MSPs are being offered digital self-defence classes amid fears their sensitive communications with whistleblowers could be snooped on.

The Open Rights Group (ORG) - a civil liberties organisation which promotes digital freedoms - is to write to all Holyrood politicians about their IT security in the wake of rows over the use of spying powers by GCHQ - the UK government's listening post - and Police Scotland.

Since the 1960s, MPs and later MSPs believed the so-called Wilson Doctrine offered protection against MI5 phone tapping.

The convention was named after former Labour Prime Minister Harold Wilson, who promised that MPs’ telephone conversations would not be monitored.

Decades later, Tony Blair confirmed that the Doctrine also applied to electronic communication such as email.

The protection was intended to ensure an MP’s dealings with constituents remained private and guarded against political dirty tricks.

However, it was reported earlier this year that GCHQ had changed the rules by excluding MSPs from the convention.

In a further development last week, the Investigatory Powers Tribunal (IPT) ruled that the Doctrine had no basis in law for any tier of politician.

The Tribunal approvingly quoted the intelligence services’ lawyer, who had argued that the Doctrine was just “a political statement in a political context, encompassing the ambiguity that is sometimes to be found in political statements”.

The IPT added: “The Wilson Doctrine has no legal effect, but in practice the Agencies must comply with the Draft Code and with their own Guidance.”

Separately, the Sunday Herald has revealed how Police Scotland has unlawfully used its surveillance powers to see if police officers have been in contact with journalists.

Serving 'whistleblower' officers have also contacted MSPs about operational concerns and Police Scotland could, in theory, use the Regulation of Investigatory Powers Act (RIPA) to flush out these officers.

Background: Police Scotland and the journalist spying row

Pol Clementsmith, the Scottish Officer for the ORG believes MSPs should be vigilant about police and security service snooping.

In a letter to MSPs and party chief executives, he wrote: “In light of the recent discoveries that our security services, including GCHQ and MI5, are systematically spying on our devolved parliaments and parliamentarians, ORG Scotland would like to offer you the opportunity to find out more about protecting your personal online communications.”

The Herald: GCHQ has been accused of spying on foreign politicians attending two G20 summit meetings in London in 2009

Caption: GCHQ

The course, entitled “Digital Self Defence Class 101”, will show MSPs how to use secure private messaging apps on mobile phones, staying safe on social media, and encrypting emails, passwords and files.

Clementsmith also wants to teach MSPs how to back up the content of their phones and block tracking devices on their computers.

Separately, the ORG is campaigning for reform of defamation law – the Scots equivalent of libel – and for changes to be made to the Scottish Government's so-called super ID database, which would allow dozens of public bodies access to an NHS database containing private information about individuals.

Liberal Democrat MSP Alison McInnes said: “This is a welcome move from the Open Rights Group in light of the ruling of the Investigatory Powers Tribunal on the Wilson Doctrine. People need to trust that when they contact their MP or MSP, they can do so safely and securely.

"Following allegations of police spying on journalists, the Tory snooper's charter and the SNP's super ID database, this ruling is further evidence that our right to privacy is under serious threat."