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

Lack of SAFEAPPROVE(o) in the INITIALIZER which can only be can only be called once #6

Closed
code423n4 opened this issue Jun 7, 2022 · 1 comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) invalid This doesn't seem right

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashBase.sol#:~:text=assetToken.safeApprove(address(NotionalV2)%2C%20type(uint256).max)%3B
https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashBase.sol#:~:text=underlyingToken.safeApprove(address(NotionalV2)%2C%20type(uint256).max)%3B

Vulnerability details

Impact

The users won't be able to go back to initialize for that specific fCash asset once the safeApprove reverts because the safeApprove() has a non-zero value.

Proof of Concept

https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashBase.sol#:~:text=assetToken.safeApprove(address(NotionalV2)%2C%20type(uint256).max)%3B
https://github.com/code-423n4/2022-06-notional-coop/blob/main/notional-wrapped-fcash/contracts/wfCashBase.sol#:~:text=underlyingToken.safeApprove(address(NotionalV2)%2C%20type(uint256).max)%3B

When using deprecated function it could leas to unintended reverts and since its the initializer function you get locked out and can't call it again. More understanding about this issue could be link here: OpenZeppelin/openzeppelin-contracts#2219

Tools Used

Manuel Review

Recommended Mitigation Steps

Approve with a zero amount first before setting the actual amount. Consider use safeIncreaseAllowance and safeDecreaseAllowance.

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Jun 7, 2022
code423n4 added a commit that referenced this issue Jun 7, 2022
@jeffywu jeffywu added the disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) label Jun 15, 2022
@jeffywu
Copy link
Collaborator

jeffywu commented Jun 15, 2022

It's not clear how there would be a non zero allowance on initialization which can only be called once.

@gzeoneth gzeoneth added the invalid This doesn't seem right label Jun 26, 2022
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 Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants