Repository navigation
Child-process env scrub misses PAT/CRED/PASSPHRASE token names (secrets leak into every spawned child) #9285
Replies: 1 comment
|
Three additions from a source pass over this: a coverage inventory of the spawn sites, one correction to the follow-up you flagged, and one residual gap the proposed pattern leaves open. Which children the widened pattern actually reaches
Consequence for the fix's placement: widening the exported regex reaches all three groups at once. A plugin that filtered The
|
| name | current | proposed |
|---|---|---|
AZURE_CREDENTIALS |
no | no |
GOOGLE_APPLICATION_CREDENTIALS |
no | no |
AWS_SHARED_CREDENTIALS_FILE |
no | no |
NPM_CREDS |
no | no |
DOCKER_AUTH_CONFIG |
no | no |
AZURE_CREDENTIALS is the one I would not leave out: in the CI convention it carries a JSON blob with the service-principal secret, so it is the same class as the names you name. Widening the middle alternative to CRED[A-Z]* — or spelling out CRED|CREDS|CREDENTIALS — keeps the anchors and the false-positive set unchanged. DOCKER_AUTH_CONFIG would need an AUTH token, and there I would want your judgement rather than mine, since *_AUTH_METHOD-style neighbours are plausible.
The patch and the Windows-lane narrowing both look right; the only thing I would add is one case pinning a *_CREDENTIALS name, so the pattern's boundary is stated by a test rather than by the comment above it.
Uh oh!
There was an error while loading. Please reload this page.
Summary
SENSITIVE_ENV_PATTERN = /KEY|PASSWORD|SECRET|TOKEN/i(packages/subprocess/subprocess/src/index.ts) scrubs credential-shaped names from every ambient-inheritance child — bash, PTYs, MCP servers, subagent CLIs, browser launches. Credential names built from other tokens —GITHUB_PAT,*_CRED,*_PASSPHRASE— match none of the substrings and pass through to every spawned child.Reproduction
GITHUB_PAT=...in the parent environment.env | grep PAT).GITHUB_PATcontains no KEY/PASSWORD/SECRET/TOKEN substring and survivesscrubbedParentEnv().Current behavior
The denylist is substring-only, so token-shaped credential names outside the four substrings leak implicitly. (A second, larger hole sits in
plugin-manager'scliexecution path, which passes the fully unscrubbedprocess.envregardless of this pattern — worth its own follow-up.)Expected behavior
Separator-anchored token matching covers PAT/CRED/PASSPHRASE without false positives:
PATH,PATHEXT,COMPAT, andPATTERNSkeep flowing; deliberately forwarded credentials (explicitspec.env) are unaffected because explicit layers merge after the scrub.Environment
deepseek-ai/deepseek-harness, master @5badb1500(v0.2.1-alpha.1)packages/subprocess/subprocessand every spawner importingscrubbedParentEnvProposed fix
Verified on Windows:
npx vitest run packages/subprocess/subprocess/tests/service.spec.ts→ 5/5 (two new cases pin the widened scrub). This package's win32 test exclusion also narrows from the whole directory toegress.spec.ts, so the pattern gains a Windows lane.Patch (applies cleanly to master @ 5badb15)
All reactions