Todd Egeland had a long career with the CIA, serving in senior positions like chief strategy officer, chief of cyberthreat analysis and chief of counterintelligence assessments, according to his bio.

But Egeland, whose bio says he retired from the CIA in 2008, has been involved in an investigation for an unlikely paymaster — Uber, CNBC has learned.

The revelation that Uber hired a CIA veteran to conduct investigations into an opponent came in a judge's order Tuesday in a legal tussle between Uber founder Travis Kalanick and a plaintiff who alleges that Kalanick engaged in a price-fixing scheme with Uber drivers.

One focus of the months-long legal battle has been over Uber's use of a private investigative firm called Ergo, which is based in New York.

Read More from CNBC: Uber Riders Can Now Schedule Trips Up to 30 Days in Advance

On Tuesday, U.S. District Judge Jed Rakoff ordered Uber to hand over documents in the case. Plaintiff attorneys are trying to figure out what Uber's involvement, if any, was in an alleged incident in which an investigator working for the private investigative firm is said to have lied in order to obtain information about a plaintiff in the lawsuit.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

In his order, Rakoff said developments in the case provide a "reasonable factual basis to suspect that a fraud occurred and that Uber's communications may have been in furtherance of it."

According to the judge, plaintiffs alleged that an employee of Ergo contacted professional colleagues of the plaintiff's counsel Andrew Schmidt in order to develop information about him. The investigator allegedly falsely said he was compiling a profile of "up-and-coming labor lawyers in the United States."

Initially, according to the judge, a defense attorney said the Uber side was not involved in the phony phone calls. But later, the judge wrote, "both Uber and Ergo, while confirming the investigation, represented that Uber did not direct Ergo to make any misrepresentations in the course of the investigation and that any such misrepresentations were the fault, if any, of a misguided Ergo employee."

Read More from CNBC: Uber Seeks to Placate Drivers With a Host of New App Features

The judge did not like that. "There is a strong suggestion that, at a minimum, an Ergo investigator hired by Uber in connection with this case made false representations in order to gain access to information about plaintiff and his counsel," Rakoff wrote "thus raising a serious risk of perverting the processes of justice before this Court."

The judge's order says the individual at Ergo who conducted the investigation was Miguel Santos-Neves. Egeland, the CIA veteran at Ergo, "tasked Mr. Santos-Neves with conducting the investigation," the order says.

Egeland is a managing partner of Ergo, according to his biography on the firm's website. Egeland "leads Ergo's geopolitical risk and strategy consulting practice, and is responsible for managing relationships and developing new business with a broad array of private and public-sector clients," the bio says.

A spokesman for Uber declined to comment.

Officials at Ergo did not respond to requests for comment.

On its website, Ergo says it "delivers ground truth and actionable intelligence obtainable only from frontline sources." The firm also says it provides "exact-fit intelligence and solutions" to its clients. But the firm does not list the names of those clients. Under the heading "Complete confidentiality," the firm says: "Our established networks and proven research techniques enable our clients to remain far in the background, protecting against disinformation and asset inflation."

Read More from CNBC: Uber's Books Still Top Secret, But It's Biggest Weakness Isn't

According to the website, Ergo is run by R.P. Eddy, a former National Security Council official. The firm says its advisory board is made up of a long list of figures who are well connected in the worlds of international diplomacy, finance and intelligence.

Those include: former Israeli Prime Minister Ehud Barak, former Clinton and Bush administration terrorism czar Richard Clarke, former New York Police Department deputy commissioner for intelligence and CIA veteran David Cohen, former chief of the British Secret Intelligence Service Sir Richard Dearlove and former New Mexico Gov. Bill Richardson.