X-ray magnetic circular dichroism provides evidence of an out-of-plane spin moment in undoped and doped cuprates. In La2CuO4 this moment is related to the canting of the antiferromagnetically ordered Cu2+ spins caused by the Dzyaloshinskii-Moriya interaction within the CuO2 planes. This canting gives rise to the well-known weak ferromagnetism in high magnetic fields. We find a similar behavior in doped compounds, both in the normal and in the superconducting state, but with a different temperature dependence typical of paramagnetic systems. This result suggests that, together with short-range in-plane antiferromagnetic correlations, the Dzyaloshinskii-Moriya interaction survives up to optimal doping and in the superconducting state.