Definition

MITRE’s description of CWE-506: The product contains code that appears to be malicious in nature.

Common consequences MITRE lists

  • Confidentiality, Integrity, Availability: Execute Unauthorized Code or Commands

Why it matters

Malicious dependencies run with the trust of your build and your application, so they can steal secrets from CI, developer machines and production; typosquatted and hijacked packages make this a routine supply-chain threat.

How to prevent it

  • Pin dependencies with lockfiles and review new or changed packages before they enter the build.
  • Disable or sandbox package install scripts, and build in isolated environments without long-lived secrets.
  • Watch advisories for malicious packages, and prepare to remove them and rotate any credentials they could reach.

Guides on this site

Main subject · Guide

Investigate a suspected malicious package safely

Distinguish package substitution, publisher compromise and dangerous installation behavior while containing exposure and preserving evidence.

Main subject · Case study

Case study: the xz Utils backdoor (CVE-2024-3094)

How a multi-year maintainer takeover planted a backdoor in xz Utils release tarballs, how build-time injection hid it from the git repository, why a performance anomaly exposed it, which systems shipped it, and what it teaches about reproducible builds and maintainer health.

Main subject · Case study

Case study: the Shai-Hulud npm worm (2025-2026)

How a self-replicating npm worm turned stolen tokens into hundreds of infected packages in 2025, how its 2026 successors hijacked release pipelines and trusted publishing, what npm and GitHub changed in response, and the publishing, install and response practices that stop it.

Main subject · Case study

Case study: the tj-actions/changed-files compromise (CVE-2025-30066)

In March 2025 an attacker moved the version tags of a popular GitHub Action, and of a reviewdog action before it, to code that printed CI secrets into build logs. This case study traces the token chain back to one pull_request_target workflow, sizes the exposure, and shows how it was caught and which controls held.

Cites this weakness · Guide

Respond to an exploited or malicious dependency

When a dependency vulnerability is being exploited, or a package version is malicious, triage gives way to incident response: find every running copy, contain it, patch and redeploy, hunt for exploitation, rotate secrets and close on deployed evidence.

Cites this weakness · Case study

Case study: the SolarWinds Orion build compromise (SUNBURST)

How an implant on SolarWinds' build server inserted the SUNBURST backdoor into signed Orion updates in 2020, how it was found, why code signing and review could not catch it, and which build controls would have.

Cites this weakness · Case study

Case study: the Codecov Bash Uploader compromise (2021)

How a credential leaked through Codecov's Docker image process let an attacker change the Bash Uploader that many CI pipelines downloaded and ran, which sent their environment variables, and the secrets in them, to the attacker for two months in 2021.

Cites this weakness · Case study

Case study: the 3CX DesktopApp supply-chain attack (CVE-2023-29059)

How a trojanized trading application on one employee's personal computer led to 3CX's build servers and to signed, malicious 3CX DesktopApp releases in 2023: the first cascading software supply-chain compromise Mandiant had seen, how EDR caught it, and the controls that would have stopped it.

Cites this weakness · Case study

Case study: event-stream and ua-parser-js, two npm package takeovers

Two ways attackers took over popular npm packages: event-stream (2018), handed to a stranger who added a targeted, encrypted payload through a new dependency, and ua-parser-js (2021), whose maintainer's account was hijacked to publish versions that installed malware for four hours. Timelines, detection and the controls that stop both.

Cites this weakness · Guide

Secure the developer workstation: extensions, package managers, secrets and AI agents

Attackers reach the software supply chain through developers' editors, package installs and AI agents. Allow-list extensions, stop install scripts and brand-new versions, keep long-lived secrets off laptops, and lock down repository files that run code when a project opens.

Cites this weakness · Case study

Case study: the Nx s1ngularity compromise and its AI-assisted payload (2025)

How a pull-request-title injection in a GitHub Actions workflow on an outdated branch gave an attacker the Nx npm token in August 2025, how the malicious versions tried to turn developers' own AI command-line tools into file-search agents, and the workflow, publishing and agent controls that stop the same chain.

Cites this weakness · Case study

Case study: the Amazon Q Developer extension compromise (2025)

How an over-scoped GitHub token, extracted from an AWS CodeBuild pull request build, let a threat actor commit code to the Amazon Q Developer extension for VS Code that shipped in version 1.84.0 in July 2025, why the injected code aimed at the Q Developer CLI failed, and the CI and AI-agent controls the incident argues for.

References

  1. CWE-506 in the MITRE CWE list (version 4.20)

List data from MITRE; the name, definition and consequences are from MITRE’s CWE 4.20 catalogue. A guide is listed as the main subject when the weakness is what the guide is about, and as covering it when a dedicated section or worked example addresses it.

CWE content: Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. CWE Terms of Use.