VSCode 擴充功能安全:Nx Console 事件後的 5 步審查
VSCode Extension Security: A 5-Step Audit After Nx Console
ExtensionBooster 提出 VSCode 擴充功能 5 步安全審查流程,回應 Nx Console 供應鏈攻擊造成 3,800 個程式碼儲存庫遭入侵的事件。
Originally published on ExtensionBooster.
VSCode extension security just got personal: GitHub confirmed that 3,800 repositories were breached through the Nx Console extension, which had 2.2 million installs and a verified publisher badge. If your editor has 30 to 50 extensions, this is the five-step audit to run today, plus what to rotate if you were exposed.
What happened
According to the write-up, this was not a zero-day in VSCode. It was a supply chain attack that climbed from npm up into a trusted extension.
- A threat group tracked as TeamPCP pushed a malicious version of
@tanstack/react-routerto npm. - Nx Console's dependency tree pulled it in during a routine extension update.
- The code ran silently in the extension host, which can read whatever your workspace touches.
The harvest went well beyond GitHub tokens:
- GitHub personal access tokens and OAuth credentials
- Claude Code config files
- 1Password CLI session tokens
- Kubernetes
~/.kube/configfiles - Any
.envfile found in the workspace
The real number of affected machines is likely higher, since not every stolen credential produces a visible repo change.
A verified badge is a floor, not a ceiling
Verified publisher status means the publisher proved domain ownership to Microsoft at the time of verification. It says nothing about their build pipeline, their npm vetting, or what a poisoned upstream package does to their extension later.
The chain is the problem: you audit the extension, the extension trusts a library, the library gets compromised. Your audit has to reach the dependencies too.
The 5-step audit
1. List what you have.
code --list-extensions > ~/vscode-extensions.txt
Every one of these runs in the same Node.js process with access to your workspace files.
2. Scan with vsix-audit. It is an open-source CLI that unpacks each .vsix and statically analyzes the bundled JavaScript.
npm install -g vsix-audit
vsix-audit nrwl.angular-console
while IFS= read -r ext; do vsix-audit "$ext"; done < ~/vscode-extensions.txt
It flags outbound calls to non-Microsoft domains, file reads outside the workspace, encoded strings matching known exfiltration patterns, and eval.
3. Get a second opinion. Paste an extension ID or Marketplace URL into vscan.dev for a browser-based scan. Handy before installing something unfamiliar, or when vsix-audit flags something.
4. Read the manifest.
cat ~/.vscode/extensions/publisher.name-*/package.json \
| jq '.contributes, .activationEvents, .main'
Treat activationEvents: ["*"] as a higher-risk profile: it activates on every workspace load, whatever the file type.
5. Prune. Attack surface grows with extension count. If you can't say from memory what an extension does, remove it:
code --uninstall-extension publisher.name
If you had Nx Console installed
Treat credentials as compromised if you updated it during the disclosure window, or if .env files were in an open workspace.
| Credential | Action |
|---|---|
| GitHub tokens | Revoke all personal access tokens; for the CLI run gh auth logout && gh auth login
|
| SSH keys | Rotate any key reachable from the workspace |
| Actions secrets | Delete and regenerate anything readable from a .env or workspace config |
| Claude API keys | Revoke and regenerate in the Anthropic dashboard |
| 1Password | Revoke CLI sessions in Settings > Developer > CLI |
| Kubernetes | Rotate service account tokens, regenerate ~/.kube/config
|
Cut exposure before the next incident
- Profiles: keep a minimal, vetted profile for work touching production credentials or private repos, and a full one for everything else.
- Update control: turning off auto-updates trades security patches for supply chain protection, so it suits extensions near credentials.
- Workspace Trust: make untrusted workspaces open in Restricted Mode.
-
Secrets scanning:
gitleaks detect --stagedcatches credentials before they reach a commit.
{
"extensions.autoUpdate": false,
"extensions.autoCheckUpdates": false,
"security.workspace.trust.enabled": true,
"security.workspace.trust.startupPrompt": "always"
}
If you publish extensions yourself, run npm audit before each release and check new dependencies with socket.dev.
Key takeaways
- A 2.2M-install extension with a verified badge was the vector for a 3,800-repo breach.
- The entry point was a poisoned npm package, not VSCode itself.
- Audit with
vsix-auditand vscan.dev, and inspectactivationEventsin each manifest. - Remove extensions you can't explain; fewer extensions means less attack surface.
- If exposed, rotate GitHub, SSH, Actions, Claude, 1Password and Kubernetes credentials.
The full walkthrough, including the FAQ, is in the VSCode extension security audit guide. If you build or ship extensions, ExtensionBooster has growth and review tools for Chrome extension and Android app developers.
How many extensions are installed in your editor right now, and when did you last remove one?
來源:DEV Community · dev.to