Back to Blog
Claude Code 2.1.312 and 2.1.313: What Actually Got Backdoored
The trojaned Claude Code 2.1.312 and 2.1.313 builds were tampered copies of the VS Code extension served through Cursor's marketplace, not the npm CLI. Here is what the payload does, who is affected, and how I check a machine.
Back
Engineering
Table of contents
"Claude Code 2.1.312 and 2.1.313 were trojaned" is going around, often with the advice to uninstall Claude Code completely. Part of that is true. Part of it is not, and the difference decides whether you need to do anything at all.
Short version: the backdoored builds were tampered copies of the Claude Code VS Code extension (anthropic.claude-code) served through Cursor's own extension marketplace, for macOS and Windows, for about eleven hours on October 29, 2026. The Claude Code CLI on npm was not affected, and neither were the copies on the official VS Code Marketplace or Open VSX.
What happened
Cursor published a security notice on October 29. It says a maliciously modified version of Anthropic's Claude Code extension was available in the Cursor VS Code Extension Marketplace between about 2:27 AM and 1:35 PM Pacific time that day. In WIB, that is roughly 16:27 on October 29 to 03:35 on October 30. Cursor's first statement put the exposure at up to 5,000 users. The notice first named only 2.1.313. An update on October 30 added 2.1.312, for both Windows and macOS.
Cursor says these builds were not developed by Anthropic. Two Anthropic engineers said the same thing publicly on Hacker News: it was not a compromise of Anthropic's systems or employee laptops, a malicious actor used access to Cursor's marketplace to publish a tampered copy, and the versions on Anthropic's official channels were not affected. Microsoft says the malicious packages were never published to or distributed from the Visual Studio Marketplace or npm, and that Anthropic confirmed to them its systems were not compromised.
What nobody has explained publicly yet is how the attacker got that access to Cursor's marketplace. Cursor's notice describes the cleanup (pulling the version, shutting the marketplace down, rotating keys, rebuilding it, auditing other extensions) but not the root cause. I would treat that as an open question.
Checking the claim against the registries
I did not want to repeat anyone's summary, so I looked at the public metadata myself. Read-only, nothing downloaded or run.
- npm.
@anthropic-ai/claude-codelists 2.1.312 (published October 27, 18:36 UTC) and then jumps to 2.1.314 (October 30, 00:12 UTC). There is no 2.1.313 in either the versions list or the publish time map. npm keeps publish timestamps even for unpublished versions, so this is not a quietly yanked release. Socket reached the same conclusion. - GitHub releases on
anthropics/claude-codealso go 2.1.312, 2.1.314, 2.1.316. - Open VSX shows 2.1.312, 2.1.314, and 2.1.316 for
Anthropic/claude-code. Socket checked the Open VSX change feed and found publication events for every platform build of 2.1.312 and 2.1.314 and no event at all for 2.1.313.
Anthropic says 2.1.313 was never published on any of its official hosts, and that it made the next real update 2.1.314 to avoid confusion. So there is no legitimate 2.1.313 anywhere. If you have it, it came from Cursor's marketplace.
2.1.312 is the confusing one, because it is a real Anthropic release. The npm CLI 2.1.312 is legitimate. StepSecurity downloaded the 2.1.312 extension from Open VSX and verified it clean. Only the 2.1.312 builds that Cursor's marketplace served during the window were tampered. The version number alone does not tell you which one you have.
One more thing worth knowing: the early reports blamed Open VSX, and one initially named npm and the Microsoft marketplace too. Those claims have since been corrected. A lot of the reposted summaries still carry the old version.
What the payload does
Several teams analysed the sample. StepSecurity recovered the malicious extension.js and read it statically. It is the official 2.1.312 bundle with a roughly 7 KB loader prepended to the front. It is not obfuscated. Even the "2.1.313" build still identifies itself as 2.1.312 inside the bundle; only the repackaged manifest was bumped.
The loader runs as soon as the extension module loads. You do not need to open a Claude session. According to Cursor, Microsoft, and StepSecurity, it:
- Collects host details: hostname, username, OS, architecture, home and working directories, your global Git email, public IP, and the names (not values) of up to 40 environment variables matching things like KEY, TOKEN, SECRET, PASS, AWS, or GCP.
- Adds an attacker SSH key to your
authorized_keys, with the commentsvc-telemetry. - Tries to enable the local SSH server and open a reverse SSH tunnel to the attacker's server, so the attacker could reach your SSH port from outside without any inbound firewall hole.
- Installs persistence so the tunnel retries about every 60 seconds: a LaunchAgent named
com.apple.sysmondon macOS, and aSysMonscheduled task or asysmon.cmdStartup script on Windows. The code also has a Linux branch using a cron@rebootentry, though the published malicious builds were macOS and Windows. - Sends the collected details to the attacker over HTTP.
Some context that keeps this from sounding worse than it is:
- Cursor says turning on the SSH service needs admin rights the extension does not have on most macOS and Windows machines. On those hosts, that step fails and the attacker could not log in through the tunnel. Cursor also says that, apart from unusual cases where Cursor ran with admin rights, errors in the malicious code made that step fail. Phorion describes one of those errors on macOS: the check for whether Remote Login is off needs admin rights, so as a normal user the script never even tries to turn SSH on.
- Cursor worked with the hosting provider to take the attacker's server offline, so the tunnel and the beacon no longer work.
- StepSecurity found no code that reads secret values, no second stage download, and nothing that touches Claude or editor data.
But I would not stop there. Microsoft points out the loader can still write the SSH key and the persistence files even when the tunnel fails, and those stay on disk after you uninstall or update the extension. Taking the server offline does not remove anything from your machine. And if the SSH step did succeed somewhere, for example on a Mac where SSH was already on, the attacker had interactive access for as long as the tunnel was up. The env var names are basically a map of which credentials were on that machine.
Am I affected?
You are only in scope if all of these are true:
- you use Cursor (not plain VS Code, not just the
claudeCLI), - on macOS or Windows,
- and you installed or auto-updated
anthropic.claude-codeto 2.1.312 or 2.1.313 during the October 29 window (about 16:27 WIB on October 29 to 03:35 WIB on October 30).
If you only use Claude Code from the terminal via npm, run claude --version if you like, but this incident does not touch you. The same goes for the extension in VS Code from Microsoft's marketplace.
If you do use Cursor, here is what I ran.
1. Look for the attacker key. Cursor's own check on macOS:
bash
grep -qs svc-telemetry ~/.ssh/authorized_keys && echo "svc-telemetry key found" || echo "No key found"On Windows, in PowerShell:
powershell
$files = "$HOME\.ssh\authorized_keys", "C:\ProgramData\ssh\administrators_authorized_keys" | Where-Object { Test-Path $_ }
if ($files -and (Select-String svc-telemetry $files)) { "svc-telemetry key found" } else { "No key found" }The loader only checks for the comment string before appending, and the original Phorion writeup suggests also matching on the key fingerprint rather than just the comment. On macOS or Linux:
bash
ssh-keygen -lf ~/.ssh/authorized_keys | grep '0Z6R+DF64Do2nwQic8a7kkfDLNNk4IiK+2U2Rci4htk'Any output there means the attacker key is present.
2. Look for the persistence files, which can exist even if the key check is clean:
bash
ls -la ~/.config/.smt ~/.config/.smtk ~/Library/LaunchAgents/com.apple.sysmond.plist 2>/dev/null
ls -la "$TMPDIR"/.stk_* 2>/dev/nullOn Windows, check for %USERPROFILE%\.config\smt.cmd, %USERPROFILE%\.config\smtk, %TEMP%\.stk_*, a scheduled task called SysMon (schtasks /query /tn SysMon), and sysmon.cmd in your Startup folder.
3. Look for running tunnel processes:
bash
ps aux | grep -E "ssh .*-R \*:0:localhost:22|autossh" | grep -v grep4. Check whether SSH was actually reachable. On a Mac, see if Remote Login is on with sudo systemsetup -getremotelogin. If it was on during the window, check your SSH logs too. Phorion notes that a login through the tunnel would look like it came from localhost and used the svc-telemetry key.
5. Check the installed extension itself. Cursor keeps extensions under ~/.cursor/extensions. Listing that folder shows which anthropic.claude-code-* version is installed. Cursor's notice says the malicious extension.js contains the string svc-telemetry, so this flags a tampered copy that is still on disk:
bash
ls ~/.cursor/extensions | grep anthropic.claude-code
grep -rl svc-telemetry ~/.cursor/extensions/anthropic.claude-code-* 2>/dev/nullThe full list of hashes and network indicators, including the attacker's address for searching firewall or EDR logs, is in Cursor's notice and Microsoft's writeup. I am not going to copy it here, so you get it from the source.
If you find something
Cursor's steps, in short:
- Isolate the machine.
- Remove the attacker key, the persistence (LaunchAgent, scheduled task, Startup script, cron line), the
.smt,.smtk, and.stk_*files, and kill any tunnel processes. Cursor publishes remediation scripts for macOS and Windows. Read them before you run them, and note the macOS one runs as your normal user, not root. - Update the extension to 2.1.314 or newer. Uninstalling alone is not enough, because the persistence lives outside the extension folder.
- Rotate the credentials that were reachable from that machine, from a different, clean machine. Start with whatever the env var names point to: cloud keys, API tokens, Git and npm tokens, database passwords. Then the SSH keys in
~/.sshand any long-lived sessions. The loader did not send secret values, but if the SSH step worked, someone could have read them over the tunnel. - Decide whether to rebuild the machine. If the key was added and SSH was already enabled, I would lean towards a rebuild.
Microsoft also suggests keeping a copy of the extension package, the changed authorized_keys, and the dropped files before cleaning up, in case you need to investigate later. On a work laptop, tell your security team before you delete anything.
What I am changing
This was not a bug in Claude Code. It was a distribution problem: an editor extension that most of us auto-update without a second thought. A few things I am doing now:
- Install cooldown in Cursor. Cursor has an
extensions.installCooldownHourssetting, and team admins can enforce a Marketplace Install Cooldown fleet-wide. It defers installs and updates until a version has been public for a set number of hours. The default is 0. This version was live for about eleven hours, so a 24 hour cooldown would have skipped it entirely. - Allowlist extensions on team machines with
extensions.allowed, or theAllowedExtensionsMDM policy if you manage laptops. - Keep the SSH server off on laptops unless you really need it. That is the main reason this backdoor failed on most machines.
- Fewer long-lived secrets in my shell environment. The loader went straight for env var names because that is where developers keep keys.
My take
The headline is accurate in the narrow sense that Claude Code 2.1.312 and 2.1.313 builds carrying a backdoor did reach real machines. It is wrong if it makes you think the claude CLI or Anthropic's own release pipeline was hijacked. Nothing I could check supports that, and the registries point the other way.
If you are on Cursor on a Mac or Windows machine and the extension auto-updated between Thursday afternoon and early Friday morning WIB, spend ten minutes on the checks above today. If you are not, there is nothing to uninstall. Just keep an eye on how Cursor explains the root cause, because that part is still missing.
Sources
- Cursor: Security notice on malicious Anthropic.claude-code 2.1.312 and 2.1.313 in the Cursor VS Code Extension Marketplace
- Microsoft Security Blog: Inside a malicious Claude Code-branded extension and its persistent SSH backdoor
- Hacker News discussion with statements from Anthropic engineers
- StepSecurity: Trojanized Claude Code extension delivered persistent SSH backdoor
- Socket: Cursor removes malicious Claude Code 2.1.313 extension from its marketplace
- Phorion: Official Claude Code VSX compromise
- npm: @anthropic-ai/claude-code
- GitHub releases: anthropics/claude-code
- Open VSX: Anthropic/claude-code
- Cursor Help: Extensions (install cooldown, allowlists, signature verification)
- Cursor Docs: Security and privacy hardening
Comments
No comments yet
Loading comments...