During the impeachment investigation, John Bolton, President Trump’s onetime national-security adviser, played a cagey game with Congress. He dropped hints suggesting that he knew a great deal about the President’s dealings with Ukraine—information that would have been highly relevant to the investigation. He also had a big deal with Simon & Schuster for a tell-all about his time in the Trump Administration, and the book had a tantalizing title: “The Room Where It Happened: A White House Memoir.” Bolton dodged testifying before either the House or the Senate, thus preserving his news-making disclosures for the book-buying public.

But Bolton may have outfoxed himself. Like anyone with access to classified information, he signed a prepublication-review agreement. Each government agency that allowed Bolton access to its information—and, in the case of a national-security adviser, that would have been virtually all of them—has the right to review his manuscript and to excise purportedly improper disclosures. Bolton left the government on bad terms with Trump, and it looks like the Administration may be taking revenge through the review process. Charles Cooper, Bolton’s lawyer, has already complained about how the Administration is delaying and revising Bolton’s book, and his publication date has already slipped from March to May. But there’s no guarantee that the review process will even be finished by May, either. (Cooper and a spokeswoman for Simon & Schuster declined to comment.)

House investigators asked Bolton to testify last year, but he said he would do so only if a court ordered him to. The Democrats leading the probe declined to enter into lengthy court battles with witnesses, so the House voted for impeachment without hearing his testimony. At the last moment, Bolton said that he would comply with a subpoena to testify before the Senate trial, but the Republican majority refused to call any witnesses. So Bolton made it through the Ukraine investigation without having to reveal what was in his book. Still, if he had testified, most of his story would already be out in the open, and the Administration would have no grounds to claim that it was still classified since he had already revealed it in testimony to Congress. In other words, by ducking public testimony, Bolton protected the commercial value of his book, but he left himself at the mercy of the prepublication-review process. That may turn out to have been a bad bet.

The key legal precedent involving prepublication-review agreements involves the book “Decent Interval,” by Frank Snepp, who was a strategy analyst for the C.I.A. at the U.S. Embassy in Saigon when that city fell to the North Vietnamese. Snepp had signed a contract allowing the agency to review any of his books for classified information prior to their release, but in 1977 he went ahead and published “Decent Interval,” a devastating critique of the agency’s handling of the end of the war, without doing so. In 1980, the Supreme Court ruled that the government could not withdraw Snepp’s book from circulation, but it could impose a “constructive trust” on his earnings from the book. The Snepp case established the law as it remains today. If you publish a book in violation of a prepublication-review agreement, even if it turns out that the book includes no improper disclosures, the government will take your publisher’s advance and any other revenue you earn from the book. (For example, the government has sought to obtain Edward Snowden’s book revenues, because he, too, failed to comply with a prepublication-review agreement.)

I have firsthand experience with this rule. From 1987 to 1990, I worked as a prosecutor in the Iran-Contra investigation, a complicated scandal involving the secret sale of American weapons to the government of Iran, and the use of the proceeds to help anti-Sandinista rebels in Nicaragua. I signed two prepublication-review agreements: one with the C.I.A. and one with my boss, Lawrence Walsh, the independent counsel. When I wrote a book about my experiences, I submitted it to both the agency and Walsh for review. The C.I.A. promptly approved it, without any changes, but Walsh refused to either approve or disapprove the manuscript. If I had gone ahead and published without his approval, I risked the loss of my advance and future earnings from the book. So Penguin Books, my publisher, and I, who were represented by Robert Baron , Aaron Marcu, and Martin Garbus, sued Walsh in federal court in New York for a declaratory judgment that we had a right to publish. Judge John Keenan ruled in our favor, finding that I made no improper disclosures, and my book, “Opening Arguments: A Young Lawyer’s First Case—United States v. Oliver North,” was published in 1991. (Here is a good primer on prepublication-review agreements. )

Bolton now faces a similar dilemma. He can publish the book with the redactions which have apparently been demanded by the Trump Administration. Some books by former government employees have been published with whole sections blacked out. Alternatively, he can do what I did: go to court and challenge the Trump Administration’s treatment of the book as unreasonable. This is a tough road, because most judges defer to executive-branch officials about what’s classified, and court cases take months, if not years, to be resolved.

Bolton may yet resolve his dispute with the Administration and publish a largely unredacted book next month. And it may also turn out that it would have been better for Bolton’s reputation, and for the public interest, for him to have done his civic duty and testified before Congress in the first place.