Learn / Securing AI coding assistants in an organisation
Lesson 5 of 610 minReviewed
Supply chain: malware that drives your agent, poisoned tools and instruction files
Learn from s1ngularity, Shai-Hulud, the Amazon Q extension compromise, package hallucination and hidden-Unicode rules files, and map each to a control you can deploy.
Coding assistants change the software supply chain in two directions. Malware that lands on a developer machine can now drive the AI agent that is already installed and authorised there, and the assistant itself, its extensions and the packages it suggests, become dependencies an attacker can target.
Malware that drives your AI CLI
On 26 August 2025, malicious versions of the nx build package and several plugins were published to npm. Their post-install script searched the file system, wrote a list of paths to /tmp/inventory.txt, uploaded the results to a new repository under the victim's own GitHub account with s1ngularity-repository in its name, and appended a shutdown command to .bashrc and .zshrc [1]. Wiz found that the malware called the locally installed Claude, Gemini and Q command-line tools with --dangerously-skip-permissions, --yolo and --trust-all-tools to do the file search, and counted over a thousand valid GitHub tokens among the leaked data [2].
The lesson is not that one tool was unsafe; it is that every bypass flag on every installed agent is now a capability available to any code that runs as the developer. Disable bypass modes in managed settings where the tool supports it, and alert on AI CLIs started non-interactively with bypass flags by a script interpreter.
In September 2025 the Shai-Hulud worm compromised more than 500 npm packages: it harvested GitHub tokens and AWS, Google Cloud and Azure keys, then used stolen npm credentials to publish infected versions of the victims' other packages. CISA's guidance was to rotate all developer credentials, pin dependencies to releases from before 16 September 2025 and require phishing-resistant MFA on developer accounts [3].
The assistant is a dependency too
In July 2025 AWS disclosed that version 1.84.0 of the Amazon Q Developer extension for VS Code shipped with malicious code, committed through an over-scoped GitHub token in a CodeBuild configuration. A syntax error stopped it from running; AWS pulled the version and told customers to move to 1.85.0 (CVE-2025-8217) [4]. Pin extension and CLI versions through your software management, and treat an advisory for an AI tool like any other dependency advisory.
Suggested packages carry their own risk. Across 576,000 generated code samples from 16 models, Spracklen and colleagues found that at least 5.2% of package references from commercial models and 21.7% from open-source models named packages that did not exist, 205,474 unique names in all [5]. An attacker who registers a frequently hallucinated name gets installed by anyone who accepts the suggestion. Route installs through a registry proxy, and block packages that are new or have no history.
Instruction files are code
Claude Code loads a repository's CLAUDE.md, or its AGENTS.md, as instructions in every session [6], and Cursor reads project rules from .cursor/rules [7]. Pillar Security showed in March 2025 that rules files for Cursor and GitHub Copilot could carry instructions hidden with invisible Unicode characters, steering generated code while looking harmless in review; GitHub later added a warning for hidden Unicode text on github.com [7].
- Require code-owner review for instruction, rules,
.mcp.jsonand agent settings files. - Scan those files and pull requests for invisible and bidirectional Unicode characters.
- Rotate tokens on any machine where a compromised package or extension version was installed.
Try it on ThreatDeck
- Detection: AI CLI scripted with a bypass flag Catch the s1ngularity pattern: a script interpreter launching an AI CLI non-interactively with prompts disabled.
- Hunt: s1ngularity host artifacts Use osquery to look for bypass runs in shell history and `/tmp/inventory.txt`.
- YARA: hidden Unicode instructions Scan rules files, prompts and agent configs for invisible tag characters.
- Agentic Supply Chain Vulnerabilities (ASI04) See related stories, tools and detections for agent supply chain risk.
Self-check
4 questionsPick an answer to see whether it is right and why. Only your score is saved, in this browser.
-
Wiz observed the malware calling installed Claude, Gemini and Q CLIs with bypass flags to do its reconnaissance, which turns every installed agent into a capability for any code running as the user.
-
AWS told customers to remove 1.84.0 and move to 1.85.0, including derivative copies. Dormant malicious code remains a risk and the installed base is your inventory problem.
-
The paper reports at least 21.7% for open-source models and 5.2% for commercial ones across 576,000 samples, which is why unvetted installs of suggested packages are a supply chain risk.
-
Zero-width and bidirectional characters can carry text the model reads but a human skims past. Scanning for them and requiring code-owner review of instruction files closes most of the gap.
References
- Malicious versions of Nx and some supporting plugins were published (GHSA-cxm3-wv7p-598c). Nx (nrwl) on GitHub, 2025-08.
- s1ngularity: supply chain attack leaks secrets on GitHub. Wiz, 2025-08-27.
- Widespread Supply Chain Compromise Impacting npm Ecosystem. CISA, 2025-09-23.
- Security Update for Amazon Q Developer Extension for Visual Studio Code (Version #1.84), AWS-2025-015. AWS, 2025-07-23.
- We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs. Spracklen et al. (arXiv:2406.10279), 2024-06.
- Explore the .claude directory. Anthropic (Claude Code docs).
- New Vulnerability in GitHub Copilot and Cursor: How Hackers Can Weaponize Code Agents. Pillar Security, 2025-03-18.