In her first appearance representing the American public before the top-secret Foreign Intelligence Surveillance Court in 2015, Amy Jeffress argued that the FBI is violating the Fourth Amendment by giving agents “virtually unrestricted” access to data from one of the NSA’s largest surveillance programs, which includes an untold amount of communications involving innocent Americans.

The NSA harvests data from major Internet companies like Facebook, Google and Apple without a warrant, because it is ostensibly “targeting” only foreigners. But the surveillance program sweeps up a large number of Americans’ communications as well. Then vast amounts of data from the program, including the Americans’ communications, are entered into a master database that a Justice Department lawyer at the 2015 hearing described as the “FBI’s ‘Google’ of its lawfully acquired information.”

The FBI routinely searches this database during ordinary criminal investigations — which gives them access to Americans’ communications without a warrant.

Jeffress, a former federal prosecutor now serving as an independent “friend of the court,” expressed frustration over the casualness with which the FBI is allowed to look through the data. “There need be no connection to foreign intelligence or national security, and that is the purpose of the collection,” she told Thomas Hogan, then the chief judge of the court. “So they’re overstepping, really, the purpose for which the information is collected.”

The ACLU obtained the hearing transcript and other legal documents related to the secret court proceedings under the Freedom of Information Act, and released them to the public on Friday.

The FISA Court has been widely criticized for its secrecy, its extreme tendency to defer to the government, and the fact that until recently it only heard the government’s side of the case. In 2015, Congress passed a law establishing the position of “amicus curiae” to represent the interests of the public and civil liberties, and Jeffress is one of five amici now serving.

Jeffress, who is now a partner at the law firm Arnold and Porter, declined an interview request, citing the sensitivity of the FISA Court’s proceedings.

The NSA program in question, called PRISM, operates under Section 702 of the Foreign Intelligence Surveillance Act, which is scheduled to sunset in December unless it is reauthorized by Congress. What critics call the FBI’s “backdoor search loophole” is likely to be a major topic of debate in the coming months. Section 702 also authorizes a program called “Upstream,” which grabs massive amounts of data off major Internet backbones inside the U.S. without a warrant — again, because it is ostensibly “targeting” foreign communications.

The FBI’s backdoor searches are so controversial that the Republican-controlled House of Representatives passed measures in 2014 and 2015 requiring agents to get a warrant before conducting them, although the Senate refused to take up either proposal.

“Section 702 backdoor searches of Americans’ private communications are plainly unconstitutional, and the FBI’s warrantless searches are especially troubling,” said Ashley Gorski, a staff attorney with the ACLU.

The CIA and even the NSA itself have imposed a requirement that each query they run on 702 data involving a U.S. person be supported by a statement of facts that explains why the information being sought is relevant to foreign intelligence – as the independent Privacy and Civil Liberties Oversight Board recommended in 2014.

But when Hogan asked if the FBI were willing to do the same thing, the lawyer representing the Department of Justice at the hearing – whose name the government redacted in the transcript – brushed him off.

The lawyer said that searches of the FBI’s “lawfully acquired data” are so common that requiring agents to document them would be impractical, and even dangerous.

“If we require our agents to write a full justification every time — think about if you wrote a full justification every time you used Google. Among other things, you would use Google a lot less,” the Justice Department attorney said. “We want the FBI to look and connect the dots in its lawfully acquired information.”

Throughout the court hearing, the government insisted that being able to routinely sift through the data during criminal investigations was essential to national security, arguing that the ordinary crimes the FBI investigates can be connected to terrorism, unbeknownst to the agent. But when asked how often non-national security queries elicited such information from the NSA data, the lawyer conceded that “at the very least it would be extremely rare.”

Members of Congress have been trying to understand the scope of 702 surveillance for years. In 2011, Sen. Ron Wyden, D-Ore., requested an estimate of how many Americans’ communications are caught up in that one NSA dragnet — and other members and committees have repeatedly asked — but the government has refused to provide even a ballpark figure.

Just last week, the House Judiciary Committee renewed that request, sending a bipartisan letter requesting an estimate. The government published a document Wednesday saying it would not provide the number, but called on Congress to reauthorize the program anyway.

In her brief to the court, Jeffress argued that the breadth of collection on U.S. citizens was enough to warrant additional constitutional scrutiny. “Not all section 702 targets are international terrorists,” Jeffress wrote. The next several sections, presumably describing what other kind of things get caught up in the dragnet, were blacked out. She continued: “These scenarios suggest a potentially very large and broad scope of incidental collection of communications between lawful target and U.S. persons that are not the type of communications Section 702 was designed to collect,” she wrote.

Judge Hogan ultimately ruled in favor of the government, allowing the FBI to continue giving its agents virtually unlimited access to conduct backdoor searches. His 80-page opinion was declassified in April 2016.

That leaves the matter to Congress.

Jeffress told the court: “I don’t think that the FBI will voluntarily set limits on its querying procedures, because law enforcement agencies tend not to take steps to restrict or limit what they can do, for obvious reasons.”

Correction: April 21, 2017, 10:09 a.m. ET

An earlier version of this story incorrectly suggested that “Upstream” data is included in the 702 data accessible to the FBI. The FBI database gets data from the PRISM program, but not from Upstream.