In the PriorityPool contract, the withdraw function allows users to withdraw their staked tokens. However, due to an unbounded amountToWithdraw parameter, an attacker could potentially withdraw more tokens than they are entitled to. By manipulating the _amountToWithdraw parameter, an attacker can exploit this vulnerability to drain the contract of its liquidity, resulting in a loss of funds for other users and the protocol.
The withdraw function is designed to handle the withdrawal of staked tokens from the PriorityPool contract. Users can unqueue their tokens and withdraw any remaining amount, but the function does not appropriately validate whether the _amountToWithdraw parameter is within the bounds of the user's actual balance or entitlement. This allows an attacker to specify an arbitrary amount to withdraw, potentially exceeding their rightful balance.
Problem:
The _amountToWithdraw parameter is directly used in the withdrawal process without verifying whether it corresponds to the user's actual balance or entitled amount.
The lack of validation allows the user to specify any arbitrary value for _amountToWithdraw, which can exceed their real balance.
This can result in a situation where the contract allows an attacker to withdraw more tokens than they own, potentially draining liquidity from the contract.
PoC scenario:
Assume Alice has a balance of 10 tokens in the PriorityPool contract.
Alice calls the withdraw function with _amountToWithdraw set to 100 tokens, even though she only has 10 tokens in the pool.
Since there is no check to ensure that Alice's withdrawal amount is within her actual balance, the contract processes the withdrawal for 100 tokens.
Alice receives 100 tokens, draining the contract of its liquidity and leaving other users vulnerable to losses.
Here is a test that can be run using Hardhat to demonstrate the over-withdrawal exploit:
The test will pass, showing that the attacker was able to withdraw more tokens than they were entitled to, demonstrating the over-withdrawal exploit.
The ability to withdraw more than a user's balance can completely drain the contract's funds, leading to a critical loss for the protocol and its users. The impact is severe, and the exploit can be easily executed by malicious actors.
Attackers can drain the contract of its liquidity by withdrawing more tokens than they are entitled to.
This can cause a loss of funds for other users who have deposited into the pool.
The protocol's token reserves can be completely depleted, leading to a collapse of the staking system.
Manual review.
The contract must validate that the _amountToWithdraw parameter does not exceed the user's actual balance or entitled amount before proceeding with the withdrawal.
This ensures that users can only withdraw the amount they actually own and prevents over-withdrawal.
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.