Pause function can be bricked #25
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-24
edited-by-warden
🤖_primary
AI based primary recommendation
🤖_06_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-10-kleidi/blob/c474b9480850d08514c100b415efcbc962608c62/src/Timelock.sol#L685-L700
Vulnerability details
Explanation
The
pause
function in the timelock is looping through all the proposals and cancels them all in case it is called by guardian. However, the function can be bricked if there are too many proposals.This is important as one of the main use cases of Kleidi vs using a normal GnosisSafe wallet, is that the pause guardian can step in and singlehandedly stop the system while the recovery spell is passing it's time.
Impact
As mentioned in the project documentation, in case the cold signers are compromised, the pause guardian can step in and pause the functionality of the timelock before recovering the safe with a
Recoveryspell
.Situation 1, cold signers gone rogue: In the case that more than
owners.length - threshold
have gone rogue, and the victim signers can not cancel anything on the timelock, the rogue signers can create many proposals on the timelock, effectively cutting the guardian out of the loop as well. This is because if the gas usage of thepause()
function is more than the block's max gas limit, it would effectively become uncallable and will always fail without of gas
error.Situation 2, cold signers' key are stolen: In this case cold signers should be able to cancel all proposals one by one.
Cost of Attack
The cost of this attack depends of the gas usage of
schedule
,cancel
functions beside the block max gas limit.As shown in the proof of concept below, the gas limit of
cancel
is somewhat equal to 5% of the gas cost ofschedule
. Therefore, attackers should fill up to 20 blocks before the guardian is cut out of the equation.Here, we explore the cost of this attack on Optimism, with
60,000,000
block gas limit. Filling up 20 blocks is equal to20*60,000,000 = 1,200,000,000
gas usage. The attack can be executed in less that a minute on optimism, but still the attack can be caught if the pause guardian is extremely fast, therefore, the cost of attack is:In case the overall profit is more than zero, the attack can be profitable.
Proof of Concept
The PoC below, shows the gas consumption increase based on the number of proposal increased. In case the gas usage of the
pause()
function goes above the block limit on any network, the transaction would fail:Recommended Mitigation Steps
Let the pause guardian pause the contract with initially cancelling all the proposals. Allow pause guardian to cancel proposals batch by batch.
Assessed type
DoS
The text was updated successfully, but these errors were encountered: