A developer laptop holds the keys to the software supply chain, and most organisations protect it no better than a sales laptop. The same machine that runs untrusted extensions, clones unfamiliar repositories and executes package install scripts also holds npm and PyPI publishing tokens, cloud CLI sessions, SSH keys and personal access tokens with write access to production repositories. This guide covers the three controls that matter most on that machine: governing IDE extensions, isolating untrusted code with Workspace Trust and dev containers, and removing long-lived secrets from the local disk. It is written for platform, endpoint and application security teams who manage developer fleets, and it uses VS Code and compatible editors as the worked example because their controls are the best documented. AI coding agents are covered separately in the AI IDE and Coding Agent Security Guide.
Key takeaways
- Extensions run with your privileges. The VS Code extension host has the same permissions as the editor itself: it can read and write files, open network connections and start processes, so an extension is code execution, not a plug-in setting.
- Allowlist centrally, not by guidance. The
AllowedExtensionspolicy (backed by theextensions.allowedsetting since VS Code 1.96) blocks and disables anything not explicitly allowed and overrides what users set. - Opening a repository can run code. Tasks, debug configurations, workspace settings, dev container lifecycle commands and package install scripts all execute on open or on first build; Workspace Trust and
ignore-scriptsare the brakes. - Dev containers isolate the project, not the developer.
initializeCommandruns on the host, Git credentials are shared into the container, andprivilegedor a mounted Docker socket removes most of the boundary. - The real prize is the token. Workstation malware such as GlassWorm targets npm, GitHub and extension marketplace tokens; short-lived, hardware-bound and federated credentials limit what a compromise yields.
Why the developer workstation is a supply chain entry point
Attackers who compromise a developer machine rarely want the laptop. They want what it can publish or push. MITRE ATT&CK tracks this under T1195.001 Compromise Software Dependencies and Development Tools, and has a dedicated sub-technique, T1176.002 IDE Extensions, for persistence through editor add-ons. The incident pattern repeats: a malicious or hijacked extension or package runs on the workstation, harvests tokens from files and credential stores (T1552.001 Credentials In Files, T1555 Credentials from Password Stores), and uses them to publish more malicious versions, which is how a single infection becomes a worm.
The GlassWorm campaign showed every step. Extensions on Open VSX and the Visual Studio Code Marketplace hid code in invisible Unicode characters, stole npm, GitHub, Git and Open VSX credentials, and added remote access to developer machines. Separately, researchers found more than 550 validated secrets inside published VS Code extensions, including over 100 Marketplace personal access tokens that could push updates to existing installs, as covered in the secrets in VS Code extensions breach page. The defensive lesson: treat developer endpoints as high-value assets, closer to a privileged access workstation than to general office endpoints.
| Entry point | What executes | When | Primary control |
|---|---|---|---|
| IDE extension install or auto-update | Extension code in the extension host with user privileges | On activation, often at editor start | AllowedExtensions policy, private marketplace |
Repository .vscode/tasks.json, launch.json, workspace settings | Shell commands and tool paths chosen by the repository author | When tasks or debug sessions run | Workspace Trust (Restricted Mode) |
devcontainer.json and image labels | initializeCommand on the host, lifecycle commands and Feature install.sh in the container | On "Reopen in Container" or rebuild | Trust prompt, reviewed and pinned images and Features |
| Package manager install scripts | preinstall, install, postinstall lifecycle scripts | On npm install and similar | ignore-scripts, release age delay, lockfiles |
| Dotfiles repository | The dotfiles install script | Every container creation | Owned, reviewed dotfiles repository |
| Local secrets on disk | Nothing: the stealer just reads them | Whenever any of the above runs | Short-lived and hardware-bound credentials |
Governing IDE extensions
Marketplace defences are real but partial. Microsoft documents that the Visual Studio Code Marketplace scans each new extension and update with several antivirus engines, runs extensions in a sandboxed clean room VM to check behaviour, blocks name squatting of official publishers and popular extensions, signs extensions at publish time and verifies the signature at install, scans new extensions for secrets, and removes extensions verified as malicious, with VS Code then uninstalling them automatically. Since VS Code 1.97 users are also asked to confirm trust in a third-party publisher on first install. None of this stops a legitimate publisher's account being hijacked, and compatible editors that use Open VSX or other registries get a different set of checks.
The allowlist
The enforceable control is the extensions.allowed setting, deployed as the AllowedExtensions policy through Group Policy, Intune, a macOS configuration profile or another device management tool. Facts from the VS Code enterprise documentation:
- Keys: a key with no period is a publisher ID (
"github": true); a key with a period is a full extension ID ("esbenp.prettier-vscode": true)."*"is the only wildcard. - Versions: an array pins exact versions (
["3.0.0"]), with optional platform suffix such as5.0.0@win32-x64. Ranges are not supported. The value"stable"allows releases and blocks pre-releases. - Precedence: the more specific rule wins, so
"microsoft": truewith"microsoft.cplusplus": falseallows every Microsoft extension except that one. - Effect: anything not matched is blocked, and an installed extension that becomes blocked is disabled.
- Enforcement: the policy overrides the user setting on managed devices. A syntax error means the allowlist is not applied at all, so check the Window log after every policy change.
Choosing an allowlist model
| Model | How it works | Strength | Weakness | Fits |
|---|---|---|---|---|
| Publisher allowlist | Allow whole publishers (your own, the editor vendor, a short list of trusted ones) | Low maintenance | A hijacked publisher account ships straight through | Small teams starting out |
| Extension ID allowlist | Allow named extensions, any version | Blocks lookalikes and new unknown extensions | Malicious updates to an allowed extension still install | Most organisations as a baseline |
| Version-pinned allowlist | Allow named extensions at exact versions | Malicious updates blocked until reviewed | High review load; every update is a change request | Regulated or high-value build teams |
| Private marketplace | Self-hosted marketplace upstreaming approved public extensions (GitHub Enterprise customers) | Central curation, works for air-gapped estates | Not supported from VS Code Server or VS Code for the Web; operating cost | Large enterprises, isolated networks |
For forks and compatible editors, confirm which registry they use and whether they honour the same policy before you claim coverage. The GlassWorm VS Code Extension Worm Guide covers the campaign-specific indicators; the same governance logic for browsers is in the Browser Extension Security Guide.
Workspace Trust: stopping a repository from running code on open
A cloned repository can carry .vscode/tasks.json, launch configurations and workspace settings that point tools at attacker-chosen binaries. Workspace Trust opens unfamiliar folders in Restricted Mode, in which, per the VS Code documentation, AI agents are disabled, the integrated terminal is blocked until trust is granted, running or even listing tasks prompts for trust, starting a debug session prompts for trust, settings tagged requireTrustedWorkspace are not applied, and extensions that have not declared Workspace Trust support are disabled or limited.
| Setting | Default | Recommended managed value | Why |
|---|---|---|---|
security.workspace.trust.enabled | true | true, enforced | Turning it off removes Restricted Mode entirely |
security.workspace.trust.untrustedFiles | prompt | newWindow for high-risk teams | Files from outside trusted folders open in a Restricted Mode window |
security.workspace.trust.emptyWindow | true | false where practical | Empty windows otherwise start trusted |
security.workspace.trust.startupPrompt | never | once | Makes the trust decision visible on first open |
terminal.integrated.allowInUntrustedWorkspace | not set | Leave unset | Only safe if the shell itself blocks automatic code execution |
extensions.supportUntrustedWorkspaces | not set | Do not override vendor restrictions | Authors restrict extensions for reasons |
The common weakness is trusting a parent folder. Trust on ~/src or C:\code is inherited by every subfolder, so every repository cloned there later is trusted silently. Keep a trusted path for your organisation's own repositories and a separate, untrusted path for third-party code, reviews and proof-of-concept clones. The --disable-workspace-trust command-line switch disables the feature for a session, so watch for it in shortcuts and wrapper scripts.
Dev containers: useful isolation with sharp edges
Dev containers move the toolchain and the project's dependencies into a container, which keeps install scripts and build tools off the host filesystem. The Dev Container specification and VS Code documentation show where the boundary leaks:
- Host execution:
initializeCommandruns on the host machine, wherever the source code sits, before the container exists. Review it like any script in the repository. - Inherited configuration: image labels can carry dev container metadata, including
remoteUserandpostCreateCommand, and are picked up when an image is referenced through aFROMline or Compose file. A base image you did not write can change what runs. - Features: each Dev Container Feature is installation code with its own
install.sh. Pin Features by version and source them from a registry you control. - Privilege flags:
privileged,capAdd,securityOpt,mountsandrunArgscan grant the container host-level access. A mount of the Docker socket or the user's home directory, or--privileged, means container compromise is host compromise. - Credentials: if the repository was cloned with a Git credential manager, the container already has access to those credentials, and SSH keys can be shared in through the agent. Malicious code in the container can use them.
- Dotfiles:
dotfiles.repositoryanddotfiles.installCommandclone a repository and run its install script on every container creation. - Ports:
forwardPortsexposes ports on localhost only;appPortand Composeportspublish them on the host network. - Remote daemons: using a remote Docker daemon means trusting that host, with no extra prompt.
VS Code asks for Workspace Trust when reopening a folder in a container, attaching to a container or cloning into a volume, which is the moment to read devcontainer.json. Container base image hygiene is covered in the Container Image Security Guide.
Package managers on the workstation
Most package worms execute through install-time lifecycle scripts. npm offers controls that belong in a managed user or global .npmrc:
ignore-scripts=true: npm does not run scripts frompackage.jsonfiles during install. Explicit commands such asnpm teststill run their named script but skip pre and post scripts. Expect some packages with native builds to need a documented exception.min-release-age: installs only versions published at least the given number of days ago (thebeforedate option takes precedence if both are set). A short delay means most malicious versions are found and removed before they reach your machines.allow-git=rootornone: limits dependencies that point at Git references, which bypass registry controls.strict-ssl=true: the default; make sure no proxy workaround has disabled it.
Commit lockfiles and use npm ci so a workstation build reproduces the reviewed tree. The full set of npm options, and equivalents for other ecosystems, is in the npm Install-Time Security Guide.
Where identity fits: local secrets and developer tokens
Everything above reduces the chance that hostile code runs. This section reduces what it can steal. Credential stealers sweep the same places on every machine: ~/.npmrc, ~/.pypirc, ~/.aws/credentials, ~/.config/gcloud, ~/.kube/config, ~/.docker/config.json, ~/.ssh, .env files in project folders, shell history and the extension secret storage of the editor. Each of these is a non-human identity credential acting with the developer's authority.
| Credential | Typical weak state | Stronger state |
|---|---|---|
| GitHub access | Classic PAT with repo scope, no expiry, in a dotfile | GitHub CLI or Git Credential Manager sign-in; fine-grained PAT scoped to one owner and selected repositories, with expiry and organisation approval |
| SSH key for Git | Unencrypted id_rsa on disk | Hardware-backed ed25519-sk key (or ecdsa-sk) needing a physical touch |
| Package publishing | Long-lived npm or PyPI token in .npmrc or .pypirc | No publishing token on laptops at all: publish from CI with trusted publishing (OIDC) |
| Cloud CLI | Static access keys in a credentials file | SSO sessions with short lifetimes; role assumption per task |
| Application secrets for local runs | Production values in .env | Development-only values, fetched at run time from a secrets manager |
| Extension marketplace PAT | Broad Azure DevOps PAT on the publisher's laptop | Publish from CI, narrow scope, short expiry, rotated after any incident |
GitHub's own documentation recommends fine-grained tokens over classic tokens, notes that classic tokens can reach every repository the user can access, and removes tokens unused for a year. The PAT is still a bearer secret: if it sits in a file, assume a stealer will find it. Publishing tokens deserve special attention because they turn a single infection into a worm; see the npm Trusted Publishing and Provenance Guide and the PyPI API Tokens and Trusted Publishing Security Guide. Scan local repositories and dotfiles with the approaches in the Git Secret Scanning Guide.
Rolling out a developer workstation baseline
- Inventory first: collect installed extensions (from the extensions folder or
code --list-extensions --show-versionsrun by your management agent), editors and forks, container runtimes and credential files present. You cannot write an allowlist without this. - Classify developers: separate maintainers who can publish packages or merge to protected branches from everyone else. They get the strict tier first.
- Remove publishing tokens from laptops: move package and extension publishing to CI with trusted publishing, then revoke the old tokens. This is the highest risk reduction per hour spent.
- Pilot the allowlist in report mode: build the list from inventory, deploy it to a pilot ring of 20 to 50 developers, and collect blocked-extension requests for two weeks. Add a fast request path (same day) or developers will find workarounds.
- Enforce Workspace Trust settings and
.npmrcdefaults through device management, with a split between trusted and untrusted clone paths. - Standardise dev container images and Features in an internal registry, forbid
privilegedand Docker socket mounts by policy, and lintdevcontainer.jsonin code review. - Expand in rings once the request queue settles. Rollback is a policy change: revert the
AllowedExtensionsvalue (remember that a malformed value silently disables the list, which is a failure mode, not a rollback method).
For small teams, steps 3 and 5 plus an extension ID allowlist give most of the value. Large organisations should add version pinning or a private marketplace for publishing maintainers and build engineers, and treat their machines under the Privileged Access Workstations Guide model.
Detection and measurement
- Process lineage: alert when the editor, its extension host or
nodespawned by a package manager launches shells,curl, archive tools or network utilities that are unusual for that user. EDR rules on parent processCode.exeorcodehelper processes are a good starting point. - Credential file access: monitor reads of
.npmrc,.aws/credentials,.sshand browser credential stores by processes other than their normal clients. - Extension changes: log installs and updates of extensions, especially outside the allowlist or from compatible-editor registries.
- Token use from new places: registry and GitHub audit logs showing a developer token used from an unfamiliar IP or ASN, or a publish event outside CI.
| Metric | Target |
|---|---|
Managed developer devices with AllowedExtensions enforced | Above 95% |
| Long-lived publishing tokens present on workstations | Zero |
| Classic GitHub PATs with no expiry in the organisation | Trending to zero |
| Median time to approve an extension request | Under one working day |
Dev container definitions using privileged or a Docker socket mount | Zero without a recorded exception |
Common failure patterns
- Trusting the whole source folder: one click on a parent folder makes every future clone trusted, so Restricted Mode never appears.
- Publisher-only allowlists: a hijacked publisher account, or an allowed extension whose update turns malicious, passes straight through. The GlassWorm "sleeper" extensions that turned malicious after later updates are the case for version pinning on high-value machines.
- Policy that never applied: a syntax error in the
AllowedExtensionsvalue disables the allowlist with nothing visible to the user. - Publishing from laptops: long-lived npm and marketplace tokens on maintainer machines are what let stealers republish packages, the mechanism in the Shai-Hulud npm worm.
- Treating dev containers as a sandbox: a mounted Docker socket,
--privilegedand shared Git credentials mean malicious code in the container reaches the host and the repositories. - Secrets inside packaged artefacts:
.envand configuration files bundled into published extensions exposed hundreds of live tokens; removing them from a later version does not revoke them.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-218 (SSDF 1.1) | PO.5 Implement and Maintain Secure Environments | Separating and hardening development environments and endpoints |
| NIST SP 800-53 Rev. 5 | CM-7(5) Authorized Software, Allow-by-exception; CM-11 User-installed Software | Extension allowlisting |
| NIST SP 800-53 Rev. 5 | IA-5 Authenticator Management; AC-6 Least Privilege; SA-15 Development Process, Standards, and Tools | Token lifetime and scope, tooling standards |
| NIST CSF 2.0 | ID.AM-02, PR.PS-02, PR.AA-05, DE.CM-09 | Software inventory, maintenance, least privilege, endpoint monitoring |
| MITRE ATT&CK v20 | T1195.001, T1176.002, T1552.001, T1555, T1528 | Development tool compromise, IDE extension persistence, credential theft |
Practitioner checklist
- Inventory extensions, editors and forks, and credential files across the developer fleet.
- Deploy the
AllowedExtensionspolicy, pilot it, and verify in the Window log that it applied. - Pin versions or use a private marketplace for maintainers and build engineers.
- Enforce Workspace Trust and keep separate trusted and untrusted clone paths.
- Set
ignore-scripts,min-release-ageandallow-gitin a managed.npmrc, with a documented exception path. - Ban
privileged, Docker socket and home directory mounts indevcontainer.jsonwithout an exception. - Move all package and extension publishing to CI with trusted publishing, then revoke laptop tokens.
- Replace classic PATs and unencrypted SSH keys with credential manager sign-in, fine-grained expiring tokens and hardware-backed SSH keys.
- Alert on editor and package manager process chains that touch credential files or open unusual network connections.
- Rehearse the response: which tokens to revoke, in which order, when a developer machine is suspected.
Standards and references
- Microsoft: VS Code Enterprise Extension Management
- Microsoft: VS Code Extension Runtime Security
- Microsoft: VS Code Workspace Trust
- Development Containers: devcontainer.json Reference
- npm: Config Documentation
- GitHub Docs: Managing Your Personal Access Tokens
- NIST: SP 800-218 Secure Software Development Framework 1.1
- MITRE ATT&CK: IDE Extensions (T1176.002)
Related NHI Mgmt Group resources: AI IDE and Coding Agent Security Guide · GlassWorm VS Code Extension Worm Guide · npm Install-Time Security Guide · Malicious Package Worm Response Playbook