Passwords belonging to British politicians, diplomats and senior police officers have been traded by Russian hackers, it has been reported.

Security credentials said to have belonged to tens of thousands of government officials, including 1,000 British MPs and parliamentary staff, 7,000 police employees and more than 1,000 Foreign Office staff, were in the troves sold or swapped on Russian-speaking hacking sites.

The majority of the passwords are said to have been compromised in a 2012 hacking raid on the business social network LinkedIn, in which millions of users’ details were stolen.

The National Cyber Security Centre (NCSC) confirmed that its cyber security advice has been highlighted to departments in light of the discovery by the Times.

In the wake of the LinkedIn attack users were advised to change their passwords on the site and any other accounts that used the same credentials.

The warning was repeated in 2016 when it emerged the compromised passwords were being sold by criminal gangs.

A government spokesman said it was a “historical incident”.

“When it took place, LinkedIn gave advice that people should change their passwords,” he said. “Anybody who is no longer using the password will not have had their account breached.”

• This article was amended on 23 June 2017. An earlier version misnamed the NCSC as the National Crime and Security Centre.