The liquidity_lockbox contract is designed to handle liquidity positions in a specific Orca LP pool. Users can deposit their LP NFTs into the contract, receiving in exchange tokens according to their position size. These tokens are minted with the goal of allowing users to bridge them to Ethereum later on and exchange them for OLAS at a discount.
However, a potential vulnerability arises from the unrestricted nature of the deposit and withdrawal functions. Specifically, a user can deposit a large amount of assets and immediately withdraw all existing positions using the tokens they just received. This sequence of actions can be repeated to continuously exploit the LP rewards system, leading to an unfair distribution of rewards.
The root cause of this issue lies in the withdraw() function, which does not have any restrictions or checks that prevent immediate withdrawal after a deposit and pays all accrued LP rewards to the caller.
Proof of Concept
Consider the following scenario:
Alice obtains a large amount of tokens either through a flashloan or by buying them.
Alice uses these tokens to open a large position in the Orca pool.
Alice deposits the position NFT into the liquidity_lockbox contract, receiving a large amount of bridge tokens.
Alice withdraws all existing positions using the tokens she just received and receives the LP rewards.
Alice closes the received positions in the Orca pool, repays the flashloan (if used) and pockets the rewards.
This sequence of actions can be repeated by Alice to continuously exploit the LP rewards system.
Tools Used
Manual review
Recommended Mitigation Steps
To mitigate this issue, a possible solution could be to implement a lock-up period for deposited positions. This would prevent users from immediately withdrawing their positions after depositing. Additionally, consider not distributing rewards to the withdrawing user (which will never be fair) and instead collecting them for the protocol.
Lines of code
https://github.com/code-423n4/2023-12-autonolas/blob/main/lockbox-solana/solidity/liquidity_lockbox.sol#L295-L307
Vulnerability details
Impact
The
liquidity_lockbox
contract is designed to handle liquidity positions in a specific Orca LP pool. Users can deposit their LP NFTs into the contract, receiving in exchange tokens according to their position size. These tokens are minted with the goal of allowing users to bridge them to Ethereum later on and exchange them for OLAS at a discount.However, a potential vulnerability arises from the unrestricted nature of the deposit and withdrawal functions. Specifically, a user can deposit a large amount of assets and immediately withdraw all existing positions using the tokens they just received. This sequence of actions can be repeated to continuously exploit the LP rewards system, leading to an unfair distribution of rewards.
The root cause of this issue lies in the
withdraw()
function, which does not have any restrictions or checks that prevent immediate withdrawal after a deposit and pays all accrued LP rewards to the caller.Proof of Concept
Consider the following scenario:
liquidity_lockbox
contract, receiving a large amount of bridge tokens.This sequence of actions can be repeated by Alice to continuously exploit the LP rewards system.
Tools Used
Manual review
Recommended Mitigation Steps
To mitigate this issue, a possible solution could be to implement a lock-up period for deposited positions. This would prevent users from immediately withdrawing their positions after depositing. Additionally, consider not distributing rewards to the withdrawing user (which will never be fair) and instead collecting them for the protocol.
Assessed type
Other