fix: avoid hash collision in caveat context#3065
Merged
miparnisari merged 3 commits intoApr 22, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3065 +/- ##
==========================================
- Coverage 76.05% 76.01% -0.03%
==========================================
Files 486 486
Lines 59456 59440 -16
==========================================
- Hits 45211 45178 -33
- Misses 10972 10981 +9
- Partials 3273 3281 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
378ffad to
cef36b0
Compare
miparnisari
reviewed
Apr 22, 2026
41d0057 to
d38c5f4
Compare
a688077 to
1402616
Compare
miparnisari
reviewed
Apr 22, 2026
|
|
||
| // TestBulkCheckCaveatContextCollision is a regression test for an issue with | ||
| // caveat hash collision. | ||
| func TestBulkCheckCaveatContextCollision(t *testing.T) { |
Contributor
There was a problem hiding this comment.
why do we need an end to end test for something that could easily be encoded at a unit test level - compare the hashing of {"x": ["a", [], "b"]} and {"x": [["a"], "b"]} and ensures they are not the same?
the test you wrote, if it fails, tells us very little about where the problem could be.
Co-authored-by: Maria Ines Parnisari <maria.ines.parnisari@authzed.com>
1402616 to
23b7171
Compare
miparnisari
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Someone pointed out to us that if you use a nested list of lists in a caveat context, it was possible under our current serialization and hashing logic to have a serialization collision and therefore a dispatch cache hash collision.
This fixes that by using deterministic proto marshalling of the caveat context Struct object.
Changes
context_hash.goto use deterministic marshallinghashableContexttohashableContextStringto satisfy the interfaceTesting
Review