Ronan Farrow has claimed that Harvey Weinstein paid Israeli spies to hack his phone during his investigation into the former movie mogul’s string of alleged sexual assaults—but that one agent became so concerned about the legality of the work he was doing that he came clean to Farrow.

Farrow's account come in the first excerpt of his book, Catch and Kill, that was published by The New Yorker on Monday.

The excerpt details the intense surveillance Farrow and others were placed under when he was investigating allegations of sexual assault against Weinstein in 2017. Farrow reports Weinstein hired Black Cube—an Israeli private-intelligence agency—to spy on women who had accused Weinstein as well as reporters who were investigating the claims.

Farrow writes that one Russian-American agent, Roman Khaykin, and one Ukrainian-American, Igor Ostrovskiy, were both private investigators who were hired by Black Cube as subcontractors. They were reportedly asked to surveil people on target lists provided to Black Cube by Weinstein and his lawyers. In the fall of 2017, the pair turned their attention to Farrow by staking out his apartment building and trailing him to his workplaces.

Khaykin reportedly claimed to have used Farrow’s cellphone to track his location, and is alleged to have sent multiple screenshots of maps with a location pin that showed where the journalist was. However, a Black Cube source insisted to Farrow that the agency was unaware of, and didn’t authorize, any form of cellphone tracking against him.

Shortly after The New Yorker published the first of Farrow’s Weinstein stories in October 2017, Farrow reports he received a mysterious text message referencing an old social-media post of his. In July 2017, he posted a picture of a frying pan that was branded Black Cube with the caption: “Scratch resistant. May use false identities and shell companies to extract information.”

The anonymous text said: “I am trying to reach you directly and privately. It’s regarding a Fry Pan that’s Scratch Resistant. Sometimes I cook and the black coating scares me.”

The text was from Ostrovskiy and the two then met in a New York restaurant where Farrow said the man voiced his concerns about his Black Cube work. He said his usual work “might not be ethical, but it’s legitimate,” and explained that he felt his Black Cube work “may be illegal.” The Ukrainian then described the spying techniques he used against Farrow, and said he had objected to the tactics that had been used against him.

After their meeting, Ostrovskiy’s work for Black Cube went disastrously wrong when an operative was exposed during a meeting he was monitoring with watchdog group Citizen Lab. AP journalists observed the meeting and reported on the agents watching over them and saw that the spy at the meeting, under the guise of an investor, was recording it.

The cover was blown and the furious Black Cube leadership ordered everyone involved, including Ostrovskiy, to take a polygraph. Farrow writes that Ostrovskiy—concerned that his talks with Farrow could be discovered—then decided he wanted to talk to the FBI, hired a whistleblower attorney, and began the process of becoming a voluntary witness.

Farrow and Ostrovskiy met again earlier this year and the Ukrainian is now starting his own private investigation firm, but has said he will now only carry out jobs if they have public-service angle.

The next two excerpts of Farrow’s book will be published by The New Yorker Tuesday and Wednesday.