Closed code423n4 closed 1 year ago
kirk-baird marked the issue as primary issue
This does not seem to be a contract bug at all. It is similar to saying a user can send unexpected funds to a contract and not get anything in return. That is the expected behavior.
The user should program their callback to not send more tokens than are required. Or the user can use the router.
gte620v marked the issue as sponsor disputed
I agree with the warden that there is risk in allowing the user to accidentally transfer more funds than required. However, this requires a significant user error as the quantity required for transfer is specified in the external call swapCallback()
.
Since this issue requires significant user error I consider it to be LOW and therefore downgrade it to QA.
kirk-baird marked the issue as grade-b
Lines of code
https://github.com/code-423n4/2022-12-Stealth-Project/blob/main/maverick-v1/contracts/models/Pool.sol#L260-L310
Vulnerability details
Impact
When calling the swap function below, the
ISwapCallback(msg.sender).swapCallback(amountIn, amountOut, data)
is called. It's possible that contract will send more input tokens amount than required to the pool. The check allows this. When this happens, the output token amount corresponding to the extra input token amount will not be transferred from the pool to the recipient after the swap. As a result, the user does not receive any output tokens to compensate input tokens he sent.Proof of Concept
https://github.com/code-423n4/2022-12-Stealth-Project/blob/main/maverick-v1/contracts/models/Pool.sol#L260-L310
After the swap there is a check that previous balance + swapped amount is less than current balance.
require(previousBalance + amountIn <= (tokenAIn ? _tokenABalance() : _tokenBBalance()), "S");
But if user paid more input tokens, then no extra output tokens were sent to user.
Tools Used
VsCode
Recommended Mitigation Steps
Do not allow to pay more tokens than expected.