-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The CMS certificates field is optional. gitsign's verifier was not.\n\nCMS/PKCS7 is the binary envelope format Sigstore uses for git commit signatures. RFC 5652 defines `SignedData` with a `certificates` field of type `CertificateSet`, marked `OPTIONAL`. A `SignedData` with the field absent, or with an empty `CertificateSet`, is structurally valid DER. A parser that decodes one without error is correct under the spec.\n\ngitsign's verifier sits behind an internal fork of `github.com/github/smimesign`'s ietf-cms parser. The library's `X509Certificates()` function honors the spec exactly:\n\n```go\n// X509Certificates gets the certificates, assuming that they're X.509 encoded.\nfunc (sd *SignedData) X509Certificates() ([]*x509.Certificate, error) {\n\t// Certificates field is optional. Handle missing value.\n\tif sd.Certificates == nil {\n\t\treturn nil, nil\n\t}\n\n\t// Empty set\n\tif len(sd.Certificates) == 0 {\n\t\treturn []*x509.Certificate{}, nil\n\t}\n\n\tcerts := make([]*x509.Certificate, 0, len(sd.Certificates))\n\tfor _, raw := range sd.Certificates {\n\t\t...\n\t}\n\n\treturn certs, nil\n}\n```\n\nTwo of three return paths produce a non-error result the caller must measure before indexing. The comments above them name both spec cases out loud: \"Certificates field is optional. Handle missing value.\" and \"Empty set.\"\n\nThe gitsign caller, in `pkg/git/verifier.go` from v0.4.0 through v0.14.0, is what CVE-2026-44310 names:\n\n```go\n// Generate verification options.\ncerts, err := sd.GetCertificates()\nif err != nil {\n\treturn nil, fmt.Errorf(\"error getting signature certs: %w\", err)\n}\ncert := certs[0]\n```\n\n`GetCertificates()` is a one-line passthrough to `X509Certificates()`. The result the library's comment described as \"optional\" and \"empty set\" is indexed at `[0]` with no length check. When an attacker submits a CMS envelope whose certificates field is absent or empty, the Go runtime raises `runtime error: index out of range [0] with length 0` on the line that reads `cert`.\n\nThe patch is two added lines, before the existing read:\n\n```diff\n \tcerts, err := sd.GetCertificates()\n \tif err != nil {\n \t\treturn nil, fmt.Errorf(\"error getting signature certs: %w\", err)\n \t}\n+\tif len(certs) == 0 {\n+\t\treturn nil, fmt.Errorf(\"no certificates found in signature\")\n+\t}\n \tcert := certs[0]\n```\n\nThe fix is the length check the spec required of every caller of the underlying library. The library's comments named the case. The caller did not read them.\n\nThat caller was introduced on October 20, 2022, in commit 6a3b4aa, \"Refactor git commit verification into its own interface.\" Three years and six months between that commit and the patch. The library's comment naming the optional case predates the caller.\n\n## The wrapper's recover ran. Its return value did not.\n\nA panicking verifier in isolation crashes the process. The exit status of a Go binary killed by an unrecovered panic is 2. A CI pipeline gating on `git verify-commit && deploy` reading exit 2 would refuse to deploy. The panic alone is a denial of service, not a bypass.\n\nWhat makes it a bypass is `internal/io/streams.go`'s `Wrap()` function, which every gitsign subcommand runs inside. The pre-patch shape:\n\n```go\nfunc (s *Streams) Wrap(fn func() error) error {\n\t// Log any panics to ttyout, since otherwise they will be lost to os.Stderr.\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\tfmt.Fprintln(s.TTYOut, r, string(debug.Stack())) // nolint:errcheck\n\t\t}\n\t}()\n\n\tif err := fn(); err != nil {\n\t\tfmt.Fprintln(s.TTYOut, err) // nolint:errcheck\n\t\treturn err\n\t}\n\treturn nil\n}\n```\n\nWalk this carefully because it is the load-bearing failure.\n\nThe deferred function is the panic catcher. `recover()` returns the value passed to `panic`, or nil if no panic is in flight. The defer body prints the panic value and a stack trace to `TTYOut`. The comment above explains the print: \"Log any panics to ttyout, since otherwise they will be lost to os.Stderr.\" The author was thinking about visibility of error messages to a user at a terminal, not about whether the function returns an error.\n\nAfter the defer runs, control returns to the caller of `Wrap`. The return value `Wrap` produces in the panic case is the zero value of its declared return type, `error`. The zero value of an interface is `nil`. `Wrap` returns `nil`.\n\nThe function is named `Wrap`. The comment on the defer says \"Log any panics.\" Neither names the second thing the defer is also doing, which is converting a runtime panic into a successful return.\n\nThe patch is six tokens of Go:\n\n```diff\n-func (s *Streams) Wrap(fn func() error) error {\n+func (s *Streams) Wrap(fn func() error) (retErr error) {\n \t// Log any panics to ttyout, since otherwise they will be lost to os.Stderr.\n \tdefer func() {\n \t\tif r := recover(); r != nil {\n \t\t\tfmt.Fprintln(s.TTYOut, r, string(debug.Stack())) // nolint:errcheck\n+\t\t\tretErr = fmt.Errorf(\"panic: %v\", r)\n \t\t}\n \t}()\n```\n\nA named return value, and an assignment inside the defer. The wrapper now does what its name implied.\n\nThat shape of `Wrap` was committed on November 9, 2022, in commit 262c054, \"Refactor commands with Cobra.\" Three years and almost six months between that commit and the patch.\n\n## main.go has one exit-code condition. It was false.\n\n```go\nfunc main() {\n\tcfg, err := config.Get()\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, err)\n\t\tos.Exit(2)\n\t}\n\n\trootCmd := root.New(cfg)\n\n\tif err := rootCmd.Execute(); err != nil {\n\t\tos.Exit(1)\n\t}\n}\n```\n\n`rootCmd.Execute()` returns whatever the root command's `RunE` returned. The root command's `RunE` is:\n\n```go\nreturn s.Wrap(func() error {\n\tswitch {\n\t...\n\tcase o.FlagVerify:\n\t\treturn commandVerify(o, s, args...)\n\t...\n\t}\n})\n```\n\nIn the panic case, `commandVerify` never returns; it unwinds through the panic. `Wrap`'s deferred `recover()` catches it and `Wrap` returns nil. `Execute()` returns nil. The `if err != nil` is false. `main` returns without calling `os.Exit`. Go's runtime exits the process with status 0.\n\nThree plausible code paths in three different files: a library function that honors the spec, a verifier that doesn't check its inputs, a wrapper that catches panics for logging, a main that branches on error. Read one at a time, each looks reasonable. Composed end to end, they form a function whose contract is \"verify this signature, exit nonzero if it doesn't verify\" and whose behavior is \"exit zero on a spec-legal empty envelope.\"\n\n## git verify-commit is the gate. Exit zero is the only thing it tells you.\n\n`git verify-commit` is the standard exit-code-only signature verification path. Its man page documents the contract: \"Check the GPG signature of the given commit object.\" Its output writes to stderr; its decision lives in the exit code. CI pipelines, pre-commit hooks, and branch-protection bots that gate on commit signatures wrap it with shell:\n\n```bash\nif git verify-commit HEAD; then\n\tdeploy\nelse\n\trefuse\nfi\n```\n\nThe shell condition reads `$?`. The deploy path runs when `$?` is zero. The verifier crashed and returned exit zero; the deploy ran.\n\nThe path that produces this exit code in gitsign is not the `gitsign verify` subcommand. It is the GPG-compatibility mode invoked by the root command with `-v` / `--verify`, the one git itself calls when it shells out to a configured `gpg.program`. The file `internal/commands/root/verify.go` is where that path lives. It contains a line the developer added to the success branch, which has been in the codebase the entire time the bug was:\n\n```go\nfmt.Fprintln(s.Err, \"WARNING: git verify-commit does not verify cert claims. Prefer using `gitsign verify` instead.\") // nolint:errcheck\n```\n\nThe author knew the gpg-compatibility verify path was weaker than the subcommand version. The warning describes a different weakness: the gpg-mode path skips Sigstore claim validation, where the subcommand does it. What the warning confirms in passing is the audience for this code path: tools calling `git verify-commit` and reading the exit code. The warning printed to stderr, which `git verify-commit` swallows by default. The warning ran only on the success branch, the branch the empty-envelope panic never reached.\n\n## fail-open-intercept, three layers deep\n\nThis is [fail-open-intercept](/patterns/fail-open-intercept) in a particularly clean form. The pattern catalog names the shape: a security gate that catches its own failure mode and forwards anyway. Tomcat's `EncryptInterceptor` [catches `GeneralSecurityException` and calls `super.messageReceived(msg)`](/posts/tomcat-encryptinterceptor-fails-open) outside the try. DataEase's `CommunityTokenFilter` catches the JWT verification exception, writes a 401, then calls `filterChain.doFilter()` outside the catch. Admidio's SAML validator returns a translation key on failure that no caller reads. Burst Statistics tests for `WP_Error` and the gate's third return value, `null`, slips past.\n\nGitsign is the Go dialect of the same shape. The gate runs (the verifier function calls into the CMS library). The failure is identified (the runtime raises an out-of-range panic on `certs[0]`). The catch fires (the deferred `recover()` in `Wrap` runs). The narration happens (the panic and stack are printed to `TTYOut`). The forwarding happens (`Wrap` returns nil, `Execute` returns nil, `main` exits 0). And the consumer downstream, `git verify-commit` in shell, treats the verdict it gets as the verdict the gate produced.\n\nWhat's distinctive in this exhibit is that the forwarding lives one stack frame deeper than the others. Tomcat, DataEase, and Admidio all run their catches in the same function that owns the security decision. Gitsign's catch runs in a wrapper that does not know it is wrapping a security check. The wrapper was written for any subcommand, signing or verifying. The author put the recover there to make panics visible in the terminal during interactive use; the recover-as-nil-return choice was made for the sign path's developer-experience benefit and inherited by the verify path's consumers.\n\nThat is the part the pattern catalog now records. A `recover()` in a generic wrapper, written for one subcommand's UX, becomes the second half of a verification bypass for another subcommand whose consumers read exit codes. The fail-open isn't in the verifier and isn't in the wrapper; it's in the composition. The patch closes the composition by making the wrapper assign `retErr` before the defer returns, which is what the function's name promised it was already doing.\n\n## What the CVSS vector says, and what it doesn't\n\nThe CVE-2026-44310 record gives CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L, a 5.4. The vector encodes attacker constraints (network, low complexity, no privileges, user interaction required) and impact (no confidentiality loss, low integrity, low availability). The \"user interaction required\" axis applies because somebody has to push or fetch the malformed commit; the \"integrity low\" rating applies because the attacker controls one bit of trust state, whether `git verify-commit` returns 0 or nonzero.\n\nThat score reads the bug as a verifier crash whose impact is bounded by the workflow that triggers it. The bug it actually is, in the language of the consumers, is \"any commit pushed to a repository whose CI pipeline checks `git verify-commit` is now indistinguishable from a verified commit.\" The CVSS model has no axis for \"the entire purpose of the tool is to make this distinction.\" Sigstore exists to make signed-by-Fulcio-OIDC-identity verifiable on a git commit. The verifier returns the same exit code for that case and for a CMS envelope containing no certificates.\n\nPoC: [advisories/GHSA-7c37-gx6w-8vc5](https://github.com/advisories/GHSA-7c37-gx6w-8vc5)","closing_line":"The verifier panicked. The exit code said verified.","hook_md":"Gitsign is Sigstore's keyless commit-signing tool. The `--verify` code path is the one git itself invokes for `git verify-commit`, the standard exit-code gate behind every CI signature check. From v0.4.0 through v0.14.0, that path read `certs[0]` on a slice it never measured. The CMS spec allows the certificates field to be empty. When it was, the index-out-of-range panic landed in a wrapper that logged it and returned `nil`, `main.go` exited 0, and `git verify-commit` reported green for an envelope that contained no signing identity at all.","post_id":443,"slug":"gitsign-cve-2026-44310-exits-zero-on-empty-cert","title":"CVE-2026-44310: gitsign Exits Zero When the Signature Has No Certificate","type":"initial","unreadable_sentence":"git verify-commit reported green for an envelope that contained no signing identity at all."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawHcrQAKCRDeZjl4jgkQ JjkIAP44b8ZxQXHprcp3i+jCvD61r+aEjAoiW650u+aagaOmygD+PoM8glrMXem3 REXxJTMbrA6ffQ8RUOlcyXWHjLqz/gY= =j1iw -----END PGP SIGNATURE-----