As per "42 USC § 401 - Trust Funds":
(h) Benefit payments
Benefit payments required to be made under section 423 of this title, and benefit payments required to be made under subsection (b), (c), or (d) of section 402 of this title to individuals entitled to benefits on the basis of the wages and self-employment income of an individual entitled to disability insurance benefits, shall be made only from the Federal Disability Insurance Trust Fund. All other benefit payments required to be made under this subchapter (other than section 426 of this title) shall be made only from the Federal Old-Age and Survivors Insurance Trust Fund. (hat tip: Sean Cheshire's answer)
However, it looks like these rules were violated in 2011/2012. As per Wikipedia:
During 2011 and 2012, for example, FICA tax revenue was insufficient to maintain Social Security's solvency without transfers from general revenues. These transfers added to the general budget deficit like general program spending.
How was the legality of such a move resolved when this seemingly violated 42 USC § 401?