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

Redundant require statements in Auction:purchaseArbitrageTokens #108

Open
code423n4 opened this issue Nov 29, 2021 · 1 comment
Open

Redundant require statements in Auction:purchaseArbitrageTokens #108

code423n4 opened this issue Nov 29, 2021 · 1 comment
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

loop

Vulnerability details

When invoking purchaseArbitrageTokens() is will first check whether the auction is active using:

require(auctionActive(currentAuctionId), "No auction running");

auctionActive() checks for the following things:

auction.active && now >= auction.startingTime;

As a result the require statement will fail if either !auction.active or now < auction.startingTime.

Later on in purchaseArbitrageTokens() two more require statements will check the same thing:

require(auction.startingTime <= now, "Auction hasn't started yet");
(...)
 require(auction.active == true, "Auction is not active");

These will always pass if auctionActive(currentAuctionId) is true and never be reached if it is false, making them redundant.

Proof of Concept

Recommended Mitigation Steps

Remove redundant require statements

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 29, 2021
code423n4 added a commit that referenced this issue Nov 29, 2021
@0xScotch 0xScotch added duplicate This issue or pull request already exists sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") and removed duplicate This issue or pull request already exists labels Dec 8, 2021
@GalloDaSballo
Copy link
Collaborator

I agree that some checks are redundant, would recommend the sponsor to rewrite the checks to make them simpler and not reduntant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants