Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing deadline check in UlyssesRouter #200

Closed
code423n4 opened this issue Jun 22, 2023 · 2 comments
Closed

Missing deadline check in UlyssesRouter #200

code423n4 opened this issue Jun 22, 2023 · 2 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-504 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Jun 22, 2023

Lines of code

https://github.com/code-423n4/2023-05-maia/blob/54a45beb1428d85999da3f721f923cbf36ee3d35/src/ulysses-amm/UlyssesRouter.sol#L49
https://github.com/code-423n4/2023-05-maia/blob/54a45beb1428d85999da3f721f923cbf36ee3d35/src/ulysses-amm/UlyssesRouter.sol#L59
https://github.com/code-423n4/2023-05-maia/blob/54a45beb1428d85999da3f721f923cbf36ee3d35/src/ulysses-amm/UlyssesRouter.sol#L73

Vulnerability details

Impact

addLiquidity(), removeLiquidity(), swap() don't have deadline parameter. It means that transaction can be pending in mempool so long, such that minOutput is too low comparing to current price at execution, and therefore high slippage action is performed.

Proof of Concept

Suppose current scenario:

  1. User wants to deposit 1000 tokens. token : share are traded as 1 : 1.
  2. User accepts slippage of 1%, therefore specifies minOutput = 1000 * 1 * (100% - 1%) = 990
  3. Transaction is pending long time in mempool. token/price share changed a lot, now 1 token is equal to 2 shares.
  4. Fair price with slippage 1% should be minOutput = 1000 * 2 * (100% - 1%) = 1980, but user specified 990 and can perform bad trade because of slippage

Tools Used

Manual Review

Recommended Mitigation Steps

Add deadline argument and check it, like UniswapV2Router does:

    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
        ...
    }

    modifier ensure(uint deadline) {
        require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
        _;
    }

Assessed type

MEV

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Jun 22, 2023
code423n4 added a commit that referenced this issue Jun 22, 2023
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value edited-by-warden and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jun 22, 2023
@c4-judge c4-judge closed this as completed Jul 9, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Jul 9, 2023

trust1995 marked the issue as duplicate of #171

@c4-judge
Copy link
Contributor

c4-judge commented Jul 9, 2023

trust1995 marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate-504 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants