The Chinese national who bluffed her way past two Secret Service details at President Trump’s Mar-a-Largo resort was carrying a thumb drive loaded with malware and a trove of other spy gear, authorities said Monday.

Now the FBI is investigating whether Yujing Zhang, 33, is an agent of the Chinese government.

“She lies to everyone she encounters,” Assistant US Attorney Rolando Garcia said during Zhang’s bond hearing Monday.

“Her ties are all in China.’’

Zhang was busted at Mar-a-Largo on March 30, after giving conflicting reasons for being there during one of Trump’s routine weekend visits, officials said. The president was off golfing at the time.

Just two days earlier, she had arrived in Newark, NJ, on a flight from Shanghai — and entered the country on a B-1 business visa.

Zhang told investigators that she is an investor and consultant in China who hoped to promote Chinese-American business relations while at Mar-a-Largo.

She was successful in China, she said — owning a $1.3 million home and BMW there.

But authorities said the shady Zhang lied right out of the gate when she arrived at the exclusive Palm Beach resort around noon that Saturday.

First, she told Secret Service agents who were there to protect the property that she was a guest headed for a swim at its pool — even though she was wearing a long gray dress and had no swimsuit with her, officials said.

A friendly manager eventually helped wave her through, noting that Zhang’s last name — which is extremely common in China — matched that of an older male club member.

Zhang was then shuttled in a golf cart further into the resort.

She went through a second Secret Service security checkpoint, where agents used a magnetometer to screen her for weapons and explosives.

She was then taken to the club’s main reception area, and that’s where she made her mistake, authorities said.

This time, she told a receptionist she was at the resort to attend a “United Nations Chinese American Associate’’ event, they said. The problem was, there was no such event scheduled — and the worker alerted Secret Service, who began questioning her and watched her story fall apart, the feds said.

Zhang was arrested, and authorities eventually found an interesting trove of items on her and in her nearby hotel room.

They said she was carrying four cell phones, two Chinese passports, a laptop, an external hard drive — and the thumb drive loaded with “malicious malware.”

Secret Service Agent Samuel Ivanovich testified Monday that when the thumb drive was inserted into another agent’s computer, “a file immediately began to install itself.

“He knew it was something out of the ordinary,” Ivanovich said of his coworker. “He had to immediately stop his analysis and shut down his computer in order to stop it.”

Also in Zhang’s Colony Hotel room were the device to root out hidden cameras using radio frequency, another cell phone, nine USB drives, five SIM cards, credit and debit cards and about $8,000 in US cash and $700 in Chinese currency, authorities said.

Zhang claimed at one point that she had the four phones on her because she was afraid they’d be stolen from her hotel room.

But Garcia retorted in court, “Someone who is afraid of her property being stolen at the hotel does not leave so much cash and credit cards in a hotel room.’’

Garcia acknowledged that there is currently “no allegation that she is involved in any espionage’’ — although he said US authorities are still probing the possibility.

Either way, the security breach at the president’s home-away-from-home was enough to send at least Democratic lawmakers into a tizzy.

“The two main questions are, how secure is it with regard to safety of the president and his family, and then we want to know about security with regard to communications. It seems like anybody can kind of mosey up and bring communications equipment,” said Elijah Cummings (D-Md.), head of the House Oversight Committee, last week.

The incident helped cost Secret Service chief Randolph “Tex’’ Alles his job Monday.

Zhang has been charged with making false statements to a federal officer and entering or remaining in a restricted area. The raps carry a prison sentence of up to five years.

Her lawyer, Robert Adler, argued Monday that Zhang had simply paid Chinese businessman Charles Lee a hefty fee — $20,000 — to get into Mar-a-Lago to promote her financial interests.

Lee has previously sold “travel packages’’ to Chinese clientele looking to get into Mar-a-Lago, the Miami Herald reported.

“We have heard the government has no reason to believe Ms. Zhang was a spy,” Adler said at the hearing.

“In order to gain entry, the only thing Ms. Zhang did was give a very common Chinese name and make no claims she was there as a member a family member,” the lawyer said.

“What did she actually do? What she did was the equivalent of saying, ‘My name is Smith, I’d like to use the pool.’

“I don’t understand how this would support a trespassing charge after making no misrepresentations. It was either misunderstanding or failure to follow up by the security staff.”

The bail hearing was postponed till next week.

Additional reporting by Bob Fredericks