//nefariousplan

CVE-2026-44310: gitsign Exits Zero When the Signature Has No Certificate

vendor

pattern

cve

proof of concept

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.

The CMS certificates field is optional. gitsign's verifier was not.

CMS/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.

gitsign'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:

// X509Certificates gets the certificates, assuming that they're X.509 encoded.
func (sd *SignedData) X509Certificates() ([]*x509.Certificate, error) {
	// Certificates field is optional. Handle missing value.
	if sd.Certificates == nil {
		return nil, nil
	}

	// Empty set
	if len(sd.Certificates) == 0 {
		return []*x509.Certificate{}, nil
	}

	certs := make([]*x509.Certificate, 0, len(sd.Certificates))
	for _, raw := range sd.Certificates {
		...
	}

	return certs, nil
}

Two 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."

The gitsign caller, in pkg/git/verifier.go from v0.4.0 through v0.14.0, is what CVE-2026-44310 names:

// Generate verification options.
certs, err := sd.GetCertificates()
if err != nil {
	return nil, fmt.Errorf("error getting signature certs: %w", err)
}
cert := certs[0]

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.

The patch is two added lines, before the existing read:

 	certs, err := sd.GetCertificates()
 	if err != nil {
 		return nil, fmt.Errorf("error getting signature certs: %w", err)
 	}
+	if len(certs) == 0 {
+		return nil, fmt.Errorf("no certificates found in signature")
+	}
 	cert := certs[0]

The 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.

That 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.

The wrapper's recover ran. Its return value did not.

A 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.

What makes it a bypass is internal/io/streams.go's Wrap() function, which every gitsign subcommand runs inside. The pre-patch shape:

func (s *Streams) Wrap(fn func() error) error {
	// Log any panics to ttyout, since otherwise they will be lost to os.Stderr.
	defer func() {
		if r := recover(); r != nil {
			fmt.Fprintln(s.TTYOut, r, string(debug.Stack())) // nolint:errcheck
		}
	}()

	if err := fn(); err != nil {
		fmt.Fprintln(s.TTYOut, err) // nolint:errcheck
		return err
	}
	return nil
}

Walk this carefully because it is the load-bearing failure.

The 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.

After 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.

The 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.

The patch is six tokens of Go:

-func (s *Streams) Wrap(fn func() error) error {
+func (s *Streams) Wrap(fn func() error) (retErr error) {
 	// Log any panics to ttyout, since otherwise they will be lost to os.Stderr.
 	defer func() {
 		if r := recover(); r != nil {
 			fmt.Fprintln(s.TTYOut, r, string(debug.Stack())) // nolint:errcheck
+			retErr = fmt.Errorf("panic: %v", r)
 		}
 	}()

A named return value, and an assignment inside the defer. The wrapper now does what its name implied.

That 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.

main.go has one exit-code condition. It was false.

func main() {
	cfg, err := config.Get()
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(2)
	}

	rootCmd := root.New(cfg)

	if err := rootCmd.Execute(); err != nil {
		os.Exit(1)
	}
}

rootCmd.Execute() returns whatever the root command's RunE returned. The root command's RunE is:

return s.Wrap(func() error {
	switch {
	...
	case o.FlagVerify:
		return commandVerify(o, s, args...)
	...
	}
})

In 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.

Three 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."

git verify-commit is the gate. Exit zero is the only thing it tells you.

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:

if git verify-commit HEAD; then
	deploy
else
	refuse
fi

The shell condition reads $?. The deploy path runs when $? is zero. The verifier crashed and returned exit zero; the deploy ran.

The 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:

fmt.Fprintln(s.Err, "WARNING: git verify-commit does not verify cert claims. Prefer using `gitsign verify` instead.") // nolint:errcheck

The 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.

fail-open-intercept, three layers deep

This is 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) 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.

Gitsign 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.

What'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.

That 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.

What the CVSS vector says, and what it doesn't

The 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.

That 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.

PoC: advisories/GHSA-7c37-gx6w-8vc5

The verifier panicked. The exit code said verified.