Open code423n4 opened 1 year ago
minhquanym marked the issue as duplicate of #179
minhquanym marked the issue as duplicate of #813
minhquanym marked the issue as not a duplicate
minhquanym marked the issue as primary issue
0xRektora marked the issue as disagree with severity
Should be medium
. Inconvenient for sure but user funds are not at risk.
0xRektora marked the issue as sponsor confirmed
dmvt changed the severity to 2 (Med Risk)
dmvt marked the issue as selected for report
Lines of code
https://github.com/Tapioca-DAO/tapiocaz-audit/blob/bcf61f79464cfdc0484aa272f9f6e28d5de36a8f/contracts/Balancer.sol#L197-L208 https://github.com/Tapioca-DAO/tapiocaz-audit/blob/bcf61f79464cfdc0484aa272f9f6e28d5de36a8f/contracts/tOFT/mTapiocaOFT.sol#L141-L146
Vulnerability details
Impact
The
mTapiocaOFT.sol
contract is a special TOFT implementation that can balance its supply. The supply of the token is balanced across chains by using Stargate. When balancing amTapiocaOFT
the caller needs to provide some native token to pay the Stargate fees.The issue with the current implementation is that the fee check for
mTapiocaOFTs
that represent native tokens is incorrect, forcing the admin to pay for the rebalance amount plus the fee.Proof of Concept
A
mTapiocaOFT
can be rebalanced if the owner of an approved balancer contract callsrebalance
inBalancer.sol
. As mentioned above, the rebalance operation uses Stargate to send tokens across chain. In order to pay the Stargate fees, some ETH (i.e. a native token) needs to be passes with any calls to Stargate and thus therebalance
method needs to be payable (which it is). The issues comes where the value passed to the call is validated:As you can see, for native tokens the check is
(msg.value <= _amount)
. However, we're already extracting the native token when callingextractUnderlying
:So in order to rebalance amount
x
across chain, theBalancer.sol
owner would have to callrebalance
withmsg.value = x + fee
, and the actual amount being rebalanced would be2 * x
.However, as I've highlighted in another issue, the underlying call will luckily fail, but this is a distinct issue that should also be resolved.
Tools Used
Manual review
Recommended Mitigation Steps
The fee check should be identical for both native and non native
mTapiocaOFT
representations:Assessed type
Invalid Validation