Safeguard
Security Guides•

What limits should a scan worker have: time, memory and network?

Scan workers process untrusted input. Give each job a wall clock timeout, memory and disk caps, an archive size ceiling, and a locked-down network egress policy.

Safeguard Security Team
4 min read

Every scan worker should have a wall clock timeout, memory and CPU limits, a disk quota, caps on archive size and file count, and restricted network egress. Scanners open untrusted archives and repositories, so assume some inputs are hostile or just enormous.

Why limits are part of security

A scanner reads other people's content: source trees, container layers, package archives. Some inputs are accidentally huge. Some are crafted. A compressed file can expand to many times its size, and a repository can contain millions of tiny files. Without limits, one input can exhaust a node and delay every other team's scans.

Limits also contain damage. If a parser has a flaw, a locked-down worker limits what the attacker gets.

The limits to set

LimitWhat it preventsNotes
Wall clock timeout per jobHung or looping scansBase it on a percentile of normal runs, with headroom
Memory limitOne job crashing the nodeOut of memory kills should be a recorded failure class
CPU limitNoisy neighboursUse requests and limits in your orchestrator
Disk quota for scratch spaceArchive expansion filling the diskClean the workspace after every job
Decompressed size and file count capArchive bombsCheck while extracting, not after
Path handling rulesArchive entries that write outside the workspaceReject absolute paths and parent directory traversal
Network egress allowlistExfiltration and calls to internal servicesAllow the database mirror and results endpoint only

Isolation matters as much as limits

  1. Run each job in a fresh sandbox, such as a container with no privileges, or a lightweight virtual machine for stronger separation.
  2. Run as a non-root user, drop capabilities, and use a read-only root file system with a writable scratch directory.
  3. Never mount host credentials or the container runtime socket.
  4. Give the worker short-lived, narrowly scoped credentials to fetch only the target it is scanning.
  5. Do not execute the code under scan. Static analysis and dependency analysis should read files, not run build scripts or install hooks.
  6. Destroy the sandbox after the job so nothing carries over.

Choosing the numbers

Collect data first. Measure duration, memory peak and disk use per scan type for a few weeks, then set limits above the 99th percentile and review monthly. Too tight and legitimate large repositories fail, which creates support tickets and exceptions. Too loose and the limit never fires.

For jobs that exceed a limit, fail with a clear message that names the limit. "Scan exceeded memory limit of the configured size on this path" helps an owner exclude a vendored directory, whereas a generic error does not.

Large inputs are a product question

Some legitimate targets are just big: monorepos, huge images. Offer a path for them, such as sharding the scan or a larger worker class with approval, rather than raising the default for everyone.

Try it yourself

Click through it at your own pace, or open it full screen. Notice that the scan reads the image contents and reports on them without running the image.

Safeguard runs scanning as a hosted service, so worker isolation is handled on our side. You can try the free scan at https://gold.safeguard.sh/scan.

Quick check

Should scanners run the project's build?

Avoid it where you can. Running build scripts executes untrusted code. Prefer reading manifests and lockfiles.

What timeout should I start with?

Start from measured run times for each scan type and set the limit above the 99th percentile, then adjust.

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.