The Invisible Threat: How Supply-Chain Attacks Target DeFi
The security firm Socket recently uncovered a sophisticated malware campaign dubbed TrapDoor, which has infiltrated major package registries like npm, PyPI, and Crates.io. Unlike traditional exploits that target vulnerabilities in smart contract code, TrapDoor focuses on the developers themselves. By embedding malicious code within ordinary developer workflows, attackers are seeking to compromise the infrastructure, credentials, and CI/CD pipelines that govern decentralized finance (DeFi) protocols before a single line of code is even deployed to the mainnet.
Exploiting the Developer Workflow
The TrapDoor campaign leverages common actions—such as installing a package, importing a library, or running a build command—to execute malicious payloads. These attacks utilize "postinstall" hooks and build scripts to exfiltrate sensitive data, including SSH keys, GitHub tokens, and cloud credentials. By compromising a single developer's machine, attackers gain lateral movement into private repositories and deployment environments. This creates a direct path to user funds through the "control plane" of a protocol, bypassing the need for a vulnerable smart contract and rendering traditional audits ineffective.
The Rise of AI-Assisted Exfiltration
A novel aspect of the TrapDoor campaign is its attempt to manipulate AI coding tools like Cursor and Claude Code.
Attackers planted hidden instructions using Unicode techniques in configuration files such as .cursorrules and CLAUDE.md.
These "instruction injections" are designed to steer AI assistants toward discovering and exfiltrating secrets during the development process.
As AI becomes more integrated into software engineering, these tools are becoming a new, silent exfiltration mechanism that operates within the context provided by compromised project files.
A Growing Industrialized Threat
The scale of these supply-chain attacks is rapidly increasing, with Sonatype reporting over 454,600 new malicious packages in 2025 alone. Recent incidents involving protocols like Drift and KelpDAO—which lost hundreds of millions due to compromised infrastructure and social engineering—highlight the devastating impact of off-chain failures. While smart contract security has matured, the industry now faces a "bear case" scenario where a single infected developer machine could push annual DeFi losses above $1 billion. The security frontier has shifted from the blockchain itself to the laptops, dependencies, and AI environments where the next generation of finance is built.