fix: verify attestation before signing; interruptible --config reads #4010
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
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.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
dims
Summary
aicr bundle --attestnow 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--configread 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 staleaicr-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.readFilechecked the context once and then blocked inos.Open/io.ReadAll, which ignore it; since the CLI's signal handler only cancels the context,aicr recipe --config /tmp/cfg.fifocould not be interrupted.Fixes: #2896
Fixes: #3296
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/server)pkg/recipe)pkg/bundler,pkg/component)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)pkg/config,tests/chainsaw/signingImplementation Notes
attestBundleAtcalls the newbinaryAttestation(injected pre-verified bytes, or find, read and verify the sidecar against the CI identity and this binary's digest) beforeAttester.Attest, and writes the same verified bytes into the bundle after signing. The OIDC token is resolved lazily insideAttest, 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 staysUnauthorized, so the exit code is unchanged.--attestis set. No shipped path builds that combination (the SDK facade rejects it and the server injects a pre-verified attestation), so only directpkg/bundlercallers could notice, and they now fail closed.tests/chainsaw/signing/bundle-headless-oidc-ciran--attestwithout--certificate-identity-regexp. They passed only because the device flow blocked insideAttestuntiltimeout 30killed it, before verification ran; the CI binary is attested by the qualification workflow, noton-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.--config(#3296).readFileruns the open and bounded read on a goroutine with a buffered result channel and returns onctx.Done()withErrCodeCanceled(also for a context already canceled before the read; it used to say timeout). Pipes stay supported, so--config <(...)and--config /dev/stdinkeep 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.DefaultBundlergains two unexported hooks,executableandverifyBinary, so tests can place a binary with a sidecar and accept it without a signed fixture. Production leaves both nil.docs/user/cli-reference.mdnow lists verification before credential acquisition in the Bundle Attestation steps.Testing
make qualify: passes; total coverage 86.7% (floor 83%).TestAttestBundle_VerifiesBinaryAttestationBeforeSigning(before: signed once, no error),TestReadFileReturnsWhenCanceledOnAFIFOWithoutAWriter(before: still blocked after 5s),TestReadFileReportsAnAlreadyCanceledContextAsCanceled(before: TIMEOUT). AlsoTestAttestBundle_WritesTheVerifiedSidecar(the verified bytes, verified against this binary's digest, are the bytes in the bundle),TestReadFileReadsAFIFOWithAWriter, and the NotFound code inTestLoad_FileNotFound.executablehook ignored; the read without its goroutine; the cancel branch asWrapinstead ofWrapCtxErr; the read error dropped; an unbuffered result channel (the abandoned read's goroutine then never exits).pkg/bundler87.8% → 88.6% (+0.8%),pkg/config94.3% → 94.4% (+0.1%). No new exported functions.Risk Assessment
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
make testwith-race)make lint)git commit -s -S) — GPG signing info