← Back to Pull requests

fix: verify attestation before signing; interruptible --config reads #4010

Closed
unknown closed this pull request without merging on Nov 23, 2026 22:47 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 20:05 UTC
Author

Summary

aicr bundle --attest now verifies the binary attestation before it signs, so a sidecar from another build fails before any OIDC login, KMS call or transparency-log entry. A --config read that blocks in the kernel (a FIFO with no writer, a hung mount) now returns on Ctrl-C instead of hanging the CLI.

Motivation / Context

With --attest, a stale aicr-attestation.sigstore.json (for example, left behind when the binary was replaced in place) failed only after the bundle was signed, so the user went through the login and a Rekor entry was published for a bundle that was then discarded. Separately, config.readFile checked the context once and then blocked in os.Open/io.ReadAll, which ignore it; since the CLI's signal handler only cancels the context, aicr recipe --config /tmp/cfg.fifo could not be interrupted.

Fixes: #2896
Fixes: #3296

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation update

  • Refactoring (no functional changes)

  • Build/CI/tooling
  • Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)

  • API server (cmd/aicrd, pkg/server)

  • Recipe engine / data (pkg/recipe)

  • Bundler and deployers (pkg/bundler, pkg/component)

  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)

  • Validator (pkg/validator)

  • Core libraries (pkg/errors, pkg/k8s)

  • Docs/examples (docs/, examples/)

  • Other: pkg/config, tests/chainsaw/signing
  • Implementation Notes

  • Verify before signing (#2896). attestBundleAt calls the new binaryAttestation (injected pre-verified bytes, or find, read and verify the sidecar against the CI identity and this binary's digest) before Attester.Attest, and writes the same verified bytes into the bundle after signing. The OIDC token is resolved lazily inside Attest, so verification now precedes every login and signing round-trip, for keyless and KMS signing, every deployer and split bundle sets. The keyless identity-disclosure prompt still comes first; it is a confirmation, not a login. The failure message now names the fix ("reinstall from a release archive or remove --attest to skip"); the code stays Unauthorized, so the exit code is unchanged.

  • One behavior that tightens. Before, an attester that returned no signature (a no-op) skipped binary-attestation verification entirely. Now verification runs whenever --attest is set. No shipped path builds that combination (the SDK facade rejects it and the server injects a pre-verified attestation), so only direct pkg/bundler callers could notice, and they now fail closed.

  • CI smoke test. Two device-flow steps in tests/chainsaw/signing/bundle-headless-oidc-ci ran --attest without --certificate-identity-regexp. They passed only because the device flow blocked inside Attest until timeout 30 killed it, before verification ran; the CI binary is attested by the qualification workflow, not on-tag.yaml, so with verification first they would exit 4. They now pass the CI identity like their sibling steps, and grep the device flow's own start message instead of any mention of "device-code", which the disclosure banner also prints.

  • Interruptible --config (#3296). readFile runs the open and bounded read on a goroutine with a buffered result channel and returns on ctx.Done() with ErrCodeCanceled (also for a context already canceled before the read; it used to say timeout). Pipes stay supported, so --config <(...) and --config /dev/stdin keep working; rejecting non-regular files, the issue's alternative, would break them. A canceled read stays blocked until the kernel releases it (for a FIFO, until a writer opens it or the process exits); the CLI exits right away, and an SDK caller in a long-lived process keeps one goroutine per such read until then. Go does not poll FIFOs on macOS, so a deadline or non-blocking open is not a portable alternative.

  • Test hooks. DefaultBundler gains two unexported hooks, executable and verifyBinary, so tests can place a binary with a sidecar and accept it without a signed fixture. Production leaves both nil.

  • docs/user/cli-reference.md now lists verification before credential acquisition in the Bundle Attestation steps.
  • Testing

    make qualify
    go test -race ./pkg/bundler/... ./pkg/config/... ./pkg/client/v1/... ./pkg/cli/...
    golangci-lint run -c .golangci.yaml ./pkg/bundler/... ./pkg/config/... ./pkg/client/v1/... ./pkg/cli/...
    

  • make qualify: passes; total coverage 86.7% (floor 83%).

  • New tests, each seen failing first: TestAttestBundle_VerifiesBinaryAttestationBeforeSigning (before: signed once, no error), TestReadFileReturnsWhenCanceledOnAFIFOWithoutAWriter (before: still blocked after 5s), TestReadFileReportsAnAlreadyCanceledContextAsCanceled (before: TIMEOUT). Also TestAttestBundle_WritesTheVerifiedSidecar (the verified bytes, verified against this binary's digest, are the bytes in the bundle), TestReadFileReadsAFIFOWithAWriter, and the NotFound code in TestLoad_FileNotFound.

  • Mutations, each caught: verification moved back after signing, or after the no-op short-circuit; the verify error ignored; the success path returning nothing; the executable hook ignored; the read without its goroutine; the cancel branch as Wrap instead of WrapCtxErr; the read error dropped; an unbuffered result channel (the abandoned read's goroutine then never exits).

  • The CI smoke-test change runs only in the same-repo CLI E2E lane (GitHub OIDC); it is checked in this PR's CI.

  • Coverage: pkg/bundler 87.8% → 88.6% (+0.8%), pkg/config 94.3% → 94.4% (+0.1%). No new exported functions.
  • Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

  • Medium — Touches multiple components or has broader impact

  • High — Breaking change, affects critical paths, or complex rollout
  • Rollout notes: N/A. A user with a stale binary attestation now gets the existing verification error before logging in instead of after signing.

    Checklist

  • Tests pass locally (make test with -race)

  • Linter passes (make lint)

  • I did not skip/disable tests to make CI green

  • I added/updated tests for new functionality

  • I updated docs if user-facing behavior changed

  • Changes follow existing patterns in the codebase

  • Commits are signed off and cryptographically signed (git commit -s -S) — GPG signing info
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: dims Review duration: 162m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.75 · 650 lines diff across 8 files
    0.75
    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%
    60%
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.075
    Real PR Conversation Timeline
    1 comments
    "Review active on #4010"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 75.2% (HIGH) · Higher = larger blast radius
    75.2%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 29.7% · Safe to merge
    29.7%
    Repository