mcpproxy-go
mcpproxy-go copied to clipboard
scanner: bound source staging enumeration and run it under the scan timeout
Follow-up from the TPA red-team PR #1596 (Sol 6.1 round 21, transcript kept locally).
- Unbounded directory enumeration —
internal/security/scanner/source_staging.go:112:d.ReadDir(-1)allocates every entry before the 100,000-entry cap is checked (lines ~124-126), so an upstream-controlled directory with millions of entries can exhaust daemon memory before staging fails closed. Fix: read in bounded batches and enforce the remaining entry budget during enumeration; extend the cap test to assert bounded allocation. - Staging outside the scan timeout —
internal/security/scanner/engine.go:823: source staging runs beforeDockerRunner.RunScannerstarts its timeout (docker.go:~220-225) and production scans passcontext.Background()(engine.go:~368-370);copyRegularFromRoot(source_staging.go:~173-193) copies without a context. A slow or huge source tree can stall a scan indefinitely. Fix: create the scan deadline before staging and make the copy context-aware.
Both are availability (not bypass) issues: staging still fails closed and tampering still discards results.