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

fix: batcher nonce verification order in handle_message function #864

Conversation

NicolasRampoldi
Copy link
Contributor

@NicolasRampoldi NicolasRampoldi commented Aug 26, 2024

Closes #1081

Description

  • This PR refactors the message handling process to address the security concerns detailed in the audit.
  • To achieve this, it does the following:
    1. Check the nonce before verifying the proof in both handle_message and handle_nonpaying_msg.
    2. Separate nonce checking and incrementing operations to ensure atomicity.
    3. Improve error handling and messaging for invalid nonces and proofs.

To Test

  • Test full flow with paying and non-paying address. Make sure everything is working correctly.

@NicolasRampoldi NicolasRampoldi self-assigned this Aug 26, 2024
Copy link
Contributor

@MauroToscano MauroToscano left a comment

Choose a reason for hiding this comment

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

User can submit a transaction with the same nonce while the proofs are verifying and this could end up in an invalid state. The nonce needs to be blocked while this process is going.

@NicolasRampoldi
Copy link
Contributor Author

User can submit a transaction with the same nonce while the proofs are verifying and this could end up in an invalid state. The nonce needs to be blocked while this process is going.

Solved in aff5aac

@entropidelic
Copy link
Contributor

it seems like when a createNewTask transaction is reverted, the nonce is set to an invalid state and then all proofs sent with that address get an invalid nonce error.
To replicate, try sending two bursts of the same proof. For example:

make batcher_send_risc0_burst

when the transaction is reverted because of the repeated merkle root, you should not be able to send any more proofs with that address

@NicolasRampoldi
Copy link
Contributor Author

it seems like when a createNewTask transaction is reverted, the nonce is set to an invalid state and then all proofs sent with that address get an invalid nonce error. To replicate, try sending two bursts of the same proof. For example:

make batcher_send_risc0_burst

when the transaction is reverted because of the repeated merkle root, you should not be able to send any more proofs with that address

Solved in ea00344. I added a condition that thought was necessary but it didn't make sense

…handle_message-function

# Conflicts:
#	batcher/aligned-batcher/src/lib.rs
Co-authored-by: Tatu <65305492+taturosati@users.noreply.github.com>
…in-handle_message-function

# Conflicts:
#	batcher/aligned-batcher/src/lib.rs
@uri-99
Copy link
Contributor

uri-99 commented Sep 25, 2024

Being solved in #1087 and 'refactor-user-states'

@uri-99 uri-99 closed this Sep 25, 2024
@MauroToscano MauroToscano deleted the 861-fix-batcher-nonce-verification-order-in-handle_message-function branch January 2, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix (batcher): nonce verification order in handle_message function
5 participants