We have investigated the use of the adjoint sensitivity formulation to design efficient passive control strategies aiming at reducing the drag coefficient of a slender blunt-based body with a straight rear cavity. In particular, two control techniques consisting in wake modifications generated by placing small control cylinders in the near wake and by geometry variations of the cavity respectively, have been evaluated numerically. Thus, we have computed the turbulent flow sensitivity of the drag coefficient to localized forcing for a two-dimensional body with a straight cavity at Re=ρU∞H∕μ=2000, where U∞ is the free-stream velocity, ρ and μ the fluid density and viscosity respectively and H the body height, showing that the highest values of sensitivity are obtained near the cavity edges. The effect of placing a pair of control cylinders around the most sensitive locations has been studied, obtaining a largest drag reduction of only 0.6%. Alternatively, a most efficient control strategy based on shape optimization has been thoroughly investigated. The drag shape sensitivity on the body surface (Othmer, 2014), computed using the former linear adjoint formulation, has been used in combination with a free-form deformation algorithm (Han et al., 2011), to guide the local structure deformations of the cavity, providing progressive drag reductions until the optimal, curved, shape is achieved. To deeply analyze the physical mechanisms behind the drag reduction provided by the optimal cavity, we have also performed more realistic three-dimensional numerical simulations using an IDDES model at two different Reynolds numbers, Re=2000 and 20000. The results corroborate the sensitivity analysis, obtaining a total drag reduction of 25.6% at Re=2000 and 43.9% at Re=20000, with respect to the original body without cavity, and 21.7% at Re=2000 and 29.6% at Re=20000 with respect to the body with a straight cavity. These reductions are mainly achieved by the inwards deflection of the flow upon detachment and a flow deceleration at the trailing edge due to an adverse pressure gradient introduced by the curved shape of the optimal cavity walls. Both combined effects reduce the size of the recirculation bubble formed behind the body, increasing the base pressure, and consequently, decreasing the drag. Furthermore, the addition of the optimized base cavity reduces the amplitude of the velocity fluctuations behind the body and stabilizes the wake, which becomes less chaotic and more two-dimensional.