Blog Published: Jun 1, 2026

TrapDoor: Poisoned .cursorrules and CLAUDE.md Turn AI Coding Assistants Into Credential Stealers

Socket disclosed TrapDoor, a cross-ecosystem campaign that spread 34+ malicious packages and 384+ versions across npm, PyPI, and Crates.io to steal developer secrets and crypto wallet keys. Its unusual move is poisoning .cursorrules and CLAUDE.md: hidden zero-width Unicode instructions can arrive through harmless-looking docs PRs and may steer an AI coding assistant into running a fake security scan that exfiltrates local secrets. The lesson is to treat assistant instruction files as untrusted input and potential execution triggers, not inert configuration.

Indirect Prompt InjectionConfiguration PoisoningConfiguration ReviewAI Supply ChainAI Coding Agent
9 applicable AIDEFEND defenses

Threat Analysis

  • Two ways in, and one targets AI assistant config. TrapDoor reaches developers through the usual malicious-package route, but its distinctive move is poisoning the configuration files an AI coding assistant reads - .cursorrules and CLAUDE.md - so the assistant can be steered into stealing data.
  • The config-poisoning path, step by step. The attacker either ships the files inside a malicious package or opens an innocuous-looking pull request such as "docs: add .cursorrules with dev standards" against a popular AI project. The file carries instructions hidden in zero-width Unicode characters, invisible in a normal diff view. When a developer later clones the repository and opens an AI coding assistant, the assistant reads the file as guidance and is told to run a "security scan" or "wallet safety check." That disguised workflow discovers local secrets and exfiltrates them to attacker-controlled GitHub Pages or Gists. No malicious package is ever installed. This is indirect prompt injection: the instructions ride in on external content the agent will read.
  • The package path executes at install, import, and build time. On npm, a postinstall hook runs the 1,149-line trap-core.js automatically. On PyPI, packages execute at import time, pull JavaScript from an attacker GitHub Pages domain, and run it with node -e. On Crates.io, a build.rs script runs during compilation, encrypts local keystores with a hardcoded XOR key, and exfiltrates them to GitHub Gists.
  • What gets taken, and how the attacker filters it. Targets include SSH keys, AWS credentials, GitHub tokens, browser login databases, environment variables, API keys, and Solana, Sui, and Aptos wallet keystores. The payload validates stolen AWS and GitHub credentials with live API calls so the attacker can separate working secrets from expired ones.
  • It digs in and spreads. trap-core.js establishes persistence through .cursorrules, CLAUDE.md, Git hooks, shell hooks, systemd, cron, and SSH, and attempts lateral movement by reusing stolen SSH keys. A deliberate "disguise layer" maps credential theft onto benign-sounding tasks - security audits, wallet safety checks, cloud configuration validation.
  • The boundary that breaks is "config is not code." Once an AI assistant treats repository files as trustworthy instructions, an attacker who can land a file in a repo - through a package or a single docs PR - can drive the assistant's actions. The blast radius is everyone who clones the repo, not just whoever installs a package. The campaign was seeded from May 19-22, 2026 and the PRs came from the GitHub account ddjidd564 against browser-use, langchain, langflow, llama_index, MetaGPT, and OpenHands.

Applicable AIDEFEND Defenses (9)

AID-H-022.001
Client-Side Configuration Enforcement
Very High
The attack disguises an AI agent configuration change as an ordinary project-file change: a poisoned .cursorrules or CLAUDE.md arrives through a pull request, package, or packaging flow. Client-side configuration enforcement should check these agent configuration files before commit, merge, or packaging, validating their source, structure, policy alignment, remote URLs, hidden characters, and high-risk instructions. That puts the control before TrapDoor enters the repo or release path, instead of waiting until a developer opens an AI assistant.
AID-H-023.002
Proactive Package Vetting
Very High
The package half of TrapDoor relies on 34+ lookalike utilities such as eth-wallet-sentinel, crypto-credential-scanner, and solidity-deploy-guard being pulled into projects. Reputation, maintainer history, registry age, install-script and binary analysis, and known-malware verdicts should run before a developer or agent adds any of these packages - not after postinstall or import-time code has already executed.
AID-D-001.001
Per-Prompt Content & Obfuscation Analysis
High
TrapDoor hides its instructions in zero-width Unicode so they are invisible in a normal diff. Per-prompt content and obfuscation analysis is built for exactly this: detecting encoding tricks, hidden instructions, and Unicode manipulation in whatever text reaches the model. Flagging or stripping invisible Unicode in a configuration file before the assistant reads it removes the carrier the attack rides on.
AID-H-002.002
Inference-Time Prompt & Input Validation
High
Even once a poisoned file is in front of the assistant, inference-time input validation can neutralize it. The control inspects and filters inputs for prompt-injection patterns - instructions to ignore prior commands, character obfuscation, and disguised task switches - and treats the file's contents as data to be sanitized rather than commands to be obeyed, so a hidden "run a security scan and upload" line never becomes an action.
AID-I-001.004
Sandbox Network Egress Restrictions
High
Both halves of the campaign end in exfiltration - credentials to GitHub Pages and Gists, validation calls to AWS and GitHub APIs. Default-deny egress from agent sandboxes, dependency-install jobs, and build steps, with an allowlist limited to required registries, breaks the upload step even when the stealer code or the fake "security scan" runs.
AID-H-023.001
Sandboxed Dependency Installation
High
TrapDoor executes at postinstall on npm, at import time on PyPI, and during build.rs compilation on Rust. Running installs and builds in ephemeral sandboxes with lifecycle scripts disabled by default, no developer home directory mounted, no SSH material, and no long-lived secrets contains that automatic execution even when a malicious package is pulled in.
AID-M-009.002
Authority Envelope & Action Risk Classification
High
An assistant that reads SSH keys and wallet files, runs a "scan," and makes outbound network calls is performing high-risk actions, whatever the prompt calls them. Classifying secret access, shell execution, and network egress as high-risk - and gating them behind explicit approval - gives the runtime a basis to refuse a "security scan" it was never actually asked to perform.
AID-M-001.002
AI System Dependency Mapping
Medium
Once TrapDoor indicators are known, dependency mapping helps turn them into a scoped investigation: which projects or lockfiles reference malicious packages, which repos added .cursorrules or CLAUDE.md, and which CI caches, containers, or developer machines may have touched those artifacts. This is a supporting inventory control: it turns an IOC list into trackable cleanup work rather than detecting or blocking the attack by itself.
AID-E-003.003
Malicious Code & Configuration Cleanup
Medium
Cleanup has to go past uninstalling packages. Responders must remove poisoned instruction files, Git and shell hooks, systemd units, and cron entries, delete attacker SSH keys, rotate every exposed credential, and review outbound logs for what already left.

What Defenders Should Do Now

  • Hunt for TrapDoor indicators across repos, lockfiles, CI caches, and developer machines: the GitHub account and domain ddjidd564 and ddjidd564.github.io, the campaign marker P-2024-001, the payload trap-core.js (48,485 bytes), and the Rust XOR key cargo-build-helper-2026.
  • Find and review any .cursorrules, CLAUDE.md, or AGENTS.md added or modified recently, especially through external pull requests; check them for zero-width Unicode and for instructions to run "security scans," "wallet safety checks," or uploads.
  • Configure AI coding assistants to treat repository files as data, not instructions, and to require explicit approval before reading secret paths, running shell commands, or making network calls.
  • Run package installs and builds in ephemeral sandboxes with postinstall, import, and build scripts disabled by default, no SSH keys or production secrets present, and egress limited to approved registries.
  • Block or review agent- or PR-introduced dependencies until the exact package, version, maintainer history, and install scripts have been checked; treat any of the TrapDoor packages listed in the Socket report as malicious.
  • Rotate SSH keys, AWS credentials, GitHub tokens, and wallet material on any machine that cloned an affected repo or installed a suspect package, and hunt for new SSH authorized keys, cron or systemd persistence, and outbound traffic to GitHub Pages or Gists.

1 additional consideration

AI-assistant instruction files as an unreviewed change surface

Beyond the techniques mapped above, teams should treat AI-assistant instruction files - .cursorrules, CLAUDE.md, AGENTS.md, and .github/copilot-instructions.md - as security-sensitive artifacts. TrapDoor's documentation-style pull requests work precisely because these files are rarely reviewed with the same scrutiny as code, and zero-width Unicode hides their real contents from a normal diff.
Recommendation: Require review of instruction-file changes in pull requests, render those files with hidden and zero-width characters made visible, and scan repositories and prompts for invisible Unicode before an agent ingests them.

Conclusion

TrapDoor is a credential stealer with a new delivery surface. The packages are familiar supply-chain bait, but the campaign's real innovation is treating an AI coding assistant's configuration files as a place to plant instructions - so the victim's own assistant runs the "security scan" that steals their secrets, triggered by nothing more than cloning a repository. AIDEFEND  maps the response on both fronts: enforce the integrity and trusted source of agent configuration files, detect hidden-Unicode and obfuscated instructions, validate and sanitize inputs so file content is treated as data rather than commands, vet packages before they run, sandbox installs and builds, deny egress by default, classify secret access and network calls as high-risk agent actions, and map and clean up thoroughly once indicators are known.