The buy function in the Auction.sol contract allows users to purchase tokens, but it contains a vulnerability that can lead to a potential denial of service (DoS) attack. Specifically, a malicious actor can exploit this by buying a very small amount (e.g., 1 wei) of tokens before a legitimate user's transaction to buy all the remaining amount gets through.
The vulnerability arises from the check:
While this ensures that a user cannot buy more than the available tokens, it can also be used maliciously to prevent legitimate users to buy the remaining amount of ZENO tokens.
This issue could result in a denial of service for legitimate buyers. This would undermine the auction's purpose, causing failed transaction for legitimate buyers.
Manual Code Review
To resolve this issue, the buy function should be modified so that it automatically changes the amount to state.totalRemaining. Specifically, if a user attempts to purchase more than the total remaining tokens, they should instead be allowed to buy the remaining amount. This can be achieved by adjusting the amount to match the state.totalRemaining if the requested amount exceeds the available tokens.
Suggested change to the buy function:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.