We use adjoint-based gradients to analyze the sensitivity of the drag force on a square cylinder. At Re = 40, the flow settles down to a steady state. The quantity of interest in the adjoint formulation is the steady asymptotic value of drag reached after the initial transient, whose sensitivity is computed solving a steady adjoint problem from knowledge of the stable base solution. At Re = 100, the flow develops to the time-periodic, vortex-shedding state. The quantity of interest is rather the time-averaged mean drag, whose sensitivity is computed integrating backwards in time an unsteady adjoint problem from knowledge of the entire history of the vortex-shedding solution. Such theoretical frameworks allow us to identify the sensitive regions without computing the actually controlled states, and provide a relevant and systematic guideline on where in the flow to insert a secondary control cylinder in the attempt to reduce drag, as established from comparisons with dedicated numerical simulations of the two-cylinder system.