The German government has confirmed that it is investigating a cyberattack against government computer networks, according to local media reports.

The country's interior ministry said on Wednesday that the incident was "isolated and [had been] brought under control within the federal administration".

Earlier on Wednesday, German news agency DPA reported that hackers had used malware to target Germany's foreign and defence ministries and steal data, according to security sources.

The hacking appeared to have originated from the APT28 group, also known as Fancy Bear, which many experts think has ties with the Russian government, DPA reported.

The news agency said the attack had been detected by German authorities in December and possibly lasted more than a year.

The interior ministry did not respond to the allegations that APT28 was behind the attack.

A spokesperson said appropriate measures had been taken to investigate the breach and protect data.

Moscow has denied involvement with the group, which has been blamed for operations including an attack on the German parliament in 2015, and the Democratic National Committee in the run-up to the 2016 US elections.