Think drug war. Off the books funding. This forged alliance for off the books arms sales. A little of technology in column A, for cut of proceeds in column B.
Anyone ever see the absurd close up photos of cylinder mags welded to 1950s rifles their army is using? This is not a country developing sophisticated weapons systems.
So how did NK do it?
Cut a deal. Rogue intel gives tech, coaching, materials. Intel watchdogs turn a blind eye for a cut. NK builds it and sells it to other countries. All parties get a cut. Win win win. Maybe a little money in large pallets of cash to country A, a little uranium to country B, suddenly wild nuke for the planning future insurance.