Skip to content

Commit

Permalink
Merge pull request #173 from lidofinance/fix/missing-check-escrow
Browse files Browse the repository at this point in the history
Audit fix: strict stETH withdrawal request validation logic
  • Loading branch information
bulbozaur authored Nov 11, 2024
2 parents 8cf3bf9 + 21f51b8 commit 277ce97
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions contracts/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,13 @@ contract Escrow is IEscrow {
uint256 minStETHWithdrawalRequestAmount = WITHDRAWAL_QUEUE.MIN_STETH_WITHDRAWAL_AMOUNT();
uint256 maxStETHWithdrawalRequestAmount = WITHDRAWAL_QUEUE.MAX_STETH_WITHDRAWAL_AMOUNT();

/// @dev This check ensures that even if MIN_STETH_WITHDRAWAL_AMOUNT is set too low,
/// the withdrawal batch request process can still be completed successfully
if (stETHRemaining < Math.max(_MIN_TRANSFERRABLE_ST_ETH_AMOUNT, minStETHWithdrawalRequestAmount)) {
/// @dev The remaining stETH amount must be greater than the minimum threshold to create a withdrawal request.
/// Using only `minStETHWithdrawalRequestAmount` is insufficient because it is an external variable
/// that could be decreased independently. Introducing `minWithdrawableStETHAmount` provides
/// an internal safeguard, enforcing a minimum threshold within the contract.
uint256 minWithdrawableStETHAmount = Math.max(_MIN_TRANSFERRABLE_ST_ETH_AMOUNT, minStETHWithdrawalRequestAmount);

if (stETHRemaining < minWithdrawableStETHAmount) {
return _batchesQueue.close();
}

Expand All @@ -363,7 +367,7 @@ contract Escrow is IEscrow {

stETHRemaining = ST_ETH.balanceOf(address(this));

if (stETHRemaining < minStETHWithdrawalRequestAmount) {
if (stETHRemaining < minWithdrawableStETHAmount) {
_batchesQueue.close();
}
}
Expand Down

0 comments on commit 277ce97

Please sign in to comment.