The Secret Service is under fire after one of its members testified a fellow agent inserted a malicious thumb drive, found in the possession of a Chinese woman arrested at President Trump's Mar-a-Lago club last month, into an agency computer -- that then began installing unwanted files.

Monday's revelation about the embattled protection unit came the same day its director, Randolph "Tex" Alles, was reported to have been ousted as part of a larger shakeup at the Department of Homeland Security, the government arm to which the Secret Service reports.

Alles departure reportedly was not related to the March 30 incident at Mar-a-Lago in which Yujing Zhang, 32, was arrested and charged with unlawfully entering a restricted area and making false statements to federal law enforcement officers. Prosecutors said she isn’t accused of spying at this time, but noted there are "a lot of questions that remain to be answered."

WOMAN ARRESTED AT MAR-A-LAGO HAD CASH, SIGNAL DETECTOR IN HOTEL ROOM, PROSECUTORS SAY

She had $8,000 in U.S. and Chinese currency in her hotel room in addition to a signal detector meant to spot hidden cameras, a federal prosecutor in Florida said Monday. Zhang also had in her possession four cellphones, an external hard drive and a thumb drive with computer malware loaded into it.

The malicious thumb drive proved to be a particularly troubling piece of evidence.

Secret Service agent Samuel Ivanovich testified in court that another agent inserted the thumb drive into his computer in an effort to analyze it, prompting the drive to install files without the agent's consent and corrupt other files on the computer.

Yujing Zhang being led into federal court in West Palm Beach, Fla., on Monday.

Yujing Zhang being led into federal court in West Palm Beach, Fla., on Monday. (William Hennessy Jr. / CourtroomArt.com)

“That was something that had never happened before," Ivanovich told the judge, adding the agent, who was not identified, then shut down the computer to avoid further damage.

Security experts scolded the Secret Service for failing to follow one of the first rules of cybersecurity.

“Sounds like an agent trying to crack the case before the cyber team got there,” Eric O’Neill, a former FBI surveillance expert, tweeted.

SECRET SERVICE DIRECTOR TO STEP DOWN ON HEELS OF NIELSEN RESIGNATION

“You don’t put an unknown USB into your computer,” Chris Wysopal, chief technology officer at Veracode, told the Daily Beast. “That’s in all the training everyone gets, even in your dumb corporate training. You even tell your mom that.”

“You don’t put an unknown USB into your computer. That’s in all the training everyone gets, even in your dumb corporate training. You even tell your mom that.”

— Chris Wysopal, chief technology officer at Veracode

The Secret Service declined to comment to Fox News on Tuesday morning, citing the ongoing investigation.

But a source with knowledge of the investigation told Fox News that the court testimony did not accurately reflect the incident.

The source said the thumb drive’s forensic analysis was conducted on a standalone computer in accordance with protocol and added the Secret Service's network was never at risk of malware introduction, as the computer wasn’t connected to the network.

But some experts questioned this explanation, noting there would have been no reason to stop the spread of malware by shutting down the computer if the drive had been analyzed in accordance with protocol. Instead, letting the malware continue to spread on the standalone computer would have allowed analysts to gather more information about it.

Zhang is currently being held until her bond hearing resumes April 15 in West Palm Beach federal court. Prosecutors said the woman would present a "serious risk of flight" if she was released.

CLICK HERE TO GET THE FOX NEWS APP

Officials say Zhang approached a checkpoint at Mar-a-Lago and told a Secret Service agent she wanted to use the pool, even though she was not wearing a bathing suit. She was carrying two Chinese passports, which she showed as identification.

Fox News' Samuel Chamberlain, John Roberts and Ivonne Amor and the Associated Press contributed to this report.