Drill the governance emergency path
An emergency power that has never been used is a rumour, not a control. Rehearse the whole path on a fork: propose the attack, detect it, cancel it, and measure how long the drill took.
Procedure
Fork mainnet (or the DAO's chain) at the current head into a test:
forge test --match-contract EmergencyDrill --fork-url $RPC -vvv
In the test, impersonate a proposer with enough weight and submit a payload that looks benign but transfers treasury funds to an attacker address:
vm.prank(proposer); governor.propose(targets, values, calldatas, description);
Run detection: decode the calldata and assert your check flags the unknown recipient. If the check does not fire, the detector is the finding.
Exercise the cancel path exactly as it would run in production, via the guardian:
vm.prank(guardian); governor.cancel(targets, values, calldatas, descHash);
then assertEq(uint8(governor.state(proposalId)), uint8(IGovernor.ProposalState.Canceled));
Measure the response window: the test timestamps between propose and cancel must fit inside the timelock delay; assert it.
Also test the failure case: a payload the governor cannot cancel (already executed) should assert the state is Executed and the drill records that the window was missed.
Record the drill: who detects, who cancels, the elapsed blocks, and the venue (forum or council chat) within one page.
Time the detection and cancel steps separately, and assert each fits the real-world SLA the DAO agreed.
Restore the fork and re-run to confirm the result is deterministic, not a one-off.
File the drill result against the emergency runbook so the next responder reads a rehearsed path, not a guess.
Pitfalls
Drilling with a benign payload so the cancel path is never actually needed; use the malicious shape or the rehearsal proves nothing.
Forgetting to impersonate the right caller; the guard onlyGuardian reverts and the test hides a broken cancel function.
Assuming the guardian's key is available in an emergency; a drill should include retrieving the key or reaching the signer.
Measuring the delay with block.timestamp left untouched; advance time explicitly (vm.warp) so the timelock boundary is tested.
A drill that only tests cancel and never tests "the attack already executed", so nobody knows what the recovery is.
A drill that cancels with unlimited gas and no mempool competition overstates the real response speed.
Assuming the guardian is a single EOA when it is a council multisig; the drill must collect the real threshold.
Forgetting to assert the attacker's payload never executed; a green cancel with a fired execute is a failed drill.
Verification
forge test --match-contract EmergencyDrill --fork-url $RPC -vvv
# expect PASS on detection, cancellation before the timelock, and an explicit record of the elapsed blocks
Report the drill outcome: payload detected, cancelled before execution, elapsed time within the delay, and any step that failed, with the test output quoted.
1---2name: drill-the-governance-emergency-path3description: Use when rehearsing a DAO's emergency response before it is needed. Runs a malicious proposal through a fork, exercises the cancel and guardian path, and times the response.4metadata:5 source: https://skillmd.com/skills/jiayaoqijia/drill-the-governance-emergency-path6---78# Drill the governance emergency path910An emergency power that has never been used is a rumour, not a control. Rehearse the whole path on a fork: propose the attack, detect it, cancel it, and measure how long the drill took.1112## Procedure13141. Fork mainnet (or the DAO's chain) at the current head into a test:15 `forge test --match-contract EmergencyDrill --fork-url $RPC -vvv`162. In the test, impersonate a proposer with enough weight and submit a payload that looks benign but transfers treasury funds to an attacker address:17 `vm.prank(proposer); governor.propose(targets, values, calldatas, description);`183. Run detection: decode the calldata and assert your check flags the unknown recipient. If the check does not fire, the detector is the finding.194. Exercise the cancel path exactly as it would run in production, via the guardian:20 `vm.prank(guardian); governor.cancel(targets, values, calldatas, descHash);`21 then `assertEq(uint8(governor.state(proposalId)), uint8(IGovernor.ProposalState.Canceled));`225. Measure the response window: the test timestamps between propose and cancel must fit inside the timelock delay; assert it.236. Also test the failure case: a payload the governor cannot cancel (already executed) should assert the state is Executed and the drill records that the window was missed.247. Record the drill: who detects, who cancels, the elapsed blocks, and the venue (forum or council chat) within one page.25268. Time the detection and cancel steps separately, and assert each fits the real-world SLA the DAO agreed.279. Restore the fork and re-run to confirm the result is deterministic, not a one-off.2810. File the drill result against the emergency runbook so the next responder reads a rehearsed path, not a guess.2930## Pitfalls3132- Drilling with a benign payload so the cancel path is never actually needed; use the malicious shape or the rehearsal proves nothing.33- Forgetting to impersonate the right caller; the guard `onlyGuardian` reverts and the test hides a broken cancel function.34- Assuming the guardian's key is available in an emergency; a drill should include retrieving the key or reaching the signer.35- Measuring the delay with `block.timestamp` left untouched; advance time explicitly (`vm.warp`) so the timelock boundary is tested.36- A drill that only tests cancel and never tests "the attack already executed", so nobody knows what the recovery is.3738- A drill that cancels with unlimited gas and no mempool competition overstates the real response speed.39- Assuming the guardian is a single EOA when it is a council multisig; the drill must collect the real threshold.40- Forgetting to assert the attacker's payload never executed; a green cancel with a fired execute is a failed drill.4142## Verification4344 forge test --match-contract EmergencyDrill --fork-url $RPC -vvv45 # expect PASS on detection, cancellation before the timelock, and an explicit record of the elapsed blocks4647Report the drill outcome: payload detected, cancelled before execution, elapsed time within the delay, and any step that failed, with the test output quoted.