You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Insufficient checks in AmirX::swap will allow change of protocol's state without verification
Summary
AmirX::swap function validates stablecoin swap parameters, performs swaps, and handles DeFi interactions based on provided DefiSwap details. Insufficient checks in the function allow the StablecoinHandler::_stablecoinSwap function to be called without verification from StablecoinHandler::_verifyStablecoinSwap causing potential burning of stablecoins below the minimum limit or minting of stablecoins above the maximum limit
} else {
// if stablecoin swap_stablecoinSwap(wallet, ss);
// if only stablecoin swapif (defi.walletData.length!=0) _defiSwap(wallet, defi);
}
The _stablecoinSwap function will get called potentially leading to incorrect burning or minting of stablecoins if the function parameters are set incorrectly.
Internal pre-conditions
The directional parameter in the AmirX::swap function should be set to false
The ss.destination parameter must be address(0)
ss.oAmount could be set such that when burning from the origin stablecoin supply -> totalSupply < getMinLimit()
ss.tAmount could be set such that when minting to the origin stablecoin supply -> totalSupply > getMaxLimit()
External pre-conditions
No response
Attack Path
SWAPPER_ROLE calls the AmirX::swap function with ss.destination = address(0), directional = false, unsafess.oAmount and ss.tAmount
_verifyStablecoinSwap() which checks the min and max supply gets skipped due to if (ss.destination != address(0))
directional = false => the else block will get executed
_stablecoinSwap function in the else block will get called unsafely burning or minting stablecoins potentially disrupting the total supply invariants
Impact
The explained issue could unsafely modify the stablecoins' total supply such that it exceeds the min and max limits.
PoC
No response
Mitigation
Adding a check would be sufficient
function swap(
...
) external payable onlyRole(SWAPPER_ROLE) whenNotPaused {
if (directional) {
...
} else {
- _stablecoinSwap(wallet, ss);+ if (ss.destination != address(0)) _stablecoinSwap(wallet, ss);
if (defi.walletData.length != 0) _defiSwap(wallet, defi);
}
}
The text was updated successfully, but these errors were encountered:
sherlock-admin3
changed the title
Magic Daisy Bison - Insufficient checks in AmirX::swap will allow change of protocol's state without verification
frndz0ne - Insufficient checks in AmirX::swap will allow change of protocol's state without verification
Nov 17, 2024
frndz0ne
High
Insufficient checks in
AmirX::swap
will allow change of protocol's state without verificationSummary
AmirX::swap
function validates stablecoin swap parameters, performs swaps, and handles DeFi interactions based on provided DefiSwap details. Insufficient checks in the function allow theStablecoinHandler::_stablecoinSwap
function to be called without verification fromStablecoinHandler::_verifyStablecoinSwap
causing potential burning of stablecoins below the minimum limit or minting of stablecoins above the maximum limitRoot Cause
Here in
AmirX::swap
ifss.destination
is not set (i.e.address(0)
) the_verifyStablecoinSwap
function (responsible for checking the values for correct burning or minting of stablecoins) will be skipped due to the if statement. Next, ifdirectional = false
the else block will get executed:https://github.com/sherlock-audit/2024-11-telcoin/blob/b9c751b59e78a7123a636e31ecafc9147046f190/telcoin-audit/contracts/swap/AmirX.sol#L96
The
_stablecoinSwap
function will get called potentially leading to incorrect burning or minting of stablecoins if the function parameters are set incorrectly.Internal pre-conditions
directional
parameter in theAmirX::swap
function should be set to falsess.destination
parameter must beaddress(0)
ss.oAmount
could be set such that when burning from the origin stablecoin supply -> totalSupply <getMinLimit()
ss.tAmount
could be set such that when minting to the origin stablecoin supply -> totalSupply >getMaxLimit()
External pre-conditions
No response
Attack Path
SWAPPER_ROLE
calls theAmirX::swap
function withss.destination = address(0)
,directional = false
, unsafess.oAmount
andss.tAmount
_verifyStablecoinSwap()
which checks the min and max supply gets skipped due toif (ss.destination != address(0))
directional = false
=> the else block will get executed_stablecoinSwap
function in the else block will get called unsafely burning or minting stablecoins potentially disrupting the total supply invariantsImpact
The explained issue could unsafely modify the stablecoins' total supply such that it exceeds the min and max limits.
PoC
No response
Mitigation
Adding a check would be sufficient
The text was updated successfully, but these errors were encountered: