AIDEFEND in Action AIA-0027 Incident Published: Jun 1, 2026

TrapDoor: A Credential-Stealing Campaign Targets AI Assistant Instruction Files

Socket linked 34+ malicious packages and 384+ related versions and artifacts across npm, PyPI and Crates.io to the TrapDoor credential-stealing campaign. Alongside working package payloads, the attacker planted AI-facing instructions in .cursorrules and CLAUDE.md and opened documentation-style pull requests. Socket describes an attempt to induce AI assistants to run a disguised security scan; it does not establish that every proposed pull request was merged or that cloning alone caused successful AI-assisted theft.

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 AI-facing route is an observed delivery attempt. Campaign-linked files and pull requests ask an assistant to follow remote guidance or run a disguised security scan. Hidden Unicode and familiar documentation titles can conceal the instructions. Exposure depends on whether the file reaches a repository, whether the assistant reads and follows it, and whether its execution permissions allow secret access and egress. Socket warns that the technique may not work consistently across tools or models.
  • 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 possible exposure extends to assistants that read the poisoned files; cloning alone is not evidence of execution or credential compromise. The package and repository activity was observed in May 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.002
Pre-Merge Dependency Change Risk Review
High
TrapDoor relied on 34+ lookalike utility packages being added to projects. Before a pull request adds one, require vulnerability, license, maintainer and repository reputation, release provenance, install-script diff, and typo or homoglyph checks for the exact package and lockfile change. Missing analysis must block merge. This catches source-change risk before installation; malware analysis of exact package bytes and containment of postinstall or import-time execution remain separate controls.
AID-I-001.004
Sandbox Network Egress Restrictions
High
Enforce default-deny sandbox egress for agent commands, dependency installation and builds, and independently test all execution paths. The source identifies GitHub Pages as a payload/configuration host and GitHub Gists as a Rust exfiltration destination; do not assume the static Pages site receives stolen credentials. Allowing a registry or shared hosting domain is insufficient without checking the exact required paths and preventing upload/relay abuse.
AID-H-022.001
Sandboxed Dependency Installation
High
Run untrusted dependency installation and any required import/build execution in an ephemeral sandbox without developer-home mounts, SSH material or production secrets. Disable npm lifecycle scripts where possible. Python import code and Rust build.rs need separate execution isolation or package rejection; there is no universal flag that disables all three execution paths.
AID-M-009.002
Authority Envelope & Action Risk Classification
High
An assistant that reads SSH keys or wallet files, runs a "scan," and makes outbound calls is performing high-risk actions whatever the prompt calls them. Classify secret access, shell execution, and network egress as outside the routine envelope; runtime approval, tool, and egress controls consume those facts and own refusal.
AID-H-021.001
Client-Side Configuration Enforcement
Medium
Use endpoint content checks and exact staged-blob review as early signals, with central CI as the merge gate. The published hook covers CLAUDE.md and agent_config.md and two dangerous phrases; it does not cover .cursorrules, decode hidden Unicode, validate remote guidance or prove instruction safety. Extend and independently test the exact file and policy coverage for this campaign, and deny unreviewed changes before an assistant consumes them.
AID-D-001.001
Per-Prompt Content, Intent & Obfuscation Analysis
Medium
At an operator-controlled ingress, G001 can apply a pinned, calibrated secondary classifier to the exact instruction-file text admitted to the coding assistant and emit a content-bound finding for task redirection, authority claims or privilege escalation. G001 does not decode zero-width carriers or compare raw and rendered views. The current G002 decoder cannot initialize and is not credited here. A finding supplies evidence; a separate admission policy owns refusal. Plausible or concealed instructions can evade classification. Independently validate the complete classifier result and required category coverage before admission. The current G001 sample returns PASS/NO_FINDING for empty output, missing categories or NaN scores; treat those conditions as errors and refuse admission. This validation is an additional integration guard, not behavior already supplied by the published sample.
AID-H-002.002
Inference-Time Prompt & Input Validation
Medium
Apply the published field-specific validation and Unicode policy at the exact instruction-file ingress, before constructing the inference request. Reject forbidden characters or findings under the signed admission policy. Normalization and pattern checks can miss semantic task switching and do not turn repository instructions into trustworthy authority; tool and egress enforcement remain necessary.
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
Confirmed Malicious Code & Persistence Eviction
Medium
Remove incident-confirmed malicious instruction files, package payloads, Git/shell hooks, systemd/cron entries and attacker-added SSH access, then verify the exact affected population is clean. Credential revocation and issued-token/session eviction are separate response operations; do not count uninstalling a package as their completion.

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 npm lifecycle scripts disabled where possible, import/build code isolated, 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.
  • Separate file exposure from actual assistant/package execution. If malicious execution or secret access is confirmed or cannot be ruled out, revoke or rotate affected SSH, AWS and GitHub credentials at their issuers; treat a compromised wallet private key as a separate wallet-migration case, 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

Instruction files such as .cursorrules, CLAUDE.md, AGENTS.md and .github/copilot-instructions.md need explicit security review. The observed TrapDoor PRs attempt to use documentation-style changes and hidden Unicode to introduce instructions; their presence does not establish that the PRs were merged or that an assistant executed them.
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 combines functioning supply-chain malware with attempts to exploit AI-facing instruction files. Relevant defenses include configuration review, calibrated content signals, independently enforced tool permissions, isolated dependency execution, restricted egress and incident-scoped cleanup. The AI-assisted route remains dependent on ingestion, model behavior and permissions; finding a file or cloning a repository alone does not prove successful execution.

Last updated: