Underestimated gas estimation for executing withdrawals leads to insufficient keeper compensation
Summary
The GasUtils.estimateExecuteWithdrawalGasLimit function underestimates the gas estimation for withdrawal execution, as it does not take into account token swaps, unlike the gas estimation in the GasUtils.estimateExecuteDepositGasLimit function (used to estimate executing deposits).
Vulnerability Detail
When creating a withdrawal request, the WithdrawalUtils.createWithdrawal function estimates the gas required to execute the withdrawal and validates that the paid execution fee (params.executionFee) is sufficient to cover the estimated gas and to compensate the keeper executing the withdrawal fairly.
However, the GasUtils.estimateExecuteWithdrawalGasLimit function used to estimate the gas for executing withdrawals does not account for token swaps that can occur at the end of the withdrawal logic and therefore underestimates the gas estimation.
Token swaps are performed in the WithdrawalUtils._executeWithdrawal function in lines 354 and 365.
Impact
The keeper executing withdrawals receives fewer execution fees and is not fully compensated for the gas spent. Moreover, users can pay fewer execution fees than expected and required.
The gas estimate calculated in the GasUtils.estimateExecuteWithdrawalGasLimit function only uses a static gas limit plus the callback gas limit. Token swaps are not accounted for.
As observed in the createWithdrawal function, the GasUtils.estimateExecuteWithdrawalGasLimit function estimates the gas required to execute the withdrawal and validates the paid execution fee accordingly.
Consider incorporating the token swaps in the gas estimation for withdrawal execution, similar to how it is done in the GasUtils.estimateExecuteDepositGasLimit function.
berndartmueller
medium
Underestimated gas estimation for executing withdrawals leads to insufficient keeper compensation
Summary
The
GasUtils.estimateExecuteWithdrawalGasLimit
function underestimates the gas estimation for withdrawal execution, as it does not take into account token swaps, unlike the gas estimation in theGasUtils.estimateExecuteDepositGasLimit
function (used to estimate executing deposits).Vulnerability Detail
When creating a withdrawal request, the
WithdrawalUtils.createWithdrawal
function estimates the gas required to execute the withdrawal and validates that the paid execution fee (params.executionFee
) is sufficient to cover the estimated gas and to compensate the keeper executing the withdrawal fairly.However, the
GasUtils.estimateExecuteWithdrawalGasLimit
function used to estimate the gas for executing withdrawals does not account for token swaps that can occur at the end of the withdrawal logic and therefore underestimates the gas estimation.Token swaps are performed in the
WithdrawalUtils._executeWithdrawal
function in lines 354 and 365.Impact
The keeper executing withdrawals receives fewer execution fees and is not fully compensated for the gas spent. Moreover, users can pay fewer execution fees than expected and required.
Code Snippet
contracts/gas/GasUtils.sol#L150
The gas estimate calculated in the
GasUtils.estimateExecuteWithdrawalGasLimit
function only uses a static gas limit plus the callback gas limit. Token swaps are not accounted for.contracts/withdrawal/WithdrawalUtils.createWithdrawal() - L163
As observed in the
createWithdrawal
function, theGasUtils.estimateExecuteWithdrawalGasLimit
function estimates the gas required to execute the withdrawal and validates the paid execution fee accordingly.contracts/withdrawal/WithdrawalUtils.executeWithdrawal() - L206-L213
The execution fee is paid to the keeper at the end of the
executeWithdrawal
function.Tool used
Manual Review
Recommendation
Consider incorporating the token swaps in the gas estimation for withdrawal execution, similar to how it is done in the
GasUtils.estimateExecuteDepositGasLimit
function.