Security: fail open of corrupt-SST artifacts with an error, not os.Exit(1) #1161
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.68) × (1 − Review Confidence (0.58)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.68 · 421 lines diff across 5 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.362
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.068
Real PR Conversation Timeline
1 comments
"Review active on #1161"
general
weight: 0.35
pquerna
Summary
C1Z-SEC-005: a v3
.c1zwhose Pebble checkpoint has one flipped byte inside an SST data block killed the process that opened it. The file sizes stay equal to what the MANIFEST records, sopebble.Open's size check passes. The first read of the block then went through pebble's defaultDataCorruptionhandler, which callsLogger.Fatalf, and our logger'sFatalfcalledos.Exit(1). Any process that opened an untrusted artifact died: the shared compaction worker, syncer previous-sync opens, the CLI.Changes
newPebbleOptionsalways installsEventListener.DataCorruption. The read that hits the block returns pebble's corruption error;pebble.IsCorruptionErrorstill holds after the store layer wraps it. The event is logged at ERROR viazap.L()with the file path, key bounds and details. There is no option to turn this off.CheckpointTothen refuses and wraps the original corruption error. This matters for background compactions, whose error reaches no caller: without the refusal, a writable store could save the corrupt table into a new artifact.CheckpointTois the only path to a saved artifact (store save, clone-sync), and a refused save comes back out ofCloseasErrArtifactUnusable. The listener records into anEngineallocated beforerawdb.Open, so nothing is written to shared state after pebble's goroutines start.discardPebbleLogger.ErrorfandFatalflog throughzap.L()instead of writing to stderr;pebble.Loggercarries no ctx.Fatalfpanics instead of callingos.Exit(1). Its remaining callers are pebble's internal invariant checks and failed MANIFEST or WAL writes. The panic carries a stack trace, and a caller that recovers it must stop using the engine.WALs are not a second route to the old
Fatalf. Saved payloads carry empty WALs (CheckpointTotruncates them;TestCheckpointWALsAreEmpty), and a corrupt WAL failspebble.Open's replay with an error.Compatibility
pkg/dotc1z/engine/pebbleconsumers get a corruption error where the process used to exit.zap.L()is a no-op unless the program installs a global logger.pkg/logginginstalls one; before this change these lines always went to stderr.Tests
TestSecurity_CorruptSSTFailsWithError(pkg/dotc1z):- Setup: write an honest c1z, unpack it, flip a mid-file byte of the largest SST, and re-frame it.
- It opens the result writable and read-only, lists resources, and asserts
pebble.IsCorruptionError. The read-only case also covers the store's writable migration pre-open.- With the listener removed, the test panics with
pebble FATAL: on-disk corruption ... crc32c checksum mismatch.TestCheckpointToRefusesAfterCompactionFindsCorruption(pkg/dotc1z/engine/pebble):- Setup: a corrupt table plus an overlapping L0 table, so
CompactAllRangesreads the corrupt block.-
CheckpointTothen fails with a corruption error.- With the guard removed,
CheckpointTosucceeds and the test fails.golangci-lint run ./...: 0 issues.go test -short -tags=baton_lambda_support ./...passes.go test -racepasses onpkg/dotc1z/engine/pebbleand onTestSecurity_CorruptSSTFailsWithError.