The British spy agency GCHQ, with help from the NSA, intercepted millions of Yahoo webcam chats and was surprised to find that about 7 percent included "undesirable nudity."

The spy program, called "Optic Nerve," was revealed in documents leaked by NSA whistleblower Edward Snowden and was reported today by The Guardian.

"GCHQ files dating between 2008 and 2010 explicitly state that a surveillance program codenamed Optic Nerve collected still images of Yahoo webcam chats in bulk and saved them to agency databases, regardless of whether individual users were an intelligence target or not," The Guardian reported. "In one six-month period in 2008 alone, the agency collected webcam imagery—including substantial quantities of sexually explicit communications—from more than 1.8 million Yahoo user accounts globally."

While the files only cover data going up to 2010, Optic Nerve "was still active in 2012, according to an internal GCHQ wiki page accessed that year," the newspaper reported.

Yahoo told the newspaper that it was not aware of the GCHQ data collection.

"We were not aware of, nor would we condone, this reported activity," a Yahoo spokesperson said. "This report, if true, represents a whole new level of violation of our users' privacy that is completely unacceptable, and we strongly call on the world's governments to reform surveillance law consistent with the principles we outlined in December. We are committed to preserving our users' trust and security and continue our efforts to expand encryption across all of our services."

We contacted Yahoo, and the company declined to provide further comment beyond the statement saying that it intends to roll out encryption to all of its services. Today, Yahoo Messenger chats are not encrypted, although other Yahoo communication products such as e-mail are. Yahoo has said that it will give users the option to encrypt all of their data flowing to and from Yahoo services by the end of March 2014.

The bulk collection of user chats saved one image every five minutes, according to The Guardian report. Intelligence analysts were shown only metadata rather than webcam images when performing bulk searches, but they "were shown the faces of people with similar usernames to surveillance targets, potentially dragging in large numbers of innocent people," the report said. "One document tells agency staff that they were allowed to display 'webcam images associated with similar Yahoo identifiers to your known target.'"

GCHQ also trialled facial recognition technology in order to search for Yahoo users with faces similar to people targeted in investigations. One presentation described by The Guardian discussed "the potential and capabilities of the Xbox 360's Kinect camera, saying it generated 'fairly normal webcam traffic' and was being evaluated as part of a wider program."

Optic Nerve collected information "from GCHQ's huge network of Internet cable taps." That data "was fed into NSA's XKeyscore search tool, and NSA research was used to build the tool which identified Yahoo's webcam traffic."

"GCHQ does not have the technical means to make sure no images of UK or US citizens are collected and stored by the system, and there are no restrictions under UK law to prevent Americans' images being accessed by British analysts without an individual warrant," The Guardian wrote.

Somewhere between 3 percent and 11 percent of webcam chats contained "undesirable nudity," a spy agency document stated.

"Unfortunately, there are issues with undesirable images within the data," the document states. "It would appear that a surprising number of people use webcam conversations to show intimate parts of their body to the other person. Also, the fact that the Yahoo software allows more than one person to view a webcam stream without necessarily sending a reciprocal stream means that it appears sometimes to be used for broadcasting pornography."

"A survey was conducted, taking a single image from each of 323 user ids," the document further said. "23 (7.1%) of those images contained undesirable nudity. From this we can infer that the true proportion of undesirable images in Yahoo webcam is 7.1% ± 3.7% with confidence 95%."

A GCHQ spokesperson said the agency would not comment on intelligence operations, but he told The Guardian that "all of GCHQ's work is carried out in accordance with a strict legal and policy framework which ensures that our activities are authorised, 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."

The NSA declined to comment on Optic Nerve but told the newspaper that "the agency did not ask foreign partners such as GCHQ to collect intelligence the agency could not legally collect itself."