Skip to content

fix(aztec-nr): fix OOB index with nonzero offset#21613

Merged
nventuro merged 3 commits intomerge-train/fairiesfrom
fix/note-getter-offset-oob
Mar 17, 2026
Merged

fix(aztec-nr): fix OOB index with nonzero offset#21613
nventuro merged 3 commits intomerge-train/fairiesfrom
fix/note-getter-offset-oob

Conversation

@nchamo
Copy link
Contributor

@nchamo nchamo commented Mar 16, 2026

I simply asked Claude to go through our code and find bugs, and it found this

Summary

  • Fixes an out-of-bounds array access in extract_property_value_from_selector when PropertySelector.offset > 0. The formula 31 + offset - i produces index >= 32 at i = 0; corrected to 31 - offset - i.
  • Adds a regression test exercising a nonzero offset.

Note

The bug was dormant -- every PropertySelector in the codebase uses offset: 0 (the macro hardcodes it). But anyone trying to use sub-field byte selection would hit a runtime panic.

@nchamo nchamo requested a review from nventuro as a code owner March 16, 2026 17:06
@nchamo nchamo self-assigned this Mar 16, 2026
@nchamo nchamo changed the title fix(aztec-nr): fix OOB index in PropertySelector with nonzero offset fix(aztec-nr): fix OOB index with nonzero offset Mar 16, 2026
@nchamo nchamo requested a review from mverzilli March 16, 2026 17:30
unconstrained fn extract_property_value_full_field_is_identity() {
let packed = [12345 as Field];
let selector = PropertySelector { index: 0, offset: 0, length: 32 };
let result = super::extract_property_value_from_selector(packed, selector);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import the fn instead of using super:: in each test

@nchamo nchamo requested review from mverzilli and nventuro March 17, 2026 19:27
@nventuro nventuro merged commit 3714938 into merge-train/fairies Mar 17, 2026
11 checks passed
@nventuro nventuro deleted the fix/note-getter-offset-oob branch March 17, 2026 19:40
AztecBot pushed a commit that referenced this pull request Mar 17, 2026
I simply asked Claude to go through our code and find bugs, and it found
this

## Summary
- Fixes an out-of-bounds array access in
`extract_property_value_from_selector` when `PropertySelector.offset >
0`. The formula `31 + offset - i` produces index >= 32 at `i = 0`;
corrected to `31 - offset - i`.
- Adds a regression test exercising a nonzero offset.

## Note
The bug was dormant -- every `PropertySelector` in the codebase uses
`offset: 0` (the macro hardcodes it). But anyone trying to use sub-field
byte selection would hit a runtime panic.
@AztecBot
Copy link
Collaborator

✅ Successfully backported to backport-to-v4-next-staging #21654.

github-merge-queue bot pushed a commit that referenced this pull request Mar 18, 2026
BEGIN_COMMIT_OVERRIDE
fix(stdlib): accept null return_type for void Noir functions (#21647)
feat!: make AES128 decrypt oracle return Option (#21696)
fix(aztec-nr): fix OOB index with nonzero offset (#21613)
feat!: include init_hash in private initialization nullifier to prevent
privacy leak (#21427)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants