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

approveUnderlying isn't safe #260

Closed
code423n4 opened this issue Sep 22, 2021 · 1 comment
Closed

approveUnderlying isn't safe #260

code423n4 opened this issue Sep 22, 2021 · 1 comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Warden finding disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate Another warden found this issue 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

0xsanson

Vulnerability details

Impact

In Basket.sol, approveUnderlying is used to approve tokens to be spent by the Auction.
The current implementation uses a simple approve function, instead of the safer safeApprove. Also it's recommended to have an approve to zero first, since the allowance could be already positive and some tokens (e.g. USDT) wouldn't work in this case.

Proof of Concept

https://github.com/code-423n4/2021-09-defiProtocol/blob/main/contracts/contracts/Basket.sol#L226

Tools Used

editor

Recommended Mitigation Steps

Consider writing

IERC20(tokens[i]).safeApprove(spender, 0);
IERC20(tokens[i]).safeApprove(spender, type(uint256).max);
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Warden finding labels Sep 22, 2021
code423n4 added a commit that referenced this issue Sep 22, 2021
@frank-beard frank-beard added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Sep 28, 2021
@GalloDaSballo
Copy link
Collaborator

Duplicate of #35

@GalloDaSballo GalloDaSballo marked this as a duplicate of #35 Dec 19, 2021
@GalloDaSballo GalloDaSballo added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value duplicate Another warden found this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Warden finding disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate Another warden found this issue 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