Skip to content

fix(security): size the scanner worker for grype and say when it runs out of memory - #1513

Merged
scttbnsn merged 5 commits into
dev/v1.8from
fix/v1.8-grype-scan-failure
Oct 29, 2026
Merged

scttbnsn merged 5 commits into
dev/v1.8from
fix/v1.8-grype-scan-failure

Conversation

@scttbnsn

Copy link
Copy Markdown
Contributor

Refs #1281. The reporter's pre-update grype scans all failed with Scanner worker exited with status 137 on rc.8.

Each scan runs in its own hardened worker container, and that worker's memory was hardcoded at 512 MiB. Grype goes over that on ordinary large images. I profiled rc.8 with grype on Colima (arm64, so the numbers are indicative):

image smallest worker limit that passed
postgres:16 384 MiB
node:22 768 MiB
nextcloud:30 about 896 MiB

Below the limit the worker is OOM-killed (OOMKilled=true, exit 137, empty stderr), and drydock reported only the bare status. A real rc.8 scan of nextcloud:30 reproduced the reporter's exact message.

Changes:

  • DD_SECURITY_WORKER_MEMORY sets the worker limit (512m, 1g, 1536m or bytes, at least 6m), validated at startup. The default goes from 512 MiB to 1 GiB.
  • On exit 137 the worker is inspected before it's removed. The error now says it was OOM-killed, or most likely out of memory if inspect can't tell, and names the limit and the setting.
  • Grype's output cap is configurable through DD_SECURITY_GRYPE_MAXOUTPUTBYTES, with the same bounds as Trivy's and a 128 MB default. A single limit now covers capture and parse. Before, it was 50 MB to capture and 20 MB to parse, and the nextcloud:30 JSON is 59.6 MB, so a large image would have failed there once memory wasn't the problem.
  • The docs add both settings, plus a note that scan errors follow DD_SECURITY_AVAILABILITY_POLICY (default block), not DD_SECURITY_BLOCK_SEVERITY. That's why NONE didn't let the reporter's updates through, and warn is the workaround.
cd app && npx vitest run --coverage.enabled=false security configuration

The scanner worker memory limit was hardcoded at 512 MiB, so Grype could be OOM-killed on large images and the only symptom was 'exited with status 137' with no hint. DD_SECURITY_WORKER_MEMORY now sets the limit (integer with optional b/k/m/g suffix, minimum 6m, default 512m) and is passed through the hardening options. A 137 exit now inspects the worker before removal and reports an OOM kill, or 'most likely out of memory', with the configured limit and the setting name. Docs and changelog updated, and the docs now note that scan errors follow DD_SECURITY_AVAILABILITY_POLICY. Refs #1281
Profiling Grype under rc.8 on Colima: postgres:16 passed at 384 MiB, node:22 needed 768 MiB and nextcloud:30 about 900 MiB, so the old 512 MiB default OOM-killed common large images with exit 137. Refs #1281
…g below it

Grype's JSON for large images (nextcloud:30 is about 60 MB) overran the hardcoded 50 MiB capture and 20 MiB parse limits. DD_SECURITY_GRYPE_MAXOUTPUTBYTES now sets one limit for both capture and parse (default 128 MB, 1 MB to 1 GB like Trivy), and the overflow errors name it. Refs #1281
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 282f9db and 92d54f5.

Files ignored due to path filters: 1
  • CHANGELOG.md is excluded by !CHANGELOG.md
Files selected for processing: 11
  • app/configuration/index.test.ts
  • app/configuration/index.ts
  • app/security/backends/docker.test.ts
  • app/security/backends/docker.ts
  • app/security/providers/grype.test.ts
  • app/security/providers/grype.ts
  • app/security/scan.test.ts
  • app/security/scan.ts
  • app/security/scanner-runtime.test.ts
  • app/security/scanner-runtime.ts
  • content/docs/current/configuration/security/index.mdx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttbnsn
scttbnsn merged commit 66076a0 into dev/v1.8 Oct 29, 2026
34 of 35 checks passed
@scttbnsn
scttbnsn deleted the fix/v1.8-grype-scan-failure branch October 29, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant