Skip to content

scanner: bound source staging enumeration and run it under the scan timeout #1602

Closed

Description

@Dumbris

Follow-up from the TPA red-team PR #1596 (Sol 6.1 round 21, transcript kept locally).

  1. 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.
  2. Staging outside the scan timeout — internal/security/scanner/engine.go:823: source staging runs before DockerRunner.RunScanner starts its timeout (docker.go:~220-225) and production scans pass context.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugpriority/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions