When a Package Install Becomes an Attack: Critical pnpm RCE in CI/CD Pipelines

Vulnerability Summary

  • CVE Name: pnpm Command Injection via environment variable substitution
  • CVE ID: CVE-2025-69262
  • Vulnerability Type: Command Injection
  • CVSS Score: High (CI/CD Remote Code Execution)
  • Severity: High
  • Attack Complexity: Moderate
  • Privileges Required: None (in many CI scenarios)
  • User Interaction: None
  • Affected Scope: CI/CD pipelines, automated build systems
  • Impact: Remote Code Execution, credential exposure, supply-chain compromise

Executive Summary

A high-severity command injection vulnerability was identified in pnpm, a widely used JavaScript package manager. The flaw allows arbitrary command execution when pnpm is executed in environments that rely on environment variable substitution together with certain .npmrc configurations.

This vulnerability is especially dangerous in CI/CD pipelines, where pnpm commonly runs with access to sensitive assets such as source code, repository tokens, cloud credentials, and deployment keys. If an attacker can influence environment variables consumed by pnpm — which is often possible in shared runners, pull-request workflows, or misconfigured pipelines — they may execute arbitrary commands on the build agent.

In practical terms, this means a successful exploit can lead to:

  • Full compromise of CI runners
  • Theft of secrets and credentials
  • Tampering with build artifacts
  • Supply-chain attacks through poisoned packages or deployments

Because exploitation does not require complex tooling and leaves minimal traces unless logging is explicitly enabled, this issue should be treated as urgent.


Vulnerability Overview

  • CVE ID: CVE-2025-69262
  • Vulnerability Type: Command Injection
  • Root Cause Category: Improper input handling of environment variables
  • Execution Context: Non-interactive (automated builds)
  • Primary Risk Area: CI/CD pipelines

Affected Versions

  • Affected: pnpm versions 6.25.0 through 10.26.2
  • Fixed In: pnpm 10.27.0 and later

Not Affected

  • Systems not using pnpm
  • Environments where pnpm is not used in CI/CD automation
  • Setups that do not rely on environment variable substitution or helper-based token resolution

Root Cause Analysis

pnpm supports advanced configuration options via .npmrc, including helper-based token resolution and environment variable substitution. These features are designed to improve automation but introduce risk when inputs are not tightly controlled.

The vulnerability arises because:

  • Environment variables are treated as trusted input
  • Certain pnpm execution paths allow these variables to be interpolated into command execution contexts
  • Insufficient validation or sanitization allows shell metacharacters to be interpreted

As a result, maliciously crafted environment variable values can escape their intended context and trigger command execution instead of being handled as simple strings.

This is a classic command injection scenario caused by unsafe handling of externally influenced configuration data.


Exploitation Scenario

A typical vulnerable workflow looks like this:

  1. A CI/CD pipeline runs pnpm as part of a build or test job
  2. The pipeline injects environment variables derived from:
    • Pull request metadata
    • Pipeline parameters
    • External configuration sources
  3. pnpm processes .npmrc and expands environment variables
  4. A malicious value contains shell metacharacters
  5. pnpm unintentionally executes attacker-controlled commands

The attacker’s commands run with the privileges of the CI runner, which often includes access to secrets and publishing rights.


What an Attacker Can Do

If exploitation succeeds, an attacker may:

  • Execute arbitrary commands on the CI runner
  • Read or export environment secrets
  • Modify or backdoor build artifacts
  • Publish malicious packages
  • Trigger unauthorized deployments
  • Establish persistence in shared runners

Because CI systems are often trusted components of the software delivery lifecycle, compromise here has far-reaching consequences.


Proof of Concept

Publicly available descriptions demonstrate that exploitation does not require custom exploit tooling. Manipulating environment variable values to include shell control characters is sufficient to trigger execution in vulnerable setups.

No complex payload is required — only control over environment input and a vulnerable pnpm version.


Exploit Availability

  • Exploitation techniques are well understood
  • Conceptual demonstrations are publicly documented
  • Attackers do not need deep pnpm internals knowledge
  • CI environments significantly lower the barrier to exploitation

For defenders, this means assume exploitability if conditions are met.


Detection & Monitoring Guidance

High-Risk Indicators

Watch for:

  • Unexpected shell execution during pnpm runs
  • CI job logs showing commands that were not defined in pipeline configuration
  • Environment variables containing shell metacharacters
  • Outbound network traffic from build agents during pnpm execution
  • Artifacts published outside normal release processes

Recommended Log Sources

Enable and monitor the following:

CI/CD Platform Logs

  • Job execution logs
  • Environment variable injection records
  • Step-level command output

Build Agent / Runner Logs

  • Process creation events
  • Child process spawning
  • File system activity

Network Logs

  • Outbound connections from build containers
  • DNS requests from CI runners

Detection Patterns

Suspicious Input Indicators

  • ;
  • &&
  • |
  • `
  • $()
  • Encoded variants (%3B, %26%26)

Behavioral Indicators

  • pnpm spawning shell processes
  • pnpm execution followed by network calls
  • Build steps behaving differently than defined in pipeline config

Rule Logic & Detection Engineering

1. CI Input Rule (Attempt Detection)

IF job.environment_variables CONTAIN (";", "&&", "|", "`", "$(")
AND job.steps CONTAIN "pnpm"
THEN alert "Potential pnpm Command Injection Attempt"

2. Process Behavior Rule (High Confidence)

IF parent_process IN ("pnpm", "node")
AND spawned_process IN ("sh", "bash", "powershell")
THEN alert "Unexpected Shell Spawn from pnpm"

3. Network Egress Rule

IF process IN ("pnpm", "node")
AND outbound_connection NOT IN approved_domains
AND connection_time DURING pnpm_execution
THEN alert "Suspicious Network Activity from CI Runner"

4. Correlation Rule (Critical)

IF suspicious_env_input
FOLLOWED BY shell_spawn OR external_network_call
WITHIN 60 seconds
THEN escalate to Incident Response

MITRE ATT&CK Mapping

  • T1059 – Command and Scripting Interpreter
  • T1083 – File and Directory Discovery
  • T1005 – Data from Local System
  • T1041 – Exfiltration Over Application Layer

Business Impact

Successful exploitation can result in:

  • CI/CD pipeline takeover
  • Credential and secret leakage
  • Supply-chain compromise
  • Unauthorized code or package distribution
  • Regulatory and compliance violations

Remediation & Mitigation

Immediate Action

Upgrade pnpm to version 10.27.0 or later across all CI runners, build containers, and developer automation systems.

Short-Term Mitigations (If Upgrade Is Delayed)

  • Avoid dynamic environment variable expansion in pnpm configs
  • Remove helper-based token resolution from .npmrc
  • Sanitize all CI inputs before injecting them into environment variables
  • Restrict network access from build runners

Defense-in-Depth

  • Use ephemeral CI runners
  • Apply least-privilege secrets access
  • Monitor and log all build-time process execution
  • Enforce artifact signing and verification

Official Patch / Upgrade Link

Official pnpm releases (upgrade to v10.27.0 or later):
👉 https://github.com/pnpm/pnpm/releases


Risk Rating Summary

CategoryRating
LikelihoodHigh
ImpactVery High
Exploit DifficultyModerate
Overall RiskHigh / Critical

Final Takeaway

This vulnerability is particularly dangerous because it targets trusted automation systems. Once a CI/CD pipeline is compromised, attackers can silently poison software at scale.

Any organization using pnpm in automated environments should assume exposure until patched, upgrade immediately, and implement detection rules to catch abuse early.


Aegiron

Backed by 11+ years in cybersecurity and incident response, we decode the latest threats shaping today’s digital battlefield. This blog cuts through the noise with clear insights on vulnerabilities, emerging exploits, and the cyber news defenders can’t afford to miss.