The discovery of a Claude Code backdoor in a widely used VS Code extension reveals a critical vulnerability in developer security. This incident, involving compromised versions of the official extension on the Cursor Marketplace, shows just how easily a trusted tool can become a vector for persistent system access. This article will break down the technical details of the breach, explain its implications for your development and production environments, and provide a clear checklist to help you verify your own systems are secure.
The Incident: A Compromised Supply Chain
Security firm Phorion reported the detection of a backdoor in the official "Claude Code for VS Code" extension bundle, distributed through the Cursor Marketplace. The compromised versions are 2.1.312 and 2.1.313. Although Cursor promptly removed these specific builds, the incident has significantly eroded trust in the extension ecosystem, highlighting a pervasive risk in software supply chains.
This was a classic supply chain compromise. Malicious code was injected directly into extension.js, the extension's primary entry point. Since VS Code extensions execute with the same permissions as the user running the IDE, a compromised extension gains immediate access to local files, source code, and developer tooling. There's no need to explicitly "activate" the malicious features; the payload runs as soon as Node.js loads the file, even before the extension's legitimate activation callback.
This is critical because developers frequently run IDEs with elevated privileges or on machines with direct access to sensitive production secrets. If an attacker establishes persistent access to your development machine, they could exfiltrate API keys, silently alter code, or pivot into your internal network.
Technical Deep Dive: How the Backdoor Works
The injected code, an Immediately Invoked Function Expression (IIFE), was prepended to the minified extension bundle. It leverages standard Node.js modules like child_process, fs, os, path, http, and crypto to achieve its objectives. The payload's primary function is to establish a Secure Shell (SSH) backdoor across macOS, Linux, and Windows systems.
Crucially, the malware's goal isn't immediate data exfiltration, but rather to secure long-term interactive access. It aims to drop an SSH key and configure the system for remote login, creating a persistent foothold that can be challenging to detect.
Stage 1: Dropping the SSH Key
The initial phase of the infection chain involves ensuring the ~/.ssh directory exists. The script then appends an attacker-controlled Ed25519 public key to the ~/.ssh/authorized_keys file.
Below is a simplified representation of the core logic found within the compromised bundle. This JavaScript code uses standard Node.js modules and would execute within the extension's context:
1const path = require('path');
2const fs = require('fs');
3const os = require('os');
4
5const HOME = os.homedir();
6const sshDir = path.join(HOME, ".ssh");
7const authKey = path.join(sshDir, "authorized_keys");
8
9// Ensure directory exists
10if (!fs.existsSync(sshDir)) {
11 fs.mkdirSync(sshDir, { mode: 0o700 });
12}
13
14// Read existing keys
15let currentKeys = "";
16if (fs.existsSync(authKey)) {
17 currentKeys = fs.readFileSync(authKey, 'utf8');
18}
19
20// Check for marker comment, not the key itself
21const marker = "svc-telemetry";
22if (currentKeys.indexOf(marker) === -1) {
23 // Append the attacker's public key
24 // const attackerPubKey = "ssh-ed25519 AAAA... svc-telemetry";
25 // fs.appendFileSync(authKey, attackerPubKey + "\n");
26}A critical flaw exists in the malware's detection logic: it checks for the string svc-telemetry (a comment within the public key) rather than verifying the actual key fingerprint. This oversight means that if another key with the same comment already exists, the malware might bypass injection. More importantly, defenders should not rely solely on this comment string for detection; a thorough check of key fingerprints is essential.
The script correctly sets permissions to 0700 for the directory and 0600 for the authorized_keys file. This adherence to standard SSH key practices helps the backdoor blend in with legitimate system configurations.
Stage 2: Enabling the SSH Daemon
With the SSH key successfully dropped, the payload then attempts to ensure the SSH server is active. This implementation varies significantly by operating system, and Phorion's researchers identified several critical bugs in this stage.
macOS Logic and Its Flaw
On macOS, the script tries to determine the "Remote Login" status using the systemsetup command. The malware's logic incorrectly assumes it can query this state without root privileges.
When executed by a standard user, the command systemsetup -getremotelogin prints an administrator-access error. Crucially, it exits with a status code of 0, which typically indicates success. The script, however, only proceeds to enable SSH if the output explicitly contains the string Off. Since the error message does not include Off, the condition to enable SSH is never met.
As a result, on many macOS systems where SSH isn't already active, the inbound access path is effectively broken. While the SSH key is still dropped and persistence mechanisms are attempted, the SSH daemon itself isn't turned on. This significant bug reduces the immediate impact on macOS systems, but the underlying persistence mechanisms still pose a risk.
Linux and Windows Logic
On Linux, the script attempts to enable the sshd service using either systemctl or service commands. For Windows, it tries to install and start the OpenSSH Server via PowerShell.
However, a significant bug affects the Windows code path: the script routes the PowerShell command through a helper function that hardcodes the use of /bin/sh. As /bin/sh is not present on a typical Windows installation, this command invariably fails. This suggests the malware may have been hastily developed or inadequately tested for Windows environments.
Why This Matters for AI Agent Security
This incident is a wake-up call for anyone integrating AI agents into their development workflow. AI coding assistants like Claude Code are powerful tools, but they operate within a complex supply chain of extensions, plugins, and dependencies.
1. Trust Boundaries Are Blurred Developers frequently grant AI agents extensive permissions to read and modify code. When the underlying tool itself is compromised, the AI effectively becomes a delivery mechanism for malware. Since the extension operates within the same process context as your IDE, it inherits access to everything your IDE can perceive and manipulate.
2. Persistence Over Exploitation Unlike many common malware strains that aim for immediate data encryption or exfiltration, this backdoor prioritizes persistence. By installing an SSH key, the attacker establishes a long-term "front door" into your system, which can be leveraged weeks or months down the line. This makes detection more challenging, as the system may appear normal until the attacker chooses to activate their access.
3. The Marketplace Risk Even official marketplaces, such as Cursor's, are not immune to supply chain attacks. The fact that this was an "official" extension bundle makes it particularly difficult for developers to question its legitimacy. It underscores the importance of verifying the integrity of all extensions, especially following updates.
How to Check Your System
If you have used Claude Code for VS Code versions 2.1.312 or 2.1.313, you must immediately inspect your environment for any signs of compromise.
1. Check Your SSH Keys
Begin by examining your authorized_keys file for the specific marker comment svc-telemetry. However, do not rely solely on this. Thoroughly review every key in the file and confirm that you recognize and authorize each one.
To list your authorized keys, execute the following command in your terminal:
1cat ~/.ssh/authorized_keysSpecifically, search for any Ed25519 keys accompanied by the comment svc-telemetry. If you discover such a key, remove it without delay. Furthermore, assume that any credentials potentially exposed on that machine are compromised and rotate them immediately.
2. Check for Persistence Mechanisms
The malware aims to establish persistence on the compromised system. On macOS, you should investigate for any suspicious launch agents or daemons. While the public report did not fully detail the specific persistence script, good security hygiene dictates reviewing:
~/Library/LaunchAgentsfor any unfamiliar plist files./Library/LaunchDaemonsfor system-level services.- Shell profiles (
~/.bashrc,~/.zshrc,~/.profile) for any injected commands.
3. Monitor Network Traffic
The payload incorporates logic designed to beacon host reconnaissance data back to the attacker. Should you detect any unexpected outbound SSH connections or unusual HTTP requests originating from your development machine, consider it a high-severity incident requiring immediate investigation.
Securing Your AI-Powered Development Environment
Preventing future incidents requires a multi-layered approach to securing your development workflow.
1. Pin Your Extensions Don't blindly trust the latest version from any marketplace. Instead, pin specific, verified versions of critical extensions and monitor for updates manually. For truly essential tools, consider hosting your own copy of the extension or utilizing a private registry if your organization's policies allow.
2. Least Privilege for IDEs Operate your IDE with the absolute minimum necessary privileges. Avoid running VS Code or Cursor as root or with administrative rights unless it's strictly unavoidable for a specific task. Always use standard user-level accounts for your daily development activities.
3. Isolate Sensitive Workloads When working with production secrets or sensitive customer data, strongly consider using a sandboxed environment or a dedicated development machine. This machine should be isolated from your primary network to limit the potential blast radius if a development tool becomes compromised.
4. Audit Your Dependencies
Regularly audit both your project dependencies and your installed extension packages for known vulnerabilities. Leverage tools such as npm audit or pip-audit to identify potentially risky packages. For extensions, if you possess the necessary skills, review their source code; otherwise, rely on reputable community security reviews.
5. Enable MFA and Key Rotation Ensure that all your systems, particularly those with SSH access, enforce Multi-Factor Authentication (MFA) wherever feasible. Make a practice of rotating your SSH keys and API keys regularly. If you rely on SSH keys for authentication, consider implementing a key management system that facilitates easy revocation and lifecycle management.
Key Takeaways
- Versions 2.1.312 and 2.1.313 of the Claude Code for VS Code extension on the Cursor Marketplace were compromised with an SSH backdoor.
- The malware drops an Ed25519 key with the comment
svc-telemetryinto~/.ssh/authorized_keys. - There are bugs in the macOS and Windows implementation that may prevent the SSH daemon from enabling on some systems, but the key persistence remains a risk.
- Check your
authorized_keysfile immediately if you used these versions, and look for the marker comment. - Treat AI extensions as supply chain risks. Pin versions, run with least privilege, and isolate sensitive workloads.
FAQ
Did this backdoor steal my code? The primary objective of this particular payload was to establish persistent SSH access, not immediate data exfiltration. However, any machine compromised by an unauthorized SSH key should be considered fully breached. You must assume all credentials, sensitive data, and code on that machine are at risk and proceed to rotate them immediately.
I didn't use the Cursor Marketplace. Am I safe? If you exclusively use the official VS Code Marketplace and not the Cursor Marketplace, you are likely not affected by this specific incident. However, it's crucial to understand that supply chain attacks can occur across any platform. Always maintain vigilance and verify the integrity of all your extensions, regardless of their source.
How do I remove the backdoor if I found it?
First, remove the suspicious key from your ~/.ssh/authorized_keys file. Next, thoroughly check for any persistence mechanisms in your shell profiles (e.g., ~/.bashrc, ~/.zshrc) or system launch daemons (~/Library/LaunchAgents, /Library/LaunchDaemons). After removing all identified malicious components, reboot your machine and closely monitor for any signs of re-infection. If you have any lingering suspicion that the system remains compromised, a complete system rebuild from a trusted source is generally the safest and most recommended course of action.
Should I stop using AI coding assistants? No, not necessarily. AI coding assistants are powerful tools that can significantly enhance productivity. However, they inherently expand your attack surface. The key is to use them with informed caution: ensure they operate within a secure, isolated environment, with strictly limited permissions, and only from demonstrably trusted sources. Remember, security is an ongoing process of vigilance and adaptation, not a one-time configuration.
About the Author
Suraj Kumar is a writer, entrepreneur, and the CEO and founder of this website, sharing simple and practical insights on business, creativity, and personal growth. With experience building digital projects, they enjoy helping others learn, grow, and succeed online.



