Lp’s liquidity may be lost if re-org happens
A liquidity provider can remove liquidity and then burn their position, but if a blockchain re-org occurs, an attacker can manipulate the pool price so the removal reverts while the burn succeeds, locking the funds. The report claims this could cause loss of the LP's liquidity.
Originally disclosed on Code4rena
Submitted by zhaojohnson
LP holders will remove liquidity and then burn their liquidity position. If re-org happens, malicious users can manipulate the pool’s price to cause user’s removing liquidity revert. Then LP holders’ position will be burned and liquidity will be locked in contract.
Proof of Concept
In lib.rs, users can burn their position. From this function’s comment, Calling this function leaves any liquidity or fees left in the position inaccessible., it’s user’s responsibility to remove their liquidity before they burn their position. The problem is that even if users follow this rule, remove liquidity at first, and then burn their position, users may still lose their funds.
Re-org is one common scenario in Arbitrum. When re-org happens, some transactions will be re-ordered and re-executed. For example:
- Alice removes her liquidity with one slippage control parameter.
- Alice burns her position.
- Re-org happens. Bob monitors the re-org and try to do some swap in pool to change pool’s price and tick.
- Alice removing liquidity transaction will be executed and reverted because Bob changes current pool’s price and Alice’s slippage condition will not be matched.
- Alice’s burning position can still be executed successfully.
- Alice will lose her funds.
pub fn burn_position_AE401070(&mut self, id: U256) -> Result<(), Revert> {
let owner = msg::sender();
// Get this NFT(position)'s owner to make sure that the caller owns this position.
assert_eq_or!(
self.position_owners.get(id),
owner,
Error::PositionOwnerOnly
);
self.remove_position(owner, id);
#[cfg(feature = "log-events")]
evm::log(events::BurnPosition { owner, id });
Ok(())
}
Recommended Mitigation Steps
Add some more check on burn_position_AE401070(), revert if there are some left liquidity.
Assessed type
Context
af-afk (Superposition) confirmed and commented:
We’re going to resolve this by deleting the burn position feature.
The Warden has identified a mechanism in the Seawater system that can become harmful if a re-organization occurs, leading to a total loss of the funds associated with the position.
I believe a medium risk severity rating is appropriate given the likelihood of a re-organization simultaneously occurring with the sequence of events outlined (i.e., different blocks that ended up being re-ordered executing the actions outlined) is low.
Silvermist (warden) commented:
Arbitrum’s docs states that a transaction can’t be re-orged, so this should be invalid.
Yeah, there are no re-orgs in Arbitrum - https://abarbatei.xyz/blockchain-reorgs-for-managers-and-auditors#heading-metrics-for-protocols-and-auditors.
@Silvermist and @Blckhv - The documentation referenced states that if the L1 re-orgs, then the Arbitrum transactions will re-org as well. This is also referenced in the glossary itself.
The link referenced by @Blckhv also does not say that “re-orgs are not possible”, simply that they have not been observed yet. As such, the original ruling of the submission stands.
Note: For full discussion, see here.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the burn function does not check whether the position still holds liquidity, so a burn can succeed even if a prior removal transaction was reverted.
Impact
If a re-org occurs, the LP could lose all liquidity associated with the position, though the report and judge note the likelihood is low.
What the attacker needed
LP removes liquidity then burns position; A blockchain re-org occurs; Attacker manipulates pool price
The fix
The project resolved the issue by deleting the burn position feature.
How it was found
- Alice removes her liquidity with a slippage control parameter.
- Alice burns her position.
- A re-org happens and Bob swaps in the pool to change its price and tick.
- Alice's removal transaction is re-executed and reverts because the price no longer meets her slippage condition.
- Alice's burn transaction still executes successfully.
- Alice loses her funds.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A liquidity provider puts money into a pool and gets a position token. They can later take their money out and then destroy the token. If the blockchain reorders past transactions (a re-org), someone else can change the pool's price so the withdrawal fails, but the token destruction still goes through, leaving the money stuck.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.