A British government agency, under a covert spying program code-named Squeaky Dolphin, monitored and collected user information from YouTube and Facebook users without those companies’ knowledge or consent, NBC News has reported.

The NBC News report was based on National Security Agency documents, obtained through former NSA contractor Edward Snowden. The information in the docs was provided by Glenn Greenwald, the former columnist for U.K. newspaper The Guardian who was first contacted by Snowden in late 2012 and later provided him with thousands of classified documents.

According to NBC News, Facebook and Google reps said the companies were unaware the British government was collecting such data and that they had not given permission to do so.

“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,” Google said in a statement. “We do not provide any government, including the U.K. government, with access to our systems. These allegations underscore the urgent need for reform of government surveillance practices.”

The section in question, called “Psychology A New Kind of SIGDEV” (Signals Development), allegedly spells out “Broad real-time monitoring of online activity” of YouTube videos, URLs “liked” on Facebook, and Blogspot/Blogger visits. For example, the British officials showed their U.S. counterparts how they retrieved trend information from YouTube, Facebook and blog posts on Feb. 13, 2012, a day before an anti-government protest in Bahrain, NBC News reported, citing the documents.

The General Communications Headquarters, the U.K. agency that tapped into YouTube and Facebook, said in a statement that it was operating within the law. “All of GCHQ’s work is carried out in accordance with a strict legal and policy framework,” the agency said in a statement to NBC News.

One source close to Google told NBC News they were “shocked” to learn the U.K. government was monitoring its YouTube data.