Repository navigation
Conversation
A caller-chosen run summary could be any size, and sha256File loaded whole artifacts into memory. Cap the summary at 8 MiB and hash artifacts in 1 MiB chunks; both behaviours are covered by focused tests.
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
readHardenRunSummaryread whatever path the caller supplied withreadFileSync(..., "utf8"), andsha256Fileread whole artifacts before hashing. The summary lookup is exposed throughbla_run_lookup, so an arbitrary large file could be buffered just to fail JSON parsing, and a multi-gigabyte model output was loaded whole for a digest.The rest of the evidence path already uses bounded reads and chunked hashes (
manifest-verify,output-registry,verify-sidecar). This brings the shared helper in line.What changed
readHardenRunSummarynow rejects a summary aboveMAX_HARDEN_SUMMARY_BYTES(8 MiB) and requires a regular file, with an explicit error that names the size and the ceiling.sha256Filestreams the file through a 1 MiB buffer withopenSync,readSyncandcloseSync, producing the same SHA-256 as the previous whole-file read.tests/run-evidence-bounded.test.tscovers an oversized sparse summary and compares the chunked digest tocrypto.createHashover the same bytes.Compatibility
Digests are identical. Summaries BLA writes are small, so normal lookups are unaffected. A caller that intentionally points
bla_run_lookupat a file larger than 8 MiB now gets a clear refusal instead of a parse error or an out-of-memory path.Verification
npx vitest run tests/run-evidence-bounded.test.ts tests/run-evidence.test.ts tests/harden-apply-*.test.tspasses, 22 tests with 1 skipped.npx tsc --noEmitis clean.