San Francisco - A federal judge in New York has ordered Google to turn over to Viacom a database linking users of YouTube, the Web's largest video site by far, with every clip they have watched there.
The order raised concerns among users and privacy advocates that the online video viewing habits of tens of millions of people could be exposed. But Google and Viacom said they were hoping to come up with a way to protect the anonymity of YouTube viewers.
Viacom said that the information would be safeguarded by a protective order restricting access to the data to outside advisers, who will use it solely to press Viacom's $1 billion copyright suit against Google.
Still, the judge's order, which was made public late Wednesday, renewed concerns among privacy advocates that Internet companies like Google are collecting unprecedented amounts of private information that could be misused or could unexpectedly fall into the hands of third parties.
For every video on YouTube, the judge required Google to turn over to Viacom the login name of every user who watched it, and the address of their computer, known as an I.P., or Internet protocol, address. Both companies have argued that such data cannot be used to unmask the identities of individual users with certainty. But in many cases, technology experts and others have been able to link I.P. addresses to individuals using records of their online activities.
Google and Viacom said they had had discussions about ways to ensure the data is further protected to assure anonymity.
"We are disappointed the court granted Viacom's overreaching demand for viewing history," Catherine Lacavera, Google's senior litigation counsel, said in a statement. "We are asking Viacom to respect users' privacy and allow us to anonymize the logs before producing them under the court's order."
Michael Fricklas, Viacom's general counsel said: "We are investigating techniques, including anonymization, to enhance the security of information that will be produced."
Mr. Fricklas added that Viacom would not have direct access to the information Google produces, and that its use would be strictly limited. Viacom would not, for example, be able to chase down users who illegally posted clips from "The Colbert Report" on YouTube.
"The information that is produced by Google is going to be limited to outside advisers who can use it solely for the purpose of enforcing our rights against YouTube and Google," Mr. Fricklas said. "I can unequivocally state that we will not use any of this information to enforce rights against end users."
In a letter sent Thursday, Google's lawyers asked their counterparts at Viacom to agree to allow Google to remove information from the data that could potentially be used to identify individuals.
"We request that plaintiffs agree that YouTube may redact usernames and I.P. addresses from the viewing data in the interests of protecting user privacy," wrote David H. Kramer, a partner at Wilson Sonsini Goodrich & Rosati. Viacom did not immediately respond to a request for comment on the letter.
Privacy advocates said they welcomed Viacom's commitment to using the information only for the purposes of the litigation, but they remained concerned about protecting user rights.
"Users should have the right to challenge and contest the production of this deeply private information," said Kurt Opsahl, senior staff lawyer at the Electronic Frontier Foundation. Such right is protected by law, he said.
Mr. Opsahl said that even records that did not include a user's login name and I.P. address might be able to be associated with specific individuals. He said he believed the judge's order violated the federal Video Privacy Protection Act.
Congress passed the law to protect the video rental records of individuals, after a newspaper disclosed the rental records of Robert H. Bork, then a Supreme Court nominee.
United States District Court Judge Louis L. Stanton, who is presiding over Viacom's lawsuit against Google and YouTube, said that Google could "cite no authority barring them from disclosing such information in civil discovery proceedings, and their privacy concerns are speculative." He said the information could help Viacom make its case.
"A markedly higher proportion of infringing-video watching may bear on plaintiff's vicarious liability claim, and defendants' substantial noninfringing use defense," he wrote.