The timelock contract allows an attacker with compromised owner keys to schedule many proposals with different salts, forcing the victim to spend gas to cancel each one. The attacker can potentially drain funds if the victim cannot afford the gas to cancel all proposals.
The timelock acts in a way that once the proposals are submitted, they need to be cancelled or executed. This behaviour opens up a griefing attack vector towards the owners of the vault in case at least threshold amount of owners’ private keys are exposed.
When the keys are exposed, the attackers can send as many transactions as they need to the network from the safe with different salts. Even if one of the transactions go through, funds can be stolen. The protocol defence mechanisms in these situations is (1) Pause guardian can cancel all the proposals (2) Cold signers can cancel proposals.
Both these defence mechanisms require gas usage from the victim’s accounts, and it is important to note that they can not use the funds inside the Kleidi wallet. This can lead to a gas war between attackers and the victims and can cause them to at least cause a griefing attack.
Impact
Assumption in this section is that the victims do not get external help and they have invested most of their liquidity inside Kleidi, and only kept minimal amounts out for gas payments.
Imagine if victims have access to F amounts of funds, and 95% of those funds is locked into Kleidi.
The proof of concept below shows that the gas consumption of cancel is close to 5% of schedule.
In case the keys are compromised, attackers can send many transactions spending G amount of gas. The requires the victims to need to spend 0.05 * G in gas to cancel those proposals.
The reward for attackers, only if one of their transactions go through, is 0.95 * F.
Given that victims only have access to 0.05 * F to pay for 0.05 * G, if attackers pay more than the funds inside the protocol, meaning (G > F), they can claim the funds in the protocol and drain it as victims do not have enough funds to cancel all proposals.
At the end, attackers can re-claim most of what they spent. Overall spending G - 0.95 * F = G - 0.95 * G = 0.05 * G, and steal 0.95 * G from the user.
Note: In case the victims have invested more than ~95% into the Kleidi, attackers will be able to make profit.
Proof of Concept
Gas consumptions is thoroughly investigated in the test below:
Add epochs to the timelock, each time the contract is paused, move the epoch to the next variable. Also, include epochs in the transaction hashes, and only execute transactions from this epoch. This way, the pause guardian does not need to clear all the transactions one by one, and once the epoch is moved to the next stage, all the previous transactions will be automatically invalidated.
It’s worth noting that the POC doesn’t work in isolation, leading me to believe that the math given is incorrect.
I have ran my POC in both modes, and both versions seems to indicate that the cost to attack is a lot higher than the cost to defend, specifically the attack is 7 times more expensive than defending.
I’m not fully confident that Foundry treats the calls as isolated in this way, so I’m happy to be corrected.
Result from forge test --match-test testGasConsumption -vv --isolate
Ran 1 test for test/unit/Timelock.t.sol:TimelockUnitTest
[PASS] testGasConsumption() (gas: 33562952)
Logs:
count 282
Gas consumption of schedule: 30021964
Gas consumption of cancel: 4053325
7 times more expensive
Result from forge test --match-test testGasConsumption -vv
Ran 1 test for test/unit/Timelock.t.sol:TimelockUnitTest
[PASS] testGasConsumption() (gas: 25463501)
Logs:
count 403
Gas consumption of schedule: 30049168
Gas consumption of cancel: 1307414
22 times more expensive
Barring a mistake from me, I think the finding is valid and Medium is the most appropriate as the guardian can with some likelihood prevent it as the cost of the attack and the setup is higher than the cost to defend.
Also the attack must be done over multiple blocks.
Mitigation would require changing the way initiatives are tracked.
By simply shifting a “valid ts” all initiatives created and queued before it can be made invalid, this makes the change a O(1) meaning it should not longer be dossable.
I think that cost on the attack side is likely more expensive than your PoC shows because it just pranks as the safe, and doesn’t generate the signatures, have them validated in the gnosis safe + increment the nonce in the gnosis safe + 21k base transaction cost. When you add all of that together, it would have to be at least 30x more expensive to attack than to defend.
I generally agree, when also considering memory expansion costs that should happen when dealing with so many signatures.
I think Medium severity is the most appropriate because the attack is IMO not possible in one block, but to say this could have been prevented would be incorrect.
Fundamentally, if the guardian doesn’t urgently pause, they may not be able to within a few blocks (strictly more than 1).
Medium seems appropriate given this.
The original report as published on Code4rena, by Allarious. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the timelock requires individual cancellation of each scheduled proposal, and the cost to cancel is proportional to the number of proposals, enabling a gas griefing attack.
Impact
Attackers could drain the protocol's funds if the victim cannot afford the gas to cancel all proposals, but the judge found the attack is 7-22 times more expensive than defending, and the attack must be done over multiple blocks.
What the attacker needed
Compromised owner keys (at least threshold); victim has most funds in the timelock; attacker can spend more gas than victim
The fix
The fix was to add epochs to the timelock, so pausing invalidates all previous proposals at once.
How it was found
Compromise at least threshold owner keys.
Schedule many proposals with different salts from the safe.
Victim must cancel each proposal or pause, spending gas.
If victim runs out of gas funds, attacker's proposal executes and steals funds.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A timelock is a smart contract that delays actions. If enough owners' keys are stolen, an attacker can create many pending actions, and the victim must pay gas to cancel each one. This could cost the victim more than the funds in the timelock, allowing the attacker to steal them.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.