{"record":{"id":"44615bc5b6a7568b","repo":"hashicorp/packer","slug":"sigstore-bundle-signature-does-not-match-any-attes","errorCode":null,"errorMessage":"sigstore bundle signature does not match any attestation signature","messagePattern":"sigstore bundle signature does not match any attestation signature","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/attestation/verify.go","lineNumber":380,"sourceCode":"\t}\n\n\tif len(envelope.Signatures) == 0 {\n\t\treturn fmt.Errorf(\"attestation envelope has no signatures\")\n\t}\n\n\tbundleSignature := bundleEnvelope.Signature()\n\tfor i, envelopeSignature := range envelope.Signatures {\n\t\tsignature, err := DecodeEnvelopeSignature(envelopeSignature)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"decode attestation envelope signature %d: %w\", i, err)\n\t\t}\n\n\t\tif bytes.Equal(bundleSignature, signature) {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"sigstore bundle signature does not match any attestation signature\")\n}\n\nfunc verifyArtifactSubject(subjects []internalprovenance.Subject, artifactPath string) error {\n\tdigest, err := sha256File(artifactPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"hash artifact %q: %w\", artifactPath, err)\n\t}\n\n\tartifactName := filepath.Base(artifactPath)\n\tfor _, subject := range subjects {\n\t\tif subject.Name == artifactName && strings.EqualFold(subject.Digest[\"sha256\"], digest) {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"attestation subject does not match artifact %q\", artifactPath)\n}\n","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/attestation/verify.go#L362-L398","documentation":"ensureBundleMatchesEnvelope verifies that the Sigstore bundle being checked actually signs the same DSSE attestation that is being verified. It extracts the bundle's envelope, checks payload type/payload equality, then compares the bundle's signature bytes against each decoded signature in the attestation envelope. If no signature byte-matches, it means the bundle and envelope come from different (or re-signed) attestations, so verification cannot proceed.","triggerScenarios":"verifySigstoreBundleEvidenceImpl passes a bundle whose envelope payload matches the attestation but whose signature bytes differ from every signature entry in the envelope — e.g. the attestation was re-signed after the bundle was produced, or the bundle belongs to a different (but identically-payloaded) attestation.","commonSituations":"Mixing artifacts from different CI runs: downloading a bundle from one `cosign attest` run and the in-toto statement/envelope from another; regenerating an attestation with an updated signer key while reusing an old bundle; manually editing envelope signatures; key rotation between bundle creation and verification.","solutions":["Regenerate the Sigstore bundle from the exact attestation envelope being verified (re-run the sign/attest step) so signatures match","Confirm the bundle file and attestation envelope come from the same CI run / build ID","Verify the envelope's signatures were not re-encoded (whitespace/base64 canonicalization differences will break bytes.Equal; use consistent encoding)","Check for key rotation: if the signing key changed, re-sign the attestation and rebuild the bundle"],"exampleFix":"// before: verifying a stale bundle against a re-signed attestation\nbundle, _ := loadBundle(\"old-bundle.jsonl\")\nenvelope, _ := loadEnvelope(\"new-attestation.intoto.jsonl\")\nensureBundleMatchesEnvelope(bundle, envelope) // fails\n// after: regenerate both from the same signing run\nbundle, envelope := signAndBundle(payload) // single sign step\nensureBundleMatchesEnvelope(bundle, envelope)","handlingStrategy":"validation","validationCode":"// Verify bundle/envelope pairing before calling the verifier\nenv, err := bundle.Envelope()\nif err != nil { return err }\nif env.RawEnvelope().Payload != envelope.Payload { return errors.New(\"payload mismatch\") }\nsig := env.Signature()\nfor _, s := range envelope.Signatures {\n    dec, err := DecodeEnvelopeSignature(s)\n    if err == nil && bytes.Equal(sig, dec) { return nil }\n}\nreturn errors.New(\"bundle does not sign this attestation\")","typeGuard":null,"tryCatchPattern":"if err := ensureBundleMatchesEnvelope(bundle, envelope); err != nil {\n    return fmt.Errorf(\"stale or mismatched sigstore bundle: %w\", err)\n}","preventionTips":["Always generate the bundle and envelope in the same signing step","Never re-sign an attestation while reusing an existing bundle","Tag artifacts and bundles with the same build ID and verify the pairing","Use canonical base64 encoding for envelope signatures"],"tags":["sigstore","attestation","supply-chain-security"],"backgroundTag":"attestation-signature-mismatch","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}