Closed sherlock-admin4 closed 8 months ago
2 comment(s) were left on this issue during the judging contest.
WangAudit commented:
iBalance and fBalance are checked right before and after the defiSwap; therefore; I can't see a way that those values can be manipulated within the function execution
takarez commented:
invalid
turvec
high
Address initiating the swap can manipulate transfers to their favor due to overriding oAmount without adjusting tAmount
Summary
Address initiating the swap can manipulate transfers to their favor due to overriding oAmount without adjusting tAmount
Vulnerability Detail
When converting to stablecoin (EXYZ) using the
stablecoinSwap()
function, they agree to transfer an amount (oAmount
) and get minted an amount of the target stablecoin (tAmount
).convertToEXYZ
However, notice that the oAmount can be entirely overridden if there is a slight change in the contract balance after a defiSwap which makes an external call to the address initiating the swap:
defiSwap
The issue here is that while this oAmount gets totally overridden to whatever was the balance difference, the tAmount to be minted for the address initiating the swap remains the same regardless. This means the address initiating the swap can deliberately transfer just 1 wei worth of amount to the contract during the external call which will end up being the only amount they would have to transfer and get minted the same tAmount, causing them to manipulate the transfer and the stablecoin accounting and minting in general
Impact
Address initiating the swap can manipulate transfers to their favor and also affect the stablecoin accounting and minting in general
Code Snippet
https://github.com/sherlock-audit/2024-02-telcoin-platform-audit-update/blob/main/telcoin-contracts/contracts/swap/AmirX.sol#L91
Tool used
Manual Review
Recommendation
Consider if tAmount should be adjusted as well if oAmount gets overridden or if it's to sum the balance difference to the already agreed upon oAmount rather than totally overriding it.