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

[audit] #12 : Same address can use multiple discounts through reentrancy #46

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

stevieraykatz
Copy link
Collaborator

Reorder transactions to prevent reentrancy attack.

From Spearbit:

Description
The discountRegistrants mapping is used to keep track of which addresses have already used a discount and block them from registering with another or the same discount again.

The mapping is checked in the validDiscount modifier and updated after _registration function. The user can specify a custom resolver address in the request on which multicallWithNodeCheck is called in the _registration function. This can be used to reenter the contract and use the same or a different discount before the discountRegistrants updated.

Note that as the validDiscounts checks the discount eligbility against the msg.sender the specified resolver must be the address that is eligible for the discount. This could be the case for smart contract wallets that can provide the needed multicallWithNodeCheck function to perform this exploit.

Recommendation
Move the update to the discountRegistrants state variable before doing the call to the resolver. This could be just before the _register statement or even in the validDiscount modifier.

@stevieraykatz stevieraykatz merged commit ac6478e into main Jul 9, 2024
1 of 3 checks passed
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.

1 participant