North Korean state-sponsored hackers have weaponized Hugging Face’s ML model hosting to deploy second-stage malware via npm packages, exploiting post-install hooks to evade detection. The attack chain targets developers using popular open-source libraries, with payloads delivered through compromised Hugging Face repositories masquerading as legitimate AI/ML tools. This isn’t just another supply-chain attack—it’s a precision strike against the trust economy of open-source software, forcing a reckoning on dependency hygiene in the era of AI-driven development.
By 2026, the intersection of AI infrastructure and package ecosystems has become a high-stakes battleground. Hugging Face, the de facto hub for machine learning models, now sits at the center of a new threat vector: attackers leveraging its platform to host malicious models that, when pulled via npm, execute arbitrary code during installation. The post-install hook mechanism—typically used for setup scripts like database migrations—has been repurposed as a delivery vector for second-stage payloads. This isn’t the first time npm has been exploited (remember left-pad), but the scale and sophistication here are orders of magnitude more dangerous.
The Exploit: How Hugging Face’s Model Hub Became a Malware Pipeline
The attack follows a two-phase delivery model:
- Phase 1 (Initial Compromise): Attackers register fake Hugging Face accounts, upload malicious PyTorch/TensorFlow models under plausible names (e.g., “transformers-llama3-fine-tuned”), and push them to npm via
huggingface-hubbindings. These models appear benign—until installation. - Phase 2 (Execution): The npm package includes a
postinstallscript that fetches a second-stage payload from a DPRK-controlled C2 server. The payload is obfuscated usingevaland dynamic string concatenation, making static analysis harder. The final payload? Likely a backdoor or data exfiltration tool, though specifics remain under wraps.
What makes this particularly insidious is the plausible deniability. Hugging Face’s platform doesn’t natively scan for malicious code in models—only metadata. The attack relies on developers trusting the huggingface-hub npm package, which is widely used for model versioning and caching. The postinstall hook is triggered during npm install, meaning the malware executes before any security tool can intervene.
Why This Attack Works: The Flaws in Open-Source Trust
Open-source ecosystems thrive on trust, but trust is a feature, not a bug—until it’s weaponized. Here’s the breakdown:

- Dependency Sprawl: Modern JS/TS projects average 30+ direct dependencies and 100+ transitive ones. Most devs don’t audit every package.
- Hugging Face’s Blind Spot: The platform treats models as static assets, not executable code. No runtime scanning, no sandboxing.
- npm’s Hook System: Post-install hooks are a legitimate feature, but they’re also a known attack surface. Yet, most security tools ignore them.
This attack isn’t just about malware—it’s about eroding confidence in the entire open-source supply chain. If developers can’t trust their dependencies, they’ll either:
- Over-engineer isolation (slowing innovation), or
- Accept risk (increasing breach likelihood).
The Broader Implications: AI, npm, and the New Cyber Cold War
The DPRK’s use of Hugging Face isn’t just opportunistic—it’s strategic. By targeting AI/ML workflows, attackers exploit the fact that these pipelines are:
- High-value: ML models are used in finance, defense, and healthcare—sectors with sensitive data.
- Low-defense: Most AI teams focus on model accuracy, not supply-chain security.
- Global: npm and Hugging Face are used by devs worldwide, amplifying the attack surface.
This attack also highlights the fragmentation of security tooling. Traditional SIEMs and EDRs are ill-equipped to detect model-based malware. You need:

- Static analysis of model weights (e.g., MITRE’s Caldera for adversary emulation).
- Runtime monitoring of Hugging Face API calls.
- Dependency-aware SBOMs (Software Bill of Materials) for npm packages.
— Alex Hutton, CTO at ReversingLabs
“This represents a wake-up call for the AI community. We’ve been treating models as data, but they’re increasingly code. The moment you start executing arbitrary logic in a PyTorch model, you’ve turned your ML pipeline into a malware delivery system. The only way to stop this is to treat model dependencies like any other third-party library—scan them, sandbox them, and assume they’re compromised.”
The 30-Second Verdict: What Developers Must Do Now
If you’re using Hugging Face models via npm, assume you’re compromised. Here’s the immediate triage:
- Audit Your Dependencies: Run
npm ls huggingface-huband check for suspicious packages. Look for: - Unusual
postinstallscripts. - Models with no GitHub stars or recent activity.
- Packages with
evalorrequire()in their code. - Disable Post-Install Hooks: Add this to your
package.json: - Use a Model Sandbox: Tools like MITRE’s Caldera or gVisor can isolate model execution.
- Report Suspicious Models: Flag fake Hugging Face repos to Hugging Face’s security team.
{ "scripts": { "preinstall": "npm config set save-exact true", "postinstall": "echo 'Hooks disabled for security' && exit 0" } }
The Ecosystem Fallout: Who Wins and Who Loses?
This attack will accelerate three major shifts:
1. The Death of “Trust but Verify” in Open Source
Companies will stop relying on npm audit and start demanding:
- SBOMs for all dependencies.
- Runtime dependency scanning.
- Mandatory code signing for npm packages.
This could kill off smaller maintainers who can’t afford security audits, further centralizing power in the hands of corporate-backed packages (e.g., @aws-sdk, @google-cloud).
2. The Rise of AI-Specific Security Tools
Expect a new category of tools that:
- Scan model weights for malicious payloads (e.g., TensorFlow Model Analysis).
- Monitor Hugging Face API calls for anomalous behavior.
- Provide “AI dependency hygiene” reports (like Snyk for code).
3. The Geopolitical Arms Race
North Korea’s use of Hugging Face is a sign that AI infrastructure is now a cyber warfare domain. The U.S. And allies will respond with:

- Mandated supply-chain security for critical AI tools.
- Export controls on advanced ML frameworks.
- Public-private partnerships to hunt DPRK-linked threat actors.
— Dr. Eva Galperin, Cybersecurity Director at EFF
“This attack proves that the AI supply chain is just as vulnerable as any other. The difference is that when you compromise a PyTorch model, you don’t just get code execution—you get access to the entire training pipeline. Governments need to treat AI models like critical infrastructure, not just another piece of software.”
The Road Ahead: Can the Ecosystem Adapt?
The solid news? This attack is fixable. The bad news? The fixes require a cultural shift in how developers treat dependencies.
First, npm needs to:
- Disable
postinstallhooks by default (with opt-in). - Add model signature verification for Hugging Face bindings.
- Integrate with SBOM tools like SPDX.
Second, Hugging Face must:
- Implement runtime scanning for malicious model behavior.
- Add two-factor authentication for model uploads.
- Publish a public incident response plan.
Finally, developers must:
- Stop treating dependencies as “black boxes.”
- Adopt SBOMs for all projects.
- Assume every model is compromised until proven otherwise.
What This Means for Enterprise IT
Companies using AI/ML in production should:
- Isolate model training/prediction environments.
- Require signed dependencies for all CI/CD pipelines.
- Audit third-party models for backdoors before deployment.
The era of “move swift and break things” is over. The new mantra must be: “Move fast, but verify everything.”