mcpproxy-go
mcpproxy-go copied to clipboard
[Bug]: private_key_file false positive on JS member access like x.key in code_execution arguments
What happened
A code_execution call was flagged critical / private_key_file in arguments, but the arguments contain no file path or key — only JavaScript. The match was the property access x.key in:
(d.issues||[]).map(x => ({k: x.key, l: x.fields.labels}))
mcpproxy v0.76.0, darwin/arm64. The activity record has is_likely_example: false, so nothing downgrades it.
Cause
ExtractPaths in internal/security/paths.go:147:
fileNamePattern := regexp.MustCompile(`(?:^|[\s"'=:])([a-zA-Z0-9._\-]+\.(?:pem|key|ppk|p12|pfx|jks|keystore|env|kdbx|pgpass))`)
:counts as a left boundary, so{k:x.keygivesx.key, which then matches*.key.- There is no right boundary, so
obj.keyboardgivesobj.key. - Any
ident.key/ident.env/ident.pemmember access in JS, Python or Go source matches.
| Input | Extracted | Flagged as |
|---|---|---|
{k:x.key} |
x.key |
private_key_file (critical) |
items.map(i => i.key) |
i.key |
private_key_file (critical) |
{a:obj.keyboard} |
obj.key |
private_key_file (critical) |
{id: row.env} |
row.env |
env_file (high) |
code_execution arguments are code by definition, so every agent that reads .key off an object sets this off. That makes the critical alerts noise.
Suggested fix
- Add a right boundary:
(?:$|[\s"'),;\]}])(or\bplus a lookahead equivalent, since RE2 has no lookahead), soobj.keyboardno longer matches. - For bare file names with no
/, require a name that looks like a file rather than an identifier member access. For example, skip a match when the next character is.,(or[, or when the arguments are thecodefield ofcode_execution. Alternatively, run the bare-file-name pass only on string literals. - Add regression tests for the table above.