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

Token is not ERC20 compliant (potential DOS of other contracts by oracle) #6

Closed
code423n4 opened this issue Oct 28, 2021 · 1 comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working 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")

Comments

@code423n4
Copy link
Contributor

Handle

TomFrench

Vulnerability details

Impact

calling transferFrom with amount will reduce the callers allowance by an amount other than amount.
This under some circumstances can result in funds being locked in external contracts which perform exact approvals.

Proof of Concept

As a rebasing wrapper for ibBTC, wibBTC's transferFrom converts the passed amount into terms of the underlying shares to perform the transfer. approve however does not do this which opens up a potential issue.

// allowance[spender] = 0
wibBTC.approve(spender, amount)
// allowance[spender] = amount
wibBTC.approve(spender, recipient, amount)
// allowance[spender] = amount - amount.mul(1e18).div(pricePerShare)

As pricePerShare is expected to be greater than 1 then this is unlikely to cause any major problems - the worst that will happen is there's some unexpected leftover allowance and we don't get an expected gas refund.

However should pricePerShare < 1 (through loss of assets or a malicious oracle) then this code will start reverting and could potentially lock some wibBTC in contracts which rely on this behaviour until pricePerShare > 1 is once again true.

Recommended Mitigation Steps

Override approve function and add similar logic to that in transfer, update transferFrom to reduce allowance by amount rather than amountInShares

@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 Oct 28, 2021
code423n4 added a commit that referenced this issue Oct 28, 2021
@dapp-whisperer dapp-whisperer added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Nov 8, 2021
@0xleastwood 0xleastwood added 3 (High Risk) Assets can be stolen/lost/compromised directly duplicate This issue or pull request already exists and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Dec 4, 2021
@0xleastwood
Copy link
Collaborator

#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working 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")
Projects
None yet
Development

No branches or pull requests

3 participants