NBC News has obtained documents Edward Snowden leaked before he came to Russia showing how British intelligence agencies analyze YouTube videos, Facebook ‘likes’ and tweets

The British government can tap into the cables carrying the world’s web traffic at will and spy on what people are doing on some of the world’s most popular social media sites, including YouTube, all without the knowledge or consent of the companies.

Documents taken from the National Security Agency by Edward Snowden and obtained by NBC News detail how British cyber spies demonstrated a pilot program to their U.S. partners in 2012 in which they were able to monitor YouTube in real time and collect addresses from the billions of videos watched daily, as well as some user information, for analysis. At the time the documents were printed, they were also able to spy on Facebook and Twitter.

Documents taken from the NSA by Edward Snowden and obtained by NBC News detail how British cyber spies demonstrated a pilot program to their U.S. partners in which they were able to monitor YouTube in real time. Click on the image to read the documents in pdf form

Called “Psychology A New Kind of SIGDEV” (Signals Development), the presentation includes a section that spells out “Broad real-time monitoring of online activity” of YouTube videos, URLs “liked” on Facebook, and Blogspot/Blogger visits. The monitoring program is called “Squeaky Dolphin.”

Experts told NBC News the documents show the British had to have been either physically able to tap the cables carrying the world’s web traffic or able to use a third party to gain physical access to the massive stream of data, and would be able to extract some key data about specific users as well.

Representatives of Facebook and Google, which owns YouTube, said they hadn’t given the British government permission to access data and were unaware the collection had occurred. A source close to Google who asked not to be identified when discussing company policy said the company was “shocked” to learn the U.K. could have been “grabbing” its data.

In connection with this report, NBC is publishing documents that Edward Snowden took from the NSA before fleeing the U.S., which can be viewed by clicking here. The documents are being published with minimal redactions.

One of the people who helped prepare the demonstration was an official from the British signals intelligence agency General Communications Headquarters (GCHQ) who worked for a division of the agency called GTE, or Global Telecoms Exploitation. GTE has already been shown in other documents released by Snowden to be tapping fiber optic cables around the world.

In 2013, the Guardian reported that Snowden documents showed GCHQ was able to tap fiber optic cables and store huge amounts of data for 30 days, and that the government was placing intercept probes on transatlantic cables when they landed on British territory. Germany’s Sueddeutsche Zeitung reported that another Snowden document indicated major telecom firms, including BT, Verizon and Vodafone, were cooperating.

The British cyber spies sometimes share their intercepted raw data and their analyses with their American counterparts. In October, the Washington Post revealed that a Snowden document dated Jan. 9, 2013, described a joint NSA/GCHQ program called MUSCULAR, in which the U.S. and British agencies shared intercepted data from fiber optic cables and copied “entire data flows” from Yahoo and Google.

The Guardian via Getty Images

Edward Snowden speaks during an interview in Hong Kong. Snowden revealed details of top-secret surveillance conducted by the National Security Agency.

According to a source knowledgeable about the agency’s operations, the NSA does analysis of social media similar to that in the GCHQ demonstration.

National security experts say that both the U.S. and British operations are within the scope of their respective national laws. When the Washington Post reported on the MUSCULAR program, the NSA said in a statement that it is “focused on discovering and developing intelligence about valid foreign intelligence targets only” and that it uses “Attorney General-approved processes to protect the privacy of U.S. persons.”

But privacy experts and former government officials say the lack of disclosure by the intelligence agencies inspires public fear that rights of privacy, free speech and dissent have been infringed.

“Governments have no business knowing which YouTube videos everyone in the world is watching,” said Chris Soghoian, chief technologist for the ACLU. “It’s one thing to spy on a particular person who has done something to warrant a government investigation but governments have no business monitoring the Facebook likes or YouTube views of hundreds of millions of people.”

It might also have a chilling effect on companies like Google. Jason Healey, former White House cyber czar under George W. Bush, says U.S. and British intelligence encroachment on the internet is a threat to everyone, including social media companies.

“We want our security services to be out there and keeping us safe,” said Healey, “but we can also look for balance, we can look for limits, especially if we’re putting at risk this most transformative technology since Gutenberg.”

According to the documents obtained by NBC News, intelligence officers from GCHQ gave a demonstration in August 2012 that spelled out to their U.S. colleagues how the agency’s “Squeaky Dolphin” program could collect, analyze and utilize YouTube, Facebook and Blogger data in specific situations in real time.

The demonstration showed that by using tools including a version of commercially available analytic software called Splunk, GCHQ could extract information from the torrent of electronic data that moves across fiber optic cable and display it graphically on a computer dashboard. The presentation showed that analysts could determine which videos were popular among residents of specific cities, but did not provide information on individual social media users.

The presenters gave an example of their real-time monitoring capability, showing the Americans how they pulled trend information from YouTube, Facebook and blog posts on Feb. 13, 2012, in advance of an anti-government protest in Bahrain the following day.

More than a year prior to the demonstration, in a 2012 annual report, members of Parliament had complained that the U.K.’s intelligence agencies had missed the warning signs of the uprisings that became the Arab Spring of 2011, and had expressed the wish to improve “global” intelligence collection.

During the presentation, according to a note on the documents, the presenters noted for their audience that “Squeaky Dolphin” was not intended for spying on specific people and their internet behavior. The note reads, “Not interested in individuals just broad trends!”

But cyber-security experts told NBC News that once the information has been collected, intelligence agencies have the ability to extract some user information as well. In 2010, according to other Snowden documents obtained by NBC News, GCHQ exploited unencrypted data from Twitter to identify specific users around the world and target them with propaganda.

The experts also said that the only way that GCHQ would be able to do real-time analysis of trends would be to tap the cables directly and store the data or use a third party, like a private company, to extract and collect the raw data. As much as 11 percent of global internet bandwidth travels through U.K. internet exchanges, according to Bill Woodcock, president of PCH, a non-profit internet organization that tracks and measures and documents fiber infrastructure around the world.

In the case of the YouTube video information, the surveillance of the unencrypted material was done not only without the knowledge of the public but without the knowledge or permission of Google, the U.S. company that owns the video sharing service.

“We have long been concerned about the possibility of this kind of snooping, which is why we have continued to extend encryption across more and more Google services and links,” said a Google spokesperson. “We do not provide any government, including the UK government, with access to our systems. These allegations underscore the urgent need for reform of government surveillance practices.”

A source close to Google added that Google was “shocked” because the company had pushed back against British legislation that would have required Google to store its metadata and other information for U.K. government use. The legislation, introduced by Home Secretary Theresa May in 2012, was publicly repudiated by Deputy Prime Minister Nick Clegg in 2013 and has never become law. May hopes to reintroduce a modified version this spring.

“It’s extremely surprising,” said the source, “that while they were pushing for the data via the law, they might have simultaneously been using their capability to grab it anyway.”

Encryption would prevent simple collection of the data by an outside entity like the government. Google has not yet encrypted YouTube or Blogger. Facebook and Twitter have now fully encrypted all their data.

Facebook confirmed to NBC News that while its “like” data was unencrypted, the company never gave it to the U.K. government and was unaware that GCHQ might have been siphoning the data. The company assumes the data was taken somewhere outside its networks and data centers.

“Network security is an important part of the way we protect user information,” said Facebook spokesman Jay Nancarrow, “which is why we finished moving our site traffic to HTTPS by default last year, implemented Perfect Forward Secrecy, and continue to strengthen all aspects of our network.”

GCHQ would not confirm or deny the existence of the Squeaky Dolphin program or anything else connected with this report. The agency declined to answer questions about the scope of its data collection or how it accessed the datastream.

In a statement, a GCHQ spokesperson emphasized that that the agency operated within the law.

“All of GCHQ’s work is carried out in accordance with a strict legal and policy framework,” said the statement, “which ensure[s] that our activities are authorized, necessary and proportionate, and that there is rigorous oversight, including from the Secretary of State, the Interception and Intelligence Services Commissioners and the Parliamentary Intelligence and Security Committee. All of our operational processes rigorously support this position.”

A spokesperson for the NSA said in a statement that the U.S. agency is not interested in “the communications of people who are not valid foreign intelligence targets.”

“Any implication that NSA’s foreign intelligence collection is focused on the social media communications of everyday Americans is not true,” said the statement. “We collect only those communications that we are authorized by law to collect for valid foreign intelligence and counterintelligence purposes – regardless of the technical means used by the targets. Because some data of U.S. persons may at times be incidentally collected in NSA’s lawful foreign intelligence mission, privacy protections for U.S. persons exist across the entire process concerning the use, handling, retention, and dissemination of data.”

The spokesperson also said that working with foreign intelligence services “strengthens the national security of both nations,” but that NSA can’t “use those relationships to circumvent U.S. legal restrictions.”

Both U.S. and British officials assert that while their passive collection of electronic communications might have great breadth, the actual use of the data collected is very targeted, and is dictated by specific missions. Sources familiar with GCHQ operations state firmly that this is the case in each of the agency’s operations.

Journalist Glenn Greenwald was formerly a columnist at Salon and the Guardian. In late 2012 he was contacted by NSA contractor Edward Snowden, who later provided him with thousands of sensitive documents, and he was the first to report on Snowden’s documents in June 2013 while on the staff of the Guardian. Greenwald has since reported on the documents with multiple media outlets around the world, and has won several journalism awards for his NSA reporting both in the U.S. and abroad. He is now helping launch, and will write for, a new, non-profit media outlet known as First Look Media that will “encourage, support and empower … independent, adversarial journalists.”

BY FREDERIC J. FROMMER

White House press secretary Jay Carney speaks during the daily press briefing at the White House in Washington, Monday, Dec. 16, 2013. Carney reiterated the position of the White House that there will be no amnesty for former NSA contractor Edward Snowden. EVAN VUCCI — AP Photo

WASHINGTON — In a ruling with potentially far-reaching consequences, a federal judge declared Monday that the National Security Agency’s bulk collection of millions of Americans‘ telephone records likely violates the U.S. Constitution’s ban on unreasonable search. The ruling, filled with blistering criticism of the Obama administration’s arguments, is the first of its kind on the controversial program.

Even if NSA’s “metadata” collection of records should pass constitutional muster, the judge said, there is little evidence it has ever prevented a terrorist attack. The collection program was disclosed by former NSA systems analyst Edward Snowden, provoking a heated national and international debate.

U.S. District Court Judge Richard Leon granted a preliminary injunction against the collecting of the phone records of two men who had challenged the program and said any such records for the men should be destroyed. But he put enforcement of that decision on hold pending a near-certain government appeal, which may well end up at the Supreme Court.

The injunction applies only to the two individual plaintiffs, but the ruling is likely to open the door to much broader challenges to the records collection and storage.

The plaintiffs are Larry Klayman, a conservative lawyer, and Charles Strange, who is the father of a cryptologist technician who was killed in Afghanistan when his helicopter was shot down in 2011. The son worked for the NSA and support personnel for Navy SEAL Team VI.

Leon, an appointee of President George W. Bush, ruled that the two men “have a substantial likelihood of showing” that their privacy interests outweigh the government’s interest in collecting the data “and therefore the NSA’s bulk collection program is indeed an unreasonable search under the Constitution’s Fourth Amendment.”

“I have little doubt that the author of our Constitution, James Madison, who cautioned us to beware ‘the abridgment of freedom of the people by gradual and silent encroachments by those in power,’ would be aghast,” he declared.

In addition to civil liberties critics, big communications companies are unhappy with the NSA program, concerned about a loss of business from major clients who are worried about government snooping. President Barack Obama will meet Tuesday with executives from leading technology companies. The meeting was previously scheduled, but the NSA program is sure to be on the agenda, and now the court ruling will be in the mix.

After the ruling, Andrew C. Ames, a spokesman for the Justice Department’s National Security Division, said in a statement, “We’ve seen the opinion and are studying it. We believe the program is constitutional as previous judges have found. We have no further comment at this time.”

Snowden, in a statement provided to reporter Glenn Greenwald and obtained by The Associated Press, said, “I acted on my belief that the NSA’s mass surveillance programs would not withstand a constitutional challenge and that the American public deserved a chance to see these issues determined by open courts. Today, a secret program authorized by a secret court was, when exposed to the light of day, found to violate Americans’ rights. It is the first of many.”

Klayman said in a telephone interview that it was a big day for the country.

“Obviously it’s a great ruling and a correct ruling, and the first time that in a long time that a court has stepped in to prevent the tyranny of the other two branches of government,” he said.

The Obama administration has defended the program as a crucial tool against terrorism.

But in his 68-page, heavily footnoted opinion, Leon concluded that the government didn’t cite a single instance in which the program “actually stopped an imminent terrorist attack.”

“I have serious doubts about the efficacy of the metadata collection program as a means of conducting time-sensitive investigations in cases involving imminent threats of terrorism,” he added.

He said was staying his ruling pending appeal “in light of the significant national security interests at stake in this case and the novelty of the constitutional issues.”

The government has argued that under a 1979 Supreme Court ruling, Smith v. Maryland, no one has an expectation of privacy in the telephone data that phone companies keep as business records. In that ruling, the high court rejected the claim that police need a warrant to obtain such records.

But Leon said that was a “far cry” from the issue in this case. The question, he said, is, “When do present-day circumstances — the evolutions in the government’s surveillance capabilities, citizens’ phone habits, and the relationship between the NSA and telecom companies — become so thoroughly unlike those considered by the Supreme Court 34 years ago that a precedent like Smith simply does not apply? The answer, unfortunately for the government, is now.”

He wrote that the court in 1979 couldn’t have imagined how people interact with their phones nowadays, citing the explosion of cellphones. In addition, he said, the Smith case involved a search of just a few days, while “there is the very real prospect that the (NSA) program will go on for as long as America is combatting terrorism, which realistically could be forever!”

Leon added: “The almost-Orwellian technology that enables the government to store and analyze the phone metadata of every telephone user in the United States is unlike anything that could have been conceived of in 1979.”

The judge also mocked the government’s contention that it would be burdensome to comply with any court order that requires the NSA to remove the plaintiffs from its database.

“Of course, the public has no interest in saving the government from the burdens of complying with the Constitution!” he wrote. As for the government’s complaint that other successful requests “could ultimately have a degrading effect on the utility of the program,” he said, “I will leave it to other judges to decide how to handle any future litigation in their courts.”

Sen. Mark Udall, a Colorado Democrat and member of the Intelligence Committee, said Leon’s ruling “underscores what I have argued for years: The bulk collection of Americans’ phone records conflicts with Americans’ privacy rights under the U.S. Constitution and has failed to make us safer.”

Stephen Vladeck, a national security law expert at the American University law school, said Leon is the first judge to say he has serious constitutional concerns about the program.

“This is the opening salvo in a very long story, but it’s important symbolically in dispelling the invincibility of the metadata program,” he added.

Vladeck said 15 judges on the Foreign Intelligence Surveillance Court have examined Section 215 of the Patriot Act, the provision of law under which the data collection takes place, without finding constitutional problems. “There’s a disconnect between the 15 judges on the FISA court who seem to think it’s a no-brainer that Section 215 is constitutional, and Judge Leon, who seems to think otherwise.”

Vladeck said there is a long road of court tests ahead for both sides in this dispute and that a higher court could ultimately avoid ruling on the big constitutional issue identified by Leon. “There are five or six different issues in these cases,” Vladeck said.

Robert F. Turner, a professor at the University of Virginia’s Center for National Security Law, said searching the databases involved in the National Security Agency case is similar to searching motor vehicle records or FBI fingerprint files.

The judge’s decision is highly likely to be reversed on appeal, Turner said.

He said the collection of telephone metadata — the issue in Monday’s ruling — has already been addressed and resolved by the Supreme Court. Turner said law enforcement officials routinely obtain telephone bills that include the numbers dialed without the use of a warrant.

“The odds that an American will have their phone metadata examined by law enforcement officials are about 1,000-times greater than by the National Security Agency,” Turner said.

Jameel Jaffer, deputy legal director of the American Civil Liberties Union, which has a similar challenge pending in federal court in New York, called Leon’s ruling “a strongly worded and carefully reasoned decision that ultimately concludes, absolutely correctly, that the NSA’s call-tracking program can’t be squared with the Constitution.”