Closed code423n4 closed 1 year ago
berndartmueller marked the issue as primary issue
kyscott18 marked the issue as sponsor acknowledged
This function in the core contract is not meant to be called by an end user and actually must be called by a contract because a callback is called. Since swapping is going to be done by arbitrageurs, we expect them to write their own contracts with their own slippage and staleness logic.
berndartmueller changed the severity to 2 (Med Risk)
berndartmueller marked the issue as selected for report
I'm revising my decision and consider this finding as QA (Low). As the sponsor noted in https://github.com/code-423n4/2023-01-numoen-findings/issues/160#issuecomment-1423070899, this swap
function has to be called by a contract. Thus I see the responsibility of ensuring proper and safe usage of the swap
function at the arbitrageurs' end.
berndartmueller changed the severity to QA (Quality Assurance)
berndartmueller marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2023-01-numoen/blob/main/src/core/Pair.sol#L116-L140
Vulnerability details
Summary
The
Pair
contract does not allow users to submit a deadline for their action. This missing feature enables pending transactions to be maliciously executed at a later point.Proof of concept
AMMs should provide their users with an option to include a deadline for their pending actions such as swapping. The most common solution is to include a deadline timestamp as a parameter (for example see Uniswap V2). If such an option is not available, users can unknowingly perform bad trades:
Pair.swap
withto = 0xAlice
,amount0Out = 100
andamount1Out = 0
.Impact
Omitted in this case, since the exploit is solely based on the fact that there is no limit on how long a transaction is allowed to be pending, which can be clearly seen when looking at the mentioned functions.
How to fix
Introduce a
deadline
parameter to the mentioned functions. This is implemented in other functions such as LiquidityManager.sol#L135 and LiquidityManager.sol#L201 with thecheckDeadline
modifier at LiquidityManager.sol#L83-86.