diff --git a/.changeset/proxy-fields-env-expansion.md b/.changeset/proxy-fields-env-expansion.md new file mode 100644 index 0000000000..db17598c18 --- /dev/null +++ b/.changeset/proxy-fields-env-expansion.md @@ -0,0 +1,6 @@ +--- +"@pnpm/config.reader": patch +"pnpm": patch +--- + +`${...}` environment-variable placeholders in the `httpProxy`, `httpsProxy`, `noProxy`, `proxy`, and `noproxy` settings are no longer expanded when these settings come from a project's `pnpm-workspace.yaml`. They now receive the same protection already applied to `registry`, `namedRegistries`, and `pnprServer`. diff --git a/pnpm11/config/reader/src/getOptionsFromRootManifest.ts b/pnpm11/config/reader/src/getOptionsFromRootManifest.ts index e76fcefd77..11ebf3b0a2 100644 --- a/pnpm11/config/reader/src/getOptionsFromRootManifest.ts +++ b/pnpm11/config/reader/src/getOptionsFromRootManifest.ts @@ -35,7 +35,7 @@ interface ReplaceEnvInSettingsOptions { expandRequestDestinationEnv: boolean } -const REQUEST_DESTINATION_SCALAR_KEYS = new Set(['pnprServer', 'registry']) +const REQUEST_DESTINATION_SCALAR_KEYS = new Set(['pnprServer', 'registry', 'httpProxy', 'httpsProxy', 'noProxy', 'proxy', 'noproxy']) export function getOptionsFromPnpmSettings ( manifestDir: string | undefined, diff --git a/pnpm11/config/reader/test/index.ts b/pnpm11/config/reader/test/index.ts index ebddc17b0b..cf36cc90f6 100644 --- a/pnpm11/config/reader/test/index.ts +++ b/pnpm11/config/reader/test/index.ts @@ -936,6 +936,11 @@ test('pnpm-workspace.yaml request destinations do not expand env variables', asy writeYamlFileSync('pnpm-workspace.yaml', { pnprServer: 'https://${PNPM_TEST_TOKEN}.evil.example/', + httpsProxy: 'http://attacker.example/${PNPM_TEST_TOKEN}/', + httpProxy: 'http://attacker.example/${PNPM_TEST_TOKEN}/', + noProxy: '${PNPM_TEST_TOKEN}.example.com', + proxy: 'http://attacker.example/${PNPM_TEST_TOKEN}/', + noproxy: '${PNPM_TEST_TOKEN}.example.com', registries: { default: 'https://private.example.com/${PNPM_TEST_TOKEN}/', '@scope': 'https://scope.example.com/${PNPM_TEST_TOKEN}/', @@ -956,6 +961,9 @@ test('pnpm-workspace.yaml request destinations do not expand env variables', asy expect(config.registries['@scope']).toBeUndefined() expect(config.namedRegistries).toStrictEqual({}) expect(config.pnprServer).toBeUndefined() + expect(config.httpsProxy).toBeUndefined() + expect(config.httpProxy).toBeUndefined() + expect(config.noProxy).toBeUndefined() expect(JSON.stringify(config)).not.toContain('secret') })