fix(scanner): prevent oom crashes by capping file read size#184
Merged
san-zrl merged 1 commit intocbomkit:mainfrom Apr 13, 2026
Merged
fix(scanner): prevent oom crashes by capping file read size#184san-zrl merged 1 commit intocbomkit:mainfrom
san-zrl merged 1 commit intocbomkit:mainfrom
Conversation
c57b0ab to
93b7188
Compare
Signed-off-by: Joshua Kristof <joshua.kristof@digits.schwarz>
93b7188 to
c13749f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR should fix a Out-Of-Memory problem in the scanner plugins by enforcing a strict memory cap during file reads, preventing unbounded memory allocations when analyzing massive files.
Motivation
Previously, the certificates and secrets plugins utilized unbounded read operations to load files entirely into RAM before parsing. When the scanner encountered large files (e.g. multi-gigabyte Database files) this caused big memory spikes. In our deployment, scanner was running in K8s environment with limited memory usage to scan other container images, this resulted in abrupt crashes of the entire container the scanner was running in.
This was tested with the following image:
https://hub.docker.com/r/tenable/securitycenter-install. While the previous code spikes on memory usage near 6 GiB while after the fix it spikes at around 500 MiB.Features
Bounded Memory Allocation: Caps all file read operations to a maximum threshold using io.LimitReader.
Keeping the configurable Limits and Default Limits
Files Modified
provider/plugins/certificates/
└── certificates.go # Replaced ReadAllAndClose with LimitReader + defer
provider/plugins/secrets/
└── secrets.go # Replaced unbounded ReadAll with LimitReader + defer
Testing
Breaking Changes
None.