Skip to content

Verify against raw git object bytes#802

Merged
wlynch merged 2 commits intosigstore:mainfrom
wlynch:git-object-parse
May 6, 2026
Merged

Verify against raw git object bytes#802
wlynch merged 2 commits intosigstore:mainfrom
wlynch:git-object-parse

Conversation

@wlynch
Copy link
Copy Markdown
Member

@wlynch wlynch commented May 6, 2026

Summary

go-git's loose object parser uses last-wins semantics for duplicate singleton headers (tree, author, committer, etc.), while git-core uses first-wins. An attacker can craft a commit or tag whose raw bytes hash to one set of contents under git-core but re-encode through go-git to a different signed payload, letting a legitimate signature verify against attacker-controlled bytes.

Replace the go-git decode + EncodeWithoutSignature path with SplitCommit and SplitTag, which operate directly on the object-database bytes (the same bytes git-core feeds its verifier) and reject objects with structural ambiguities — duplicate singleton headers, duplicate gpgsig, malformed gpgsig continuations. ObjectHash now reassembles via JoinCommit/JoinTag so the recorded hash matches git-core.

Release Note

  • Fixes object parsing and validation for invalid Git objects (multiple/conflicting headers)

Documentation

n/a

wlynch added 2 commits April 30, 2026 22:10
go-git's loose object parser uses last-wins semantics for duplicate
singleton headers (tree, author, committer, etc.), while git-core uses
first-wins. An attacker can craft a commit or tag whose raw bytes hash
to one set of contents under git-core but re-encode through go-git to a
different signed payload, letting a legitimate signature verify against
attacker-controlled bytes.

Replace the go-git decode + EncodeWithoutSignature path with SplitCommit
and SplitTag, which operate directly on the object-database bytes (the
same bytes git-core feeds its verifier) and reject objects with
structural ambiguities — duplicate singleton headers, duplicate gpgsig,
malformed gpgsig continuations. ObjectHash now reassembles via
JoinCommit/JoinTag so the recorded hash matches git-core.

Signed-off-by: Billy Lynch <billy@chainguard.dev>
@wlynch wlynch force-pushed the git-object-parse branch from 657db62 to 4ea91f4 Compare May 6, 2026 14:47
@wlynch wlynch requested review from adityasaky and cpanato May 6, 2026 14:47
@wlynch wlynch changed the title Git object parse Verify against raw git object bytes May 6, 2026
@gittuf-app-beta
Copy link
Copy Markdown

Observed review from cpanato+4115580 (@cpanato)

@wlynch
Copy link
Copy Markdown
Member Author

wlynch commented May 6, 2026

Merging w/o E2E because github actions outage has broken the Sigstore beacon token workflow, blocking the tests.

@wlynch wlynch merged commit 3c84d87 into sigstore:main May 6, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants