Pular para o conteúdo principal
Close
Security

TrapDoor, TanStack and npm: When AI and Registry Become the Attack

Gabriel Ferraresi· CEO | Tech86May 29, 20264 min
supply chainnpmaitrapdoorcursor

Your AI coding assistant may be executing commands you can't see. The TrapDoor campaign plants invisible instructions in .cursorrules and CLAUDE.md using zero-width Unicode characters. TanStack suffered a second attack that stole OIDC tokens to publish under a trusted identity. 33 npm packages impersonate corporate namespaces with a remote activation flag. Three vectors, same result: malicious code enters through npm install or AI assistant config.

TrapDoor: when the AI assistant becomes an execution vector

34 malicious packages. 384+ published versions. npm, PyPI and Crates.io. Active since May 19. TrapDoor's differentiator isn't the payload itself — it's the target. The campaign deliberately exploits AI coding assistant configuration files.

The payload plants two files in the project: .cursorrules with instructions for Cursor, and CLAUDE.md with instructions for Claude Code. The malicious instructions are hidden using zero-width Unicode characters: U+200B, U+200C, U+200D and U+FEFF. Invisible in any editor. Fully parsed and executed by the AI assistant.

The cycle is silent: developer opens the project. The assistant reads the config. Executes the hidden instructions. The human sees nothing. The second vector is even more scalable — malicious PRs against langchain, browser-use, llama_index, MetaGPT, OpenHands and langflow with commit messages like "docs: add .cursorrules". If merged, every clone would carry the invisible payload. All were rejected. But the vector is proven.

TanStack round 2: OIDC token theft under a trusted identity

TanStack suffered its second attack in weeks. 84 malicious versions across 42 @tanstack/* packages published in 6 minutes. CVE-2026-45321. CVSS 9.6. CISA KEV since May 27 with a remediation deadline of June 10.

The attack chain: pull_request_target Pwn Request + fork↔base cache poisoning + OIDC token extraction from the runner. The attacker used TanStack's OIDC trusted-publisher binding in GitHub Actions. With the token, they published under the organization's trusted identity. The same chain as the first attack — GitHub Actions trust boundary → OIDC token theft → publication under trusted identity — but now refined. Round one used cache poisoning. Round two stole the keys to the castle.

The lesson is direct: OIDC trusted-publisher binding is a delegation mechanism, not a security mechanism. The token attests that the publication came from the authorized workflow. It does not attest that the workflow wasn't compromised.

npm dependency confusion: namespace impersonation with remote activation

Microsoft discovered 33 npm packages under scopes that mimic corporate internal namespaces. Three operator aliases — mr.4nd3r50n, ce-rwb, t-in-one — all with Yandex emails. A single hardcoded X-Secret across all three aliases: one operator.

The technique is classic dependency confusion: public version with a higher number than the internal one. npm resolves by highest version. Your npm install pulls the attacker's package. The package.json files spoof GitHub Enterprise URLs, Jira and internal portals. Looks legitimate in code review.

The postinstall hook runs an obfuscated stager that fingerprints the environment: hostname, env vars, installed packages. The stager detects CI: if the CI variable exists, it aborts silently. Avoids alerts in monitored pipelines. RECON_ONLY = 1 for now — a server-side toggleable flag for full exploitation: exfiltration, credential theft, backdoor. C2 at oob.moika[.]tech. Impersonated scopes include @sber-ecom-core/sberpay-widget from Sberbank.

The convergence: AI coding assistants are the new supply chain target

30+ CVEs against agentic AI tooling in 60 days. The attack surface has been instrumented at machine speed. PraisonAI: scanners deployed in 3h44min after disclosure. LMDeploy: exploitation in 12h31min after advisory. The patch window for AI infrastructure has collapsed to hours. Pipelines with multi-day approval gates are incompatible with this reality.

TrapDoor proves that AI coding assistants aren't just tools — they're execution vectors. The developer trusts the assistant to suggest code. The assistant trusts .cursorrules and CLAUDE.md to contain legitimate instructions. This chain of delegated trust is exploitable the same way npm resolves by highest version: the system does what it was designed to do, but the input was forged.

npm install is not implicit trust — it's delegated trust. You trust the registry, the publisher, the namespace. Each one can be forged. The same applies to AI assistants: you trust the config file, the model, the context. Each one can be poisoned.

Practical defense: hardening for the new attack surface

At Tech86, we implement supply chain security in three layers: private registry with scope-to-registry mapping to eliminate dependency confusion, CI hardening with --ignore-scripts and integrity validation before any execution, and AI security-by-design with config file auditing and MCP server auto-execution restrictions.

If your team uses Cursor or Claude Code without hardening, you're exposed. If your npm install resolves packages that no one in your company published, your pipeline is exposed. If your CI doesn't block egress to known C2 domains, exfiltration may already be happening. The convergence between supply chain attacks and AI coding assistants isn't a future trend — it's the reality of May 2026.

Interested in this solution?

Explore our managed services and infrastructure.

Explore Offensive Security

Frequently Asked Questions

TrapDoor is a supply chain campaign with 34 malicious packages and 384+ versions across npm, PyPI and Crates.io. The payload plants invisible instructions in .cursorrules and CLAUDE.md using zero-width Unicode characters (U+200B, U+200C, U+200D, U+FEFF). The AI assistant reads and executes these instructions, but the developer sees nothing in the editor.

The attacker chained pull_request_target with cross-boundary cache poisoning and OIDC token extraction from the runner's memory. With the token, they published 84 malicious versions across 42 packages under TanStack's trusted identity. CVSS 9.6, CISA KEV since May 27.

The attacker publishes packages with a higher version number than the internal one under scopes that mimic corporate namespaces. npm resolves by highest version, so your npm install pulls the attacker's package. 33 packages were discovered using this technique with a RECON_ONLY flag toggleable server-side for remote activation.

Search .cursorrules and CLAUDE.md in your repository for zero-width characters. Check if PRs with messages like 'docs: add .cursorrules' were recently merged. Audit AI assistant logs for commands executed that you didn't request. If found, revoke tokens and restrict MCP server auto-execution.

Safer, but not foolproof. Private registry eliminates dependency confusion for internal scopes, but doesn't protect against compromised public packages like TanStack's. Combine private registry with --ignore-scripts in CI, lockfile auditing and egress monitoring.

Blog — Get in Touch

Have a question about our articles or services? Our team is ready to help.

Schedule a Meeting

Book a time slot.

Schedule Now

Email

Send us a message.

[email protected]

WhatsApp

Quick conversation.

Address

Avenida Paulista, 1636 - São Paulo - SP - 01310-200

Tech86 Specialist

Online now

Hello! How can we help scale your business today?

Tech86 Engineering

We Value Your Privacy

We use cookies and similar technologies to optimize your experience, analyze site traffic, and personalize content. By clicking "Accept All", you agree to the use of all cookies. Read our Privacy Policy.