Official Secrets Act

""The Official Secrets Act is not there to protect Secrets, it is there to protect Officials.""

- Sir Humphrey, Yes Minister

""That's another of those irregular verbs, isn't it? I give confidential press briefings; you leak; he's being charged under section 2A of the Official Secrets Act.""

- Bernard Woolley Yes Minister

This is what you break when you leak UK government secrets to the media. (It is also the legislation that covers spies and other more serious breaches of secrecy than "the minister for health called the pop celebrity "poofy"" level stuff that tabloids love.) Its enforcement is famously spotty and erratic when it comes to media leaks; for example, a document that is generally positive toward the government will not get investigated, even if it cannot legally be released. Yes Minister explains quite well why you never tend to see the leaker's name published.

""If the leaker is an official, then you can't publish because that is not fair. Ministers are there to take the blame. Conversely, if the leaker is a Minister, you can't publish because if you do, he will reveal all the other leaks he knows about. But mostly you can't publish because the leak came from ..." Indicates upward, signifying the Prime Minister's Office ."

This is not quite as accurate anymore but still has a certain truth to it. In order to commit an offence you must be aware that telling people is an offence, the disclosure must cause harm to the UK or her interests and you must know or should know that harm could occur from it. There are certain reasons you can break the act, but since the 1989 version every politician's favourite get out clause "it was in the public interest" is no longer a valid defence.

"Signing the Official Secrets Act" is a common expression, but only done these days for security-cleared posts and it applies regardless.
 * It should be noted that actually signing the Official Secrets Act is not required, simply having the document marked with the Official Secrets Act implies you agree to the terms, even if you haven't signed (or read) the document in question.

The Official Secrets Act is considered to be the ultimate law that allows the government to do anything they want to someone who knows a secret (in spy novels). In Real Life, the U.S. government is said to be changing (or already has) its laws to more closely match this, because they are jealous of the power of Britain to stop embarrassing leaks.
 * The law is quite broad in a lot of areas, but often only if you are a member of the Intelligence Services or a government employee. If you have access to defence info and show them to anyone, even if you don't realise what they are, even if you never even read the Act stapled to the front, even if you never realised that it was potentially a problem that you showed them, the government will still have your head on a platter (well, the CPS will get you locked up for the rest of your life).

There are also things called "D-Notices" (no longer called that), which are formal requests, with no legal force, for the media not to cover a certain area or story.
 * Such as when an agreement was made with the Media to keep Prince Harry's tour of duty in Afghanistan a secret until the story was leaked quite late.
 * Something similar was done by Americans to facilitate Bush's Thanksgiving Day visit to Baghdad in 2003. Also in on it was a British Airways pilot who inquired if he had seen Air Force One. The USAF pilot replied that they were a Gulfstream V, and luckily the Brit dropped the issue.