Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Kirkeelee - AlchemicTokenV2Base.sol deviates from xERC20 (EIP-7281) standard in the implementation of the burn() function. #59

Closed
github-actions bot opened this issue Apr 22, 2024 · 0 comments
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout

Comments

@github-actions
Copy link

github-actions bot commented Apr 22, 2024

Kirkeelee

medium

AlchemicTokenV2Base.sol deviates from xERC20 (EIP-7281) standard in the implementation of the burn() function.

Summary

The protocol aims to upgrade their alAssets contracts by implementing xERC20 (EIP-7281) standard with AlchemicTokenV2Base.sol while preserving the storage layout of the previous version (CrossChainCanonicalBase.sol). In doing so, the modified function burn(address account, uint256 amount) leads to deviation from the xERC20 and opens up attack vectors.

Vulnerability Detail

The rules around the burn function per the xERC20 are the following:

  • burn MUST check that the caller's current available limit is greater than or equal to _amount
  • burn MUST decrease the supply of the underlying ERC-20 by _amount and reduce the current available limit

Per the requirements of the xERC20 (EIP-7281) standard the function burn() "Can only be called by a bridge (whitelisted minter).
If you inspect the burn() function in AlchemicTokenV2Base.sol several issues arise:

function burn(address account, uint256 amount) external {
   if (msg.sender != account) {
     uint256 newAllowance = allowance(account, msg.sender) - amount;
     _approve(account, msg.sender, newAllowance);
   }

   // If bridge is registered check limits and update accordingly.
   if (xBridges[msg.sender].burnerParams.maxLimit > 0) {
     uint256 currentLimit = burningCurrentLimitOf(msg.sender);
     if (amount > currentLimit) revert IXERC20.IXERC20_NotHighEnoughLimits();
     _useBurnerLimits(msg.sender, amount);
   }

   _burn(account, amount);
 }

First, anyone with allowance(account, msg.sender)>=amount can call it and successfully burn the amount of tokens. The check if (xBridges[msg.sender].burnerParams.maxLimit > 0) will be skipped if the msg.sender is not registered/whitelisted since xBridges[msg.sender].burnerParams.maxLimit will be 0.

Secondly, the burnt amount is not registered (not deducted from the available limit) with burnerParams if the caller is not registered/whitelisted by skipping the xBridges[msg.sender].burnerParams.maxLimit > 0 check. These leads to possibility of the caller to avoid that limitation and may be used by attackers.

Overall whole concept of the xERC20 (EIP-7281) standard such as assigning/whitelisting certain bridges to mint/burn functions and limiting the amount that can be minted/burned per bridge(to set the limit to 0 in case the bridge contract is hacked or to have a certain balance of tokens in each side of the bridge) will be violated with the current implementation of the function burn().

Impact

Noncompliance with the EIP and possible loss of user funds depending on the other integrations of asset burning.

Code Snippet

https://github.com/sherlock-audit/2024-04-alchemix/blob/main/v2-foundry/src/AlchemicTokenV2Base.sol#L190-L204

Tool used

Manual Review

Recommendation

Add onlyWhitelisted modifier to the burn() function.

Duplicate of #102

@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue labels Apr 22, 2024
@sherlock-admin4 sherlock-admin4 changed the title Lucky Black Pheasant - AlchemicTokenV2Base.sol deviates from xERC20 (EIP-7281) standard in the implementation of the burn() function. Kirkeelee - AlchemicTokenV2Base.sol deviates from xERC20 (EIP-7281) standard in the implementation of the burn() function. Apr 30, 2024
@sherlock-admin4 sherlock-admin4 added the Reward A payout will be made for this issue label Apr 30, 2024
@WangSecurity WangSecurity added Excluded Excluded by the judge without consulting the protocol or the senior and removed Medium A valid Medium severity issue labels May 14, 2024
@sherlock-admin2 sherlock-admin2 added Non-Reward This issue will not receive a payout and removed Reward A payout will be made for this issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

3 participants