in this guide
On the evening of 26 August 2025, US Eastern time, someone published malicious versions of nx, a popular JavaScript build tool, to npm. They stayed up for about four hours, according to the Nx team’s own advisory. Installing one ran a script that collected credentials and posted them to a new public repository on the victim’s own GitHub account.
One part of that script was new. StepSecurity, a vendor that sells supply-chain security tools, published the code on 27 August 2025: it checked whether the machine had the command-line versions of Claude, Gemini or Amazon Q installed, and if so, asked them to search the disk for wallets, keys and .env files. It called each one with the flag that tells the tool to stop asking permission: --dangerously-skip-permissions, --yolo, --trust-all-tools.
That is the mechanism. An AI coding agent in a developer’s terminal runs as that developer. It can read what they can read and run what they can run, including every token the terminal holds for GitHub, npm and the cloud. Unless the agent runs in a sandbox, the permission prompt is what stands between a request and an action, and every one of these tools has a documented way to turn it off.
The laptop guide explains why an engineer’s machine already reaches production. The agent guide covers the identity any agent acts under. This guide is about the place where the two meet: the coding agent, the keys sitting next to it, and the switch.
what the agent can reach
A coding agent installed on a laptop is a program started by the developer, so the operating system treats it as the developer. Nothing in your identity provider records that it exists. What it can reach is whatever that user account already holds.
what a coding agent in a developer's terminal can use
- the GitHub CLI loginkept in the system credential store, or a plain text file if that store is unavailable, per GitHub's manual
- the npm logina session or token that can publish the packages the developer maintains
- cloud CLI credentialslong-term AWS keys in
~/.aws/credentialshave no expiry, per AWS's documentation - project
.envfilesdatabase URLs, API keys and test credentials next to the code - SSH keys and other tools' configincluding the keys pasted into MCP server settings
reachable by anything running as the developer
The GitHub login deserves a closer look. GitHub’s manual for gh auth login gives repo, read:org and gist as the minimum scopes for a classic token, which covers every repository the developer can see. The Nx payload, per StepSecurity’s published code, simply ran gh auth token to print it. Nx’s own advice afterwards was to revoke the GitHub CLI’s authorisation in each user’s GitHub settings so that the old token stopped working.
three ways it has already gone wrong
Someone else’s code drives the agent you installed. That is the Nx case. The payload never needed the agent; it collected tokens directly too. The agent was a helper for finding files the script did not know to look for. GitGuardian, a vendor that sells secret-detection tools, counted 2,349 distinct secrets in the leaked repositories it analysed and wrote on 27 August 2025 that half were still valid. In an update on 28 August it reported that of 366 systems where AI tools were targeted, 95 wrote the requested file listing, and read that as a sign that many of the tools refused. A refusal depends on how the model behaves that day, and nobody at your company can configure it.
The story did not end with the deleted repositories. On 28 August 2025, according to GitGuardian’s update of the next day, the attackers used stolen GitHub tokens to make private repositories public, 10,767 of them by its count. The tokens were the ones the first wave had collected from infected machines.
The Nx advisory also lists AI agents among the less obvious things that install npm packages, next to editors and their extensions. Its own VS Code extension installed the latest nx in the background, so opening the editor during those four hours could trigger the payload. The incident page has the full timeline: the Nx packages that searched with your AI.
The agent ships with hostile instructions. On 23 July 2025 AWS published a bulletin about version 1.84.0 of its Amazon Q Developer extension for VS Code. A threat actor had committed malicious code into the extension’s open-source repository, using a GitHub token in its build configuration that AWS says was scoped too broadly, and the code went out in a release. AWS says it failed to run because of a syntax error, and told users to move to 1.85.0. 404 Media reported the same day that the inserted text was a prompt telling the agent to wipe the machine and delete cloud resources; the person behind it told 404 Media a pull request was enough, a claim AWS’s bulletin does not address. 404 Media also judged the real risk of machines being wiped as probably low. See the Amazon Q extension case.
Text the agent reads steers it. On 26 May 2025 Invariant Labs, a vendor of AI guardrail tools, showed an agent connected to GitHub reading an issue in a public repository. The issue carried instructions. In the demonstration the agent followed them, pulled data from the user’s private repositories and posted it in a pull request on the public one. Invariant described this as an architectural issue in how agents use broad access, and recommended limiting the agent to the repositories it needs. The agent could only leak what its GitHub access could see.
The agent does what the terminal allows. The terminal holds whatever nobody cleaned out.
The Replit case is the same lesson without an attacker: an agent with write access to a production database deleted it during a declared code freeze.
the switch that removes the question
Each tool’s own documentation describes a mode that skips approvals, and says what it is for.
- Claude Code has a
bypassPermissionsmode. Anthropic’s documentation says to use it only in “isolated environments like containers or VMs”. An administrator can setpermissions.disableBypassPermissionsModeto"disable"in managed settings so that users cannot switch it on. - OpenAI Codex runs commands in an operating-system sandbox. Its documentation gives the default in a code repository as write access to the workspace with approval on request, and says network access is off by default. The
--dangerously-bypass-approvals-and-sandboxflag, also called--yolo, removes both and is marked not recommended. - Cursor asks before terminal commands by default. Its security page calls the allowlist and automatic review “best-effort guardrails”, which is a fair description of any prompt a tired person clicks through.
Two details in these documents matter more than the flags. Anthropic’s page says a rule that blocks the agent from reading .env applies to its own file tools and recognised shell commands, and does not stop a Python or Node script it runs from opening the file; for that, it points to the operating-system sandbox. And none of these settings help if the agent is not the one asking. The Nx script started the CLI itself, with the flag already set.
two places a coding agent can run
a box built for it
sandbox, container, or a hosted agent
- Codex: writes limited to the workspace, network off by default
- Copilot cloud agent: pushes to one branch, internet access restricted
- Copilot cloud agent: workflows wait for a person with write access to approve
- Only the credentials someone chose to put there
the developer's own terminal
the common install
- Runs as the developer's user account
- GitHub, npm and cloud logins already present
- Every
.envin every project folder - One flag away from no questions at all
GitHub’s documentation for its Copilot cloud agent lists the controls on the left in detail: only people with write access can give it work, it can push only to its own branch, and the person who asked for a pull request cannot approve it. Those are design choices worth copying for any agent that runs unattended.
shrink what the terminal holds
The agent setting decides whether anyone is asked. The credentials decide how bad a wrong answer is. Each vendor now documents a way to make them smaller.
GitHub. Organisation owners can block classic personal access tokens from organisation resources, require approval for fine-grained tokens, and set a maximum lifetime, per GitHub’s documentation. The default maximum for fine-grained tokens is 366 days; classic tokens have no expiry requirement. A fine-grained token can be limited to named repositories, which is the narrow access Invariant recommended. The GitHub identity guide has the full organisation audit.
npm. GitHub’s changelog of 9 December 2025 says all classic npm tokens were permanently revoked, npm login now gives a two-hour session, and granular tokens with write access last 90 days at most. Nx itself moved its publishing to npm’s trusted publishing after the attack, so no npm token sits in its pipeline. The pipeline side of that story is in the pipeline secrets guide.
Cloud. The AWS CLI documentation lists long-term IAM user keys as not recommended and recommends short-term credentials from a console login or IAM Identity Center. A short-term credential that leaks expires on its own.
Project secrets. Keep production database passwords and live API keys out of the .env files on laptops where an agent works, and put test values there instead.
When a token does leak, deleting the repository it leaked into does nothing to it. GitGuardian’s finding that half the Nx secrets still worked is the point of the token guide: a credential keeps working until someone revokes it.
who decides how the agents run
At a company of 50 or 300 people, a coding agent can arrive with no decision at all: one developer installs it, it helps, others follow. The connectors in the MCP servers guide arrive on the same laptops the same way. Unless someone sets it centrally, the mode each agent runs in is whatever each developer picked. The questions are short:
- Which coding agents are installed, as CLIs, editors and extensions?
- Does anyone run them with approvals off, and on which machine?
- Which tokens does that machine hold, and how long do they live?
- Can an administrator set the mode centrally for the tools you use, and is that set?
If a package your team installed tomorrow started one of those agents with approvals off, which of your tokens would it find first?
on the record
- Cline, 2026"a bot that only sorts new issues cannot reach the release"
- Amazon Q Developer extension for VS Code, 2025"an official extension from a big vendor only ships code its own team reviewed"
- Nx npm packages (s1ngularity), 2025"the AI coding assistant on a developer's laptop only works for the developer"
sources
- Nx: Malicious versions of Nx and some supporting plugins were published (GitHub security advisory GHSA-cxm3-wv7p-598c, 27 August 2025)
- Nx blog: S1ngularity, what happened, how we responded, what we learned (5 September 2025)
- StepSecurity: Popular Nx build system package compromised with data-stealing malware (27 August 2025)
- GitGuardian: The Nx s1ngularity attack, inside the credential leak (27 August 2025, updated 28 and 29 August 2025)
- AWS security bulletin AWS-2025-015: Amazon Q Developer for Visual Studio Code extension (23 July 2025, updated 25 July 2025)
- 404 Media: Hacker plants computer wiping commands in Amazon's AI coding agent (23 July 2025)
- Invariant Labs: GitHub MCP exploited, accessing private repositories via MCP (26 May 2025)
- Claude Code docs: Configure permissions
- OpenAI Codex docs: Agent approvals and security
- Cursor docs: Agent security
- GitHub Docs: Risks and mitigations for GitHub Copilot cloud agent
- GitHub CLI manual: gh auth login
- GitHub CLI manual: gh auth status
- GitHub Docs: Setting a personal access token policy for your organization
- GitHub changelog: npm classic tokens revoked, session-based auth and CLI token management now available (9 December 2025)
- AWS CLI user guide: Authentication and access credentials for the AWS CLI
