The onAfterRemoveLiquidity function in the UpliftOnlyExample contract fails to properly validate the caller's authenticity. It only checks if the router input matches the contract address itself, allowing malicious users to exploit this by providing the correct router address. Attackers can remove liquidity positions of other users.
The vulnerability stems from the following flawed logic in the onAfterRemoveLiquidity function. The function relies on the onlySelfRouter(router) modifier, which validates that router equals the contract's own address. However, since router is an input parameter, attackers can easily provide the expected value (contract's address) to bypass this check.
The function does not verify that the caller is the Vault contract, which should be the sole authorized entity for invoking onAfterRemoveLiquidity. By creating a malicious contract, attackers can exploit the above issues to target other users' liquidity positions.
Test:
Attackers can arbitrarily remove liquidity positions from other users' accounts.
Manual
Update the function to ensure that only the Vault contract can invoke it
Likelihood: High, anyone, anytime. Impact: High, Loss of funds
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.