I was idly wandering about nuclear weapons proliferation and what happens when a nuclear armed state collapses. This got me thinking about the fall of the Soviet Union. This is (as far as I am aware) the only instance of a nuclear armed state ceasing to exist with all the disruption that comes from that. In the disorder that followed the collapse was there ever a risk of nuclear materials going missing and what steps were taken to prevent this (and by whom)?
The long and short is that the Soviet nuclear arsenal was never left in a "stateless" condition: command and control passed on in a relatively orderly fashion.
The main fact behind this is that the Soviet military continued after 1991 as a transitional Commonwealth of Independent States military theoretically under joint command of its member states. Russia had declared itself to be the legal successor to the USSR, assuming its UN seat, its treaty obligations, it's foreign debt, and control of its nuclear arsenal. The Alma Ata Protocols in December 1991 recognized that the Russian President held command and control of nuclear forces and was to use them in consultation with other members of the Commonwealth of Independent States, most notably the three other "nuclear" states that had weapons deployed on their territories (Belarus, Ukraine and Kazakhstan). Hotlines were established between these capitals and the Kremlin, and when Gorbachev resigned on December 25, 1991, he transferred his nuclear codes (kept in the "cheget" nuclear briefcase) to Russian President Boris Yeltsin.
A quick word on the nuclear codes and nuclear forces. The codes used a "triple key" system: the Soviet/Russian President had to transmit his code to the Minister of Defense, who had to transfer their code to the Chief of Staff. This controlled strategic missiles commanded by the Strategic Rocket Forces (a desperate military branch), subamrine missiles under control of the navy, and airborne weapons controlled by the Air Force. In late 1991, Gorbachev unified all nuclear weapons under one command, but this was reversed later in 1992. In April 1992, Russia created its own Ministry of Defense, which shared personnel (and nuclear codes) with the older joint military, which uneasily coexisted and shrank in importance before being dissolved in June 1993. So for a while there were technically two command and control systems over the former Soviet arsenal. After the dissolution of the joint CIS command, this control was all folded into the Russian Ministry of Defense structure.
Generally speaking, Belarus and Kazakhstan were more or less fine with de facto Russian control of nuclear weapons on their territory. Ukraine, less so. From late 1992, Ukraine has custodial control of nuclear warheads on its territory, and set up its own embryonic command and control system, as well as protocols to order military staff on its territory to not comply with launch orders that the Ukrainian President did not approve. Ukrainian control went so far that in 1993 the Ukrainian military removed and transported warheads from missiles, inching closer to its own active control. This confusing situation was only ultimately resolved by the December 5, 1994 Budapest Memorandum, under which Belarus, Ukraine and Kazakhstan agreed to the transfer of all nuclear warheads to Russian territory, which was completed by 1996.
Interestingly, the fall of the USSR itself was not the trickiest time for control of the nuclear arsenal: arguably that dubious honor goes to the failed August 1991 coup against Gorbachev. On August 19, Gorbachev was deprived of his codes by the coup plotters, and his codes went to Soviet Ministry of Defense Yazov. When Yazov abandoned his post on August 21, both sets of codes went to the General Staff, one of whom, Marshal Moiseev, became acting Minister of Defense. Gorbachev only got back his codes on August 22 and appointed a new Minister of Defense thereafter, so there was a brief window in a critically chaotic time when control of the "triple key" broke down.
A second near call was in the constitutional crisis of October 1993, when President Yeltsin squared off against the Russian legislature and his Vice President, Alexander Rutskoi. Forces loyal to Rutskoi surrounded the General Staff headquarters in Moscow on October 3, and thus nearly captured the General Staff's and Minister of Defense's codes.
Overall, the nuclear command and control system faced serious weaknesses and a lack of clarity in institutional control between 1991 and 1994, but the actual end of the USSR in December was a relatively minor and uneventful part of that transition process.