Removing token from the whitelist may cause DoS due to limited USDC amount
The withdraw function only allows withdrawing a USDC version that is currently whitelisted, so if the owner removes a version from the whitelist, the tokens backed by that version can no longer be withdrawn. Holders of the remaining whitelisted version could then drain its balance, leaving other users unable to withdraw.
SpicyMeatball Follow with 0xTheC0der and oakcobalt
Originally disclosed on Code4rena
Submitted by SpicyMeatball, also found by 0xTheC0der and oakcobalt
Users won’t be able to withdraw USDC tokens from asdUSDC.
Proof of Concept
Consider a situation where we have two whitelisted USDC versions 1 and 2:
usdcBalances[usdc1] = 1000
usdcBalances[usdc2] = 500
asdUSDC total supply = 1500
After some time, asdUSDC owner removes usdc2 from the whitelist. It creates a situation where 1500 asdUSDC is only backed by 1000 usdc1 tokens, since it’s no longer possible to withdraw usdc2.
https://github.com/code-423n4/2024-03-canto/blob/main/contracts/asd/asdUSDC.sol#L52
function withdraw(address _usdcVersion, uint256 _amount) external returns (uint256) {
// check whitelist
>> require(whitelistedUSDCVersions[_usdcVersion], "ASDUSDC: USDC version not whitelisted");
// burn tokens
_burn(msg.sender, _amount);
// calculate amount to withdraw
uint256 amountToWithdraw = _amount / (10 ** (this.decimals() - ERC20(_usdcVersion).decimals()));
// check balance
require(usdcBalances[_usdcVersion] >= amountToWithdraw, "ASDUSDC: Not enough USDC balance");
// transfer USDC
usdcBalances[_usdcVersion] -= amountToWithdraw;
SafeERC20.safeTransfer(ERC20(_usdcVersion), msg.sender, amountToWithdraw);
emit Withdrawal(_usdcVersion, amountToWithdraw);
return amountToWithdraw;
}
If former usdc2 holders withdraw their 500 asdUSDC for usdc1, there will be no usdc1 left for other users.
Recommended Mitigation Steps
Consider removing the require block from withdraw function.
- require(whitelistedUSDCVersions[_usdcVersion], "ASDUSDC: USDC version not whitelisted");
dsudit01 (Canto) confirmed and commented:
PR here.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the withdraw function gates on the current whitelist rather than on whether the contract still holds a balance of that version, so delisting strands backing funds.
Impact
Users could be unable to withdraw their asdUSDC because the remaining whitelisted version's balance is drained by others.
What the attacker needed
Owner removes a USDC version from whitelist; contract holds multiple USDC versions
The fix
The require block was removed from the withdraw function, as confirmed by the project's linked pull request.
How it was found
- Two USDC versions are whitelisted, with balances of 1000 and 500 and a total supply of 1500 asdUSDC.
- The owner removes the second version from the whitelist.
- The 500 asdUSDC backed by that version can no longer be withdrawn.
- Holders withdraw their asdUSDC against the first version until its balance is empty.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This contract holds several versions of the USDC stablecoin and gives users a token representing their share. A check in the withdrawal function refuses any version that is not on an approved list, so if the owner removes a version, the money behind it is stuck. Users holding the other version can then take out more than their fair share, and later users find nothing left.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.