← Back to Pull requests

Security: reject three hostile-input crashes at the ingest boundary (C1Z-SEC-012) #1168

Closed
unknown closed this pull request without merging on Oct 05, 2026 13:10 UTC
View on GitHub
unknown unknown commented on Oct 04, 2026 19:47 UTC
Author

Summary

C1Z-SEC-012. Three crafted .c1z shapes 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 grants id is a plain SQLite integer primary key, so a file can hold {0, MaxInt64}. sampleGrantBoundaries computed span := maxID - minID + 1, which wraps negative, and rng.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, so EndSyncWithStats panicked. 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.Writer never writes sparse entries, so extraction rejects them with ErrMaxSizeExceeded before creating anything.

Not changed: protowire recursion

The audit also flagged recursion in the raw proto scanners: 26 protowire.ConsumeFieldValue skip sites. ConsumeFieldValue in the pinned google.golang.org/protobuf v1.36.11 stops group nesting at DefaultRecursionLimit (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 makes EndSyncWithStats return ledger 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 with ErrMaxSizeExceeded and nothing extracted. The fixture needs neither an external tar nor disk space.

  • - Without the guard: extraction succeeds.

    Other checks:

  • golangci-lint v2.13.2: 0 issues.

  • go test -short -tags=baton_lambda_support ./...: passes.

  • go test -race passes on pkg/dotc1z/format/v3, pkg/dotc1z/engine/pebble, and the conversion tests in pkg/dotc1z.
  • Diff: 346 lines (+259 / -87) across 4 files Reviewer: c1-squire-dev[bot] Review duration: 1043m
    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
    0.66
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    57%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.6% (HIGH) · Higher = larger blast radius
    65.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 58.0% · Lower = rushed or shallow review
    58.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.5% · Safe to merge
    27.5%