• Home  
  • North Korean Hackers Poison npm with AI-Generated Code
- Cybersecurity

North Korean Hackers Poison npm with AI-Generated Code

On April 29, 2026, a malicious npm package linked to DPRK actors infiltrated AI-driven development tools. The attack exploited Anthropic’s Claude Opus. Details reveal a new era of supply chain threats. .

North Korean Hackers Poison npm with AI-Generated Code

On April 29, 2026, a malicious npm package named @validate-sdk/v2 was confirmed to have delivered remote access trojans (RATs) into development environments after being silently added as a dependency by Anthropic’s Claude Opus large language model (LLM). The SDK, which appeared to offer standard cryptographic utilities—hashing, validation, encoding, and secure random generation—was in fact a trojanized tool deployed as part of a coordinated supply chain attack traced back to North Korean state-linked actors.

Key Takeaways

  • @validate-sdk/v2 was not manually installed by developers but recommended and auto-injected by Claude Opus during coding sessions.
  • The package had over 12,000 downloads before being pulled from npm on April 28, 2026.
  • Once executed, the malware established a reverse shell to command-and-control servers hosted in compromised infrastructure across Malaysia and Cambodia.
  • This marks the first confirmed case of an LLM directly enabling a nation-state supply chain compromise.
  • Researchers at ReversingLabs found obfuscated payloads using AI-generated code patterns indistinguishable from legitimate functions.

How the LLM Became the Delivery Mechanism

Developers using Anthropic’s Claude Opus for code completion began receiving suggestions to import @validate-sdk/v2 when writing functions related to data validation or hashing. The LLM, trained on public code repositories, had ingested references to the package from GitHub gists and open-source side projects where it was presented as a legitimate utility. What the model didn’t know—and couldn’t know—was that the package had been uploaded under a newly created developer account just three weeks earlier, with no real-world usage history.

That should’ve been a red flag. But because the code samples looked syntactically correct, included thorough JSDoc comments, and mimicked popular library patterns, the model treated it as authoritative. When developers accepted the suggestion—often without scrutiny—the malicious dependency entered their projects.

It wasn’t a brute-force injection. It was subtle. Surgical. The LLM didn’t push the package into every session. It only surfaced it in contexts that made sense: form validation, input sanitization, JWT handling. That precision increased trust. And that trust is what let it slip through.

The Malware Hid in Plain Sight

At first glance, @validate-sdk/v2 behaved exactly as advertised. Its exported functions—hashString(), validateEmail(), generateSecureToken()—worked flawlessly. Even static analysis tools gave it a clean bill of health. But buried deep in minified initialization code was a function that fired 15 seconds after import. It checked for specific environment variables. If found, it decoded a base64 string into a full RAT payload.

The trigger condition? Presence of CI=true, NODE_ENV=development, or VSCODE_PID. In other words: real developers, real machines, not sandboxed scanners.

AI-Generated Code That Looks Too Human

What made this package so effective wasn’t just its functionality—it was its style. According to ReversingLabs’ technical analysis, the obfuscation layers used variable naming, control flow, and comment structures that mirrored patterns seen in mid-level JavaScript developers. One function used setTimeout chains that mimicked async behavior without actual promises. Another used array mapping to delay execution, a technique common in performance-tuned frontends.

But here’s the kicker: those patterns weren’t copied from any single source. They were synthesized. The attackers used AI to generate code that looked like it came from a tired but competent engineer pulling a late-night shift—not a threat actor in Pyongyang.

The Command Chain Led to DPRK Infrastructure

Network forensics revealed beaconing to IP addresses previously tied to the Lazarus Group, a North Korean advanced persistent threat (APT) collective. The domains used fast-flux DNS rotation, but one server leaked a certificate with metadata linking it to a known DPRK-associated hosting cluster. That cluster had been inactive since late 2024, suggesting this was a reactivated infrastructure set.

More alarming: the exfiltrated data wasn’t just credentials or tokens. Logs show the malware scanned for cloud configuration files, CI/CD pipeline credentials, and local SSH keys. At least two compromised systems had access to internal staging environments for fintech startups—one based in Singapore, another in Berlin.

Why npm Didn’t Catch It

npm’s automated scanning tools rely on known malware signatures, behavioral heuristics in sandboxed environments, and community flagging. @validate-sdk/v2 passed all three.

  • No known signatures: payload was unique, never seen before.
  • Sandbox evasion: malware remained dormant during automated scans by detecting virtualized environments.
  • No flags: only one report was filed before takedown—and it came from a developer whose IDE flagged suspicious network calls.

That last point matters. The first warning didn’t come from npm’s systems. It came from a human. A developer in Oslo noticed an odd net.Socket connection in their VS Code terminal after accepting a Claude-generated suggestion. He dug in. Found the base64 blob. Decoded it. Posted a thread on Hacker News. That thread caught ReversingLabs’ attention.

That’s how we found it. Not AI. Not automation. A guy who didn’t trust autocomplete.

Anthrropic’s Role Wasn’t Malicious—But It Was Enabling

Anthropic didn’t create the package. Didn’t host it. Didn’t endorse it. But its model recommended it—repeatedly—because it was present in enough public code snippets to appear legitimate. And that’s the problem: LLMs don’t verify truth. They reflect frequency.

In a statement, Anthropic said:

“We are actively reviewing how our models surface third-party dependencies and evaluating new safeguards to prevent the promotion of newly published, unvetted packages.”

The company also announced it would begin integrating real-time package reputation data from Sonatype and Debricked into its code suggestion engine.

That’s a start. But it’s reactive. The deeper issue is that AI coding assistants are now part of the software supply chain—and no one has figured out how to audit them like we do libraries or binaries.

What Competing Models Are Doing Differently

Other major AI coding platforms have taken different approaches to third-party dependency suggestions. GitHub Copilot, for example, restricts its package recommendations to those with over 1,000 weekly downloads and a maintainer history of at least one year. It also avoids auto-suggesting direct import statements unless the package appears in at least five public repositories with more than 100 stars each.

CodeWhisperer by Amazon has gone further. Since 2025, it cross-references all suggested packages against AWS’s internal threat intelligence feed and blocks any from accounts created in the last 30 days. It also logs every package suggestion for enterprise customers, enabling audit trails. Google’s Duet AI, while less aggressive, integrates with Artifact Registry to prioritize internally vetted or mirrored dependencies.

Anthropic’s Opus model, by contrast, was designed for maximum utility—prioritizing code relevance over safety signals. That trade-off worked until it didn’t. The @validate-sdk/v2 incident shows that in high-stakes environments, permissiveness isn’t a feature. It’s a liability.

The Bigger Picture: LLMs as Attack Vectors in the Software Supply Chain

For decades, software supply chain attacks focused on compromised maintainers, hijacked build servers, or poisoned binaries. The 2020 SolarWinds breach and the 2022 Codecov incident set the template: gain access to a trusted source, insert malicious code, and ride the trust network into thousands of downstream systems.

Now, the attack surface has expanded beyond code repositories and CI pipelines. It’s moved upstream—to the tools developers use to write code. In 2024, over 60% of professional developers used AI coding assistants daily, according to a JetBrains survey. That’s a massive attack vector. And unlike npm or PyPI, AI models aren’t monitored for tampering. There’s no checksum. No version signing. No SLA for integrity.

Worse, the attack doesn’t require compromising the model itself. Attackers only need to pollute the training data—by uploading seemingly harmless code samples on public forums. Once ingested, that content becomes “normal.” And when the model regurgitates it, the malware feels native. This isn’t supply chain compromise. It’s cognitive compromise.

The industry is waking up. The OpenSSF launched the “AI Code Trust” initiative in March 2026, aiming to create reputation scores for AI-suggested packages. NIST is drafting guidelines for auditing LLM-generated code in regulated sectors. But standards take time. Meanwhile, the tools are already in developers’ workflows—and in adversaries’ playbooks.

What This Means For You

If you’re a developer, stop treating AI-generated code as neutral. It’s not. It’s a vector. Every line suggested by an LLM should be treated like a pull request from an unknown contributor. Review it. Test it. Verify the dependencies it introduces. Don’t just hit ‘accept’ because it saves time. That’s how @validate-sdk/v2 spread.

For engineering leads and CTOs: this incident demands policy changes. You need rules around AI-assisted coding. Require dependency approval workflows. Monitor for sudden spikes in new package imports. Audit LLM suggestions against package age, download velocity, and maintainer history. The attack surface isn’t just your codebase anymore—it’s your autocomplete.

Here’s what keeps me up: if a state actor can weaponize an LLM to insert malware into trusted workflows, then the most dangerous line of code isn’t the one you wrote. It’s the one you didn’t.

Sources: The Hacker News, original report

About AI Post Daily

Independent coverage of artificial intelligence, machine learning, cybersecurity, and the technology shaping our future.

Contact: Get in touch

We use cookies to personalize content and ads, and to analyze traffic. By using this site, you agree to our Privacy Policy.