A battle is heating up over whether a Louisiana private investigator who allegedly tried to obtain President Trump’s tax records did so to warn authorities around a security flaw.

On one side is Jordan Hamlett’s attorneys, who argue their client is a so-called ‘white hat hacker,’ a hacker who highlights bugs and cybersecurity issues so they can be fixed. And on the other, the Department of Justice is trying to force that narrative out of the courtroom altogether, and saying the defense’s position is merely trying to cover up for a crime. The dispute shows how the justice system can sometimes be skewed against, or unsympathetic towards, security researchers, or how trying to uncover cybersecurity issues in government systems can be legally perilous.

“Despite seizing every electronic device Hamlett owned, despite thorough forensic analysis of those devices, and despite a score of interviews with associates and family of Hamlett, the vast investigative resources of the federal Government has been unable to produce one shred of evidence that Hamlett was intending to do anything other than his stated intent —to discover, out of sheer curiosity, whether Trump’s tax information could be accessed through a flaw [in a government website],” Michael A. Fiser, Hamlett’s defense lawyer, wrote in a court filing last week.

Hamlett allegedly tried to obtain Trump’s records in September last year, and is charged with misuse of a Social Security number —Hamlett supposedly attempted to access the records through the Free Application for Federal Student Aid (FAFSA) website. Hamlett was ultimately unsuccessful in accessing any of Trump’s information; hackers have previously linked the last four digits of the Social Security number included in Hamlett’s November 2016 indictment to Trump. According to other court documents, Hamlett admitted the charged offense in an interview with officers shortly after he was arrested.

On the same day Hamlett allegedly probed for Trump’s tax information, he tried to warn the IRS about security issues with the FAFSA service, the defense filing adds. “Hamlett abandoned the attempt to notify the IRS when he could not reach a human, only recorded messages,” Fiser continues.

This wasn’t some isolated incident for Hamlett: he apparently has a history of reporting security flaws. According to the defense filing, the Government’s own evidence shows that Hamlett discovered a separate flaw in the Livingston Parish Sheriff’s Office’s systems which allowed access to raw investigation reports and personal identifying information about police officers.

The issue centres around intent: did Hamlett go out and try and obtain Trump’s tax records maliciously? The defense believes Hamlett “has every right to present evidence that he had no “intent to deceive” when he attempted to expose a security flaw in the FAFSA Data Retrieval Tool,” according to the filing.

The prosecution does not want Hamlett bringing any of that context or justification into the case, and has asked the judge to block Hamlett from presenting any evidence or argument along those lines. But the Justice Department doesn’t focus on whether Hamlett wanted to warn the IRS of a security issue; instead, its position is that, legally, there is no such thing as a white hat hacker defense.

“The so-called white hat defense is not really a ‘defense’ at all. It is essentially nothing more than a belated excuse for a crime,” a Department of Justice filing from earlier this month reads. The government attorneys also write that such a defense would confuse the jury.

“His after-the-fact excuses and self-justifications are wholly irrelevant,” the government’s filing adds.

For EFF Criminal Defense Attorney Stephanie Lacambra, the issue falls in Hamlett’s favour.

"I would likely echo the defense attorney's comments that his client has a right to present evidence intended to raise a reasonable doubt as to any essential element of the government's case. If the defense thinks the white hat theory of defense undermines the essential element of intent, they should be permitted to present evidence on that issue,” she told The Daily Beast.

Hamlett’s trial is scheduled for December.

“The jury in Hamlett’s case should be allowed to determine his guilt or innocence based on all the relevant evidence, not just the evidence cherry-picked by the Government,” Fiser, Hamlett’s attorney, writes in his filing.