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

Some functions in TokenisableRange.sol does not allow user to supply slippage and deadline. #155

Closed
code423n4 opened this issue Aug 6, 2023 · 6 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-260 grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L154
https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L200
https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L260
https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L301

Vulnerability details

Impact

Not allowing users to supply their own deadline could potentially expose them to sandwich attacks

Proof of Concept

There are 04 instances of this issue:
TokenisableRange.sol#init() , TokenisableRange.sol#claimFee(), TokenisableRange.sol#deposit(), TokenisableRange.sol#withdraw()

File: TokenisableRange.sol
134:  function init(uint n0, uint n1) external {
---SKIP---
154:         deadline: block.timestamp
---------
167:  function claimFee() public {
---SKIP---
200:          deadline: block.timestamp
---------
222:  function deposit(uint256 n0, uint256 n1) external nonReentrant returns (uint256 lpAmt) {
---SKIP---
260:        deadline: block.timestamp
---------
292:  function withdraw(uint256 lp, uint256 amount0Min, uint256 amount1Min) external nonReentrant returns (uint256 removed0, uint256 removed1) {
---SKIP---
301:        deadline: block.timestamp

Passing block.timestamp as the expiry/deadline of an operation does not mean "require immediate execution" - it means "whatever block this transaction appears in, I'm comfortable with that block's timestamp". Providing this value means that a malicious miner can hold the transaction for as long as they like (think the flashbots mempool for bundling transactions), which may be until they are able to cause the transaction to incur the maximum amount of slippage allowed by the slippage parameter, or until conditions become unfavorable enough that other orders, e.g. liquidations, are triggered. Timestamps should be chosen off-chain, and should be specified by the caller to avoid unnecessary MEV.

Tools Used

Manual review

Recommended Mitigation Steps

Require the user to pass in a timestamp.

Assessed type

MEV

@code423n4 code423n4 added 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 labels Aug 6, 2023
code423n4 added a commit that referenced this issue Aug 6, 2023
@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #78

@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #260

@c4-judge
Copy link

gzeon-c4 marked the issue as unsatisfactory:
Insufficient proof

@c4-judge c4-judge added unsatisfactory does not satisfy C4 submission criteria; not eligible for awards downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Aug 20, 2023
@c4-judge
Copy link

gzeon-c4 changed the severity to QA (Quality Assurance)

@Nadinnnn
Copy link

I would like to provide more of the same issues discussed before
code-423n4/2022-11-paraspace-findings#429
https://code4rena.com/reports/2022-06-canto-v2#m-01-stableswap---deadline-do-not-work

From a judge's contest in a previous contest

Because Front-running is a key aspect of AMM design, deadline is a useful tool to ensure that your tx cannot be “saved for later”.
Due to the removal of the check, it may be more profitable for a miner to deny the transaction from being mined until the transaction incurs the maximum amount of slippage.

@gzeon-c4
Copy link

See #260 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue duplicate-260 grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

6 participants