Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix default implementation on FixedVector #2264

Closed
wants to merge 1 commit into from

Conversation

paulhauner
Copy link
Member

@paulhauner paulhauner commented Mar 17, 2021

Issue Addressed

NA

Proposed Changes

Whilst hacking on something I noticed that the default implementation of FixedVector can violate the length constraint!

E.g., let v: FixedVector<u8; U4> = <_>::default() would create a fixed vector with length 0, even though it promises to always have length 4! This causes SSZ deserialization to fail and probably other things too.

This isn't a security risk as it can't be triggered externally, however it's a foot gun for LH devs.

Additional Info

NA

@paulhauner paulhauner added the ready-for-review The code is ready for review label Mar 17, 2021
@paulhauner paulhauner added the bug Something isn't working label Mar 17, 2021
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

Nice catch!

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Mar 17, 2021
@paulhauner
Copy link
Member Author

bors r+

@paulhauner paulhauner added bug Something isn't working and removed bug Something isn't working labels Mar 22, 2021
bors bot pushed a commit that referenced this pull request Mar 22, 2021
## Issue Addressed

NA

## Proposed Changes

Whilst hacking on something I noticed that the default implementation of `FixedVector` can violate the length constraint!

E.g., `let v: FixedVector<u8; U4> = <_>::default()` would create a fixed vector with length 0, even though it promises to *always* have length 4! This causes SSZ deserialization to fail and probably other things too.

This isn't a security risk as it can't be triggered externally, however it's a foot gun for LH devs.

## Additional Info

NA
@bors bors bot changed the title Fix default implementation on FixedVector [Merged by Bors] - Fix default implementation on FixedVector Mar 22, 2021
@bors bors bot closed this Mar 22, 2021
@michaelsproul michaelsproul deleted the default-fixed-vec branch March 22, 2021 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants