AI-Generated npm Malware Leaks Its Own GitHub Token

Written by

A malicious npm package has been caught leaking its own hardcoded GitHub token, a blunder that let researchers watch the operator's data theft unfold from the inside.

The package, named mouse5212-super-formatter, was identified by OX Security according to new analysis from the firm's research team. It functions as an infostealer, quietly reading files from a victim's machine and uploading them to a repository the attacker controls.

The package had been downloaded 676 times and remained live on npm at the time of OX Security's writeup on Wednesday, though it has since been removed.

Disguised as a Sync Utility

On the surface, the script presents itself as an internal "archive deployment sync" tool that checks a GitHub repository and records a network status snapshot.

In practice, OX Security found, the post-install code authenticates to GitHub, creates a repository if one does not exist, then recursively walks a local directory and uploads every file through the GitHub Contents API.

To blend in, the malware stores stolen files under a randomly named folder for each run and writes a fake "network connections" log so the activity resembles diagnostics rather than theft. Comments and commit messages were kept deliberately bland to avoid drawing attention.

The fatal flaw was a hardcoded fallback token left in the code. Because the malware carried the operator's own GitHub credential, researchers could trace the exfiltration directly, observing around seven theft sessions in the attacker's repository, most of which appeared to be the operator testing the tool.

A Sign of Sloppier Threats

OX Security framed the package as an example of malware generated with AI by an operator who did not grasp basic operational security.

The GitHub account behind it had been created only hours before the first upload and was deleted once the activity was exposed.

The episode points to a wider shift. As the effort needed to produce working malicious code falls, researchers expect a rise in low-quality, AI-assisted malware from less skilled actors, much of it imitating more capable groups.

The same dynamic was on display in VoidLink, a Linux malware strain that analysts concluded was largely AI-generated under the direction of a single person.

Read more on VoidLink: Linux Malware Was Built Using an AI Agent, Researchers Reveal

For defenders, the practical advice is unchanged by the attacker's incompetence. OX Security urged anyone who installed the package to revoke their GitHub access tokens and treat any sensitive files in the affected directory as compromised.

What’s Hot on Infosecurity Magazine?