Security: reject three hostile-input crashes at the ingest boundary (C1Z-SEC-012) #1168
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.66) × (1 − Review Confidence (0.58)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.66 · 346 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.350
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.066
Real PR Conversation Timeline
1 comments
"Review active on #1168"
general
weight: 0.35
c1-squire-dev[bot]
Summary
C1Z-SEC-012. Three crafted
.c1zshapes crashed the process reading them, or got past the decoded-byte budget. Each now returns an error or takes a safe path. The same file fails the same way on every retry, so each was a poison pill for the shared compaction worker.1. v1 grant rowids that overflow the lane sampler (
to_pebble.go). The v1 grantsidis a plain SQLite integer primary key, so a file can hold{0, MaxInt64}.sampleGrantBoundariescomputedspan := maxID - minID + 1, which wraps negative, andrng.Int63n(span)panicked in every v1→pebble conversion. Sampling only balances conversion lanes, so a span that overflows now skips it.2. A ledger child without an identity (
ledger.go). The seal scrub,scrubLedgerRow, reads ledger rows back from the file and wrote through a child's nil identity, soEndSyncWithStatspanicked. This SDK never writes such a row, so the scrub now returns an error and the seal fails with it.3. GNU sparse tar entries (
format/v3/envelope.go). archive/tar synthesizes a sparse entry's holes itself, so those bytes never pass through the budgeted payload reader. About 3 KB of tar can declare a 16 GiB file, and extraction would write all of it.tar.Writernever writes sparse entries, so extraction rejects them withErrMaxSizeExceededbefore creating anything.Not changed: protowire recursion
The audit also flagged recursion in the raw proto scanners: 26
protowire.ConsumeFieldValueskip sites.ConsumeFieldValuein the pinnedgoogle.golang.org/protobuf v1.36.11stops group nesting atDefaultRecursionLimit(10000) and returns an error. The scanners report that as a parse error; a 1M-deep group value is rejected at open without a crash. Not material against the pinned version.Tests
Each test fails, as shown, with its guard removed:
TestSecurity_ToPebbleWithExtremeGrantRowids: a v1 file with grant rowids 0 and MaxInt64 converts to pebble.- Without the guard:
panic: invalid argument to Int63n.TestSecurity_SealRejectsLedgerChildWithoutIdentity: a committed ledger row whose stored child identity is cleared makesEndSyncWithStatsreturnledger row child has no identity.- Without the guard: nil-pointer panic.
TestSecurity_ExtractionRejectsSparseEntries: an in-memory PAX 0.1 sparse tar (about 3 KB declaring 64 MiB) is rejected withErrMaxSizeExceededand nothing extracted. The fixture needs neither an externaltarnor disk space.- Without the guard: extraction succeeds.
Other checks:
golangci-lintv2.13.2: 0 issues.go test -short -tags=baton_lambda_support ./...: passes.go test -racepasses onpkg/dotc1z/format/v3,pkg/dotc1z/engine/pebble, and the conversion tests inpkg/dotc1z.