mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

[Bug]: private_key_file false positive on JS member access like x.key in code_execution arguments

Open algis-dumbris opened this issue 4 days ago • 0 comments

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.key gives x.key, which then matches *.key.
  • There is no right boundary, so obj.keyboard gives obj.key.
  • Any ident.key / ident.env / ident.pem member 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

  1. Add a right boundary: (?:$|[\s"'),;\]}]) (or \b plus a lookahead equivalent, since RE2 has no lookahead), so obj.keyboard no longer matches.
  2. 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 the code field of code_execution. Alternatively, run the bare-file-name pass only on string literals.
  3. Add regression tests for the table above.

algis-dumbris avatar Nov 30 '26 06:11 algis-dumbris