Commit b262a78
authored
fix(mcp): normalize env names before secret-pattern matching (#106)
isSensitiveEnvVar substring-matched patterns like API_KEY against the raw
variable name, so MCP server env overrides named API-KEY, APIKEY, or
PRIVATE-KEY - all legal spellings in environment variable names - were
forwarded to potentially untrusted MCP subprocesses. Only the override
path was affected; the inherited-environment path is allowlist-based.
Names are now normalised (uppercased, "-" and "_" stripped) before
matching, and the patterns are stored in normalised form, so
API-KEY/APIKEY/Api-Key/PRIVATE-KEY/SECRET-KEY/AUTH-TOKEN and similar
spellings are all stripped.
Regression tests extend TestBuildEnv_OverridesCannotInjectSecrets with
non-underscore spellings and add TestIsSensitiveEnvVar_NormalizesSeparators
covering blocked spellings and benign names. Docs updated (SECURITY.md
section 19, AGENTS.md).1 parent fc69bbe commit b262a78
4 files changed
Lines changed: 41 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
311 | 316 | | |
312 | | - | |
| 317 | + | |
313 | 318 | | |
314 | | - | |
315 | | - | |
| 319 | + | |
| 320 | + | |
316 | 321 | | |
317 | | - | |
| 322 | + | |
318 | 323 | | |
319 | 324 | | |
320 | 325 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
420 | | - | |
| 420 | + | |
421 | 421 | | |
422 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
423 | 429 | | |
424 | 430 | | |
425 | 431 | | |
426 | 432 | | |
427 | 433 | | |
428 | 434 | | |
429 | | - | |
| 435 | + | |
430 | 436 | | |
431 | 437 | | |
432 | 438 | | |
433 | 439 | | |
434 | 440 | | |
435 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
436 | 464 | | |
437 | 465 | | |
438 | 466 | | |
| |||
0 commit comments