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

Use modulo instead of and operation to validate the proof size #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mininny
Copy link
Collaborator

@mininny mininny commented Dec 10, 2024

Description

The slow implementation loads the _proof length from calldata and checks that this length is a multiple of 60.

However, this check uses a logical AND which may lead to accepting invalid values that are not multiple of 60.

	if and(b32asBEWord(calldataload(shortToU64(uint16(stateContentOffset)+paddedStateSize))), shortToU256(60-1)) != (U256{}) {

Moreover, the check is insufficient. _proof is expected to be a multiple of 60 * 32, however only the fact that it is a multiple of 60 is checked.

The logical AND check should be replaced with a modulo operation to ensure that it is a multiple of 32 * 60.

@mininny mininny requested review from clabby and ImTei December 13, 2024 06:53
@BlocksOnAChain BlocksOnAChain added the Audit finding grouping for our audit findings label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audit finding grouping for our audit findings
Projects
Development

Successfully merging this pull request may close these issues.

2 participants