1
0
mirror of synced 2026-10-24 12:59:22 +03:00
Files
Ashvin 6a83f9a208 fix(verify): don't panic on a bundle entry with no hash (#5127)
* fix(verify): don't panic on a bundle entry with no hash

bundleHash dereferenced the algorithm and value of a Rekor entry hash
without checking them. The hash is optional in all five of these schemas,
and unmarshalling does not always populate it: a rekord v0.0.1 entry that
carries data.content but no data.hash, and an intoto v0.0.2 entry whose
envelope payload is empty, both unmarshal cleanly with a nil hash.

The body comes from the bundle attached to the signature, so it is read
from the registry before the certificate has been validated and before
the signature has been checked. A body that omits the hash therefore
crashes the verifier rather than failing verification.

Check each level before dereferencing it and return an error instead.

Signed-off-by: ashvinctrl <sharmaashvin27@gmail.com>

* fix(verify): trim comments in bundleHash

Drop the hashFields doc comment and cut the bundleHash comment down to the
part that is not visible from the code: the Rekor models mark the hash fields
required, but per-type validation does not always enforce it.

Signed-off-by: ashvinctrl <sharmaashvin27@gmail.com>

* test(verify): cover every bundleHash entry type and hashFields

Add success cases for all five entry types, missing-hash cases for each
type (including partial hash objects, which Rekor rejects before the
switch), and a direct test of hashFields for a nil algorithm or value.

Signed-off-by: ashvinctrl <sharmaashvin27@gmail.com>

---------

Signed-off-by: ashvinctrl <sharmaashvin27@gmail.com>
2026-10-02 10:42:03 -07:00
..