The NSA had infiltrated North Korean networks before last year’s brutal attack on Sony Pictures Entertainment, according to documents leaked by the whistleblower Edward Snowden to German news magazine Der Spiegel.

An exchange between several of the agency’s employees showed that the NSA had been involved in hacking North Korea as part of its alliance with South Korea, with the spooks hijacking existing malware to achieve their aims.

A message from an NSA worker said: "While we aren’t super interested in [South Korea] (things changed a bit when they started targeting us a bit more), we were interested in North Korea and SK puts a lot of resources against them."

Exploiting South Korean "implants" on computers being used by North Korean officials, the NSA "sucked back" data in what it termed "fourth party" attacks, and was even able to hack North Korean hackers being targeted by South Korea.

"But once that started happening we ramped up our efforts to target NK ourselves (as you don’t want to rely on an untrusted [sic] actor to do your work for you)," the message added.

Other leaked documents and official sources that spoke to the New York Times claimed the NSA had also tapped into Chinese and Malaysian networks to spy on North Korea.

The reports may well add to a furore over responsibility for the attack on Sony, which the FBI claim was carried out by North Koreans, a charge the Asian dictatorship denies.