The linear stability of high-speed boundary layers can be altered by distortions to the base velocity and temperature profiles. An analytic expression for the sensitivity is derived for parallel and spatially developing boundary layers, the latter using linear parabolized stability equations and their adjoint. Both the slow mode, S, and the fast mode, F, are investigated at Mach number 4.5. The mode S is more sensitive with respect to distortion in base velocity than in base temperature. The sensitivity is largest within the boundary layer away from the wall. Near the critical layer, where the phase speed of the mode equals the base streamwise velocity, the sensitivity to the base streamwise velocity is negative. For the mode F, there is a discontinuous jump in the sensitivity when the phase speed is below unity, and a critical layer is established. The sensitivity of the two modes increases with the Reynolds number, but there is a sudden drop and a jump in the sensitivities of the modes S and F, respectively, near the synchronization point where the phase speeds of the two modes are equal. Furthermore, the maximum uncertainty bounds are obtained for the distorted base state that maximizes the destabilization or stabilization of the modes by solving the Lagrangian optimization problem for the sensitivity. The sensitivity of the flow stability to surface heating is then studied, and changes in growth rate and the$N$-factor are evaluated. The formulation provides a clear physical interpretation of these changes, and establishes uncertainty bounds for stability predictions for a given level of uncertainty in wall temperature.