CNN  — 

Edward Snowden, the former CIA contractor who leaked intelligence secrets in 2013, has agreed to forfeit more than $5 million he earned from his book and speaking fees to the US government, according to court records.

Snowden published his book “Permanent Record” last year without government approval, in violation of contracts he signed with the CIA and the National Security Agency.

A federal judge had sided with the Justice Department in its lawsuit to claw back Snowden’s proceeds, and was considering how much he would need to pay.

The agreement Snowden’s legal team reached may not be the end of the dispute of his book proceeds, however.

The judge has not yet approved the forfeiture plan.

And Snowden, in the agreement, said he still wants the ability to appeal the judge’s earlier decision against him.

He tweeted his reaction to CNN’s reporting on Tuesday. “A) This is not a settlement; I didn’t agree to it. B) The judgement from this censorship case is not enforceable while I am in exile, but I’ve never had that much money anyway,” he wrote on Twitter, highlighting how he may still contest his case in court or be able to block handing over his proceeds. “Better headline: ‘US could gain up to $5m by pardoning Edward Snowden,’” he added.

Snowden’s pardon suggestion on Twitter downplayed the current reality of his situation – if the court proceedings stand, Snowden would still be liable for the $5 million his lawyers said he’s gained and agreed to give up, and potentially more.

Snowden has engaged in a political dance with US authorities for years, since his leak exposed US surveillance techniques. He said previously he would like to return to the US if he were guaranteed a fair trial. His supporters have long advocated for a pardon, and President Donald Trump recently floated it as a possibility. Federal prosecutors have made public a 2013 criminal complaint charging him with theft of government property and unauthorized communication of national defense and classified information.

The case represents one of the few ways the US government has found to hold former employees accountable for unauthorized leaks. John Bolton, the former national security adviser who published a damaging book about President Donald Trump earlier this year, faces a similar attempt by the Justice Department to claw back proceeds for publishing. That case is still ongoing, with a hearing set for this week. Bolton disputes the government’s accusations.

Snowden, who lives in Russia, had earned $4.2 million from his book sales, royalties and related rights as of this month. He gave 56 paid speeches that included disclosures that breached his government secrecy agreement, according to the court filing from his lawyers in the US and the Justice Department. In all, Snowden made about $1.03 million from the speeches, with an average speaking fee of $18,000.

The money will be put in a trust, according to the plan to which Snowden and the Trump administration agreed.

An attorney for Snowden said the agreement filed in court on Tuesday doesn’t mean the US government will be able to immediately collect the money, because Snowden is considering appealing the judge’s previous decision that he was liable for the disclosures.

“This is not like he’s going to fork over the money. This gives them a judgment they were going to get anyways,” said Lawrence Lustberg, Snowden’s attorney, on Monday, noting that it may be difficult for the US government to get access to Snowden’s funds if they’re kept out of the country.

The $4 million was Snowden’s advance from his publisher for writing his book, Lustberg said.

This story has been updated with comment from Snowden and additional context about the case.