Safe can be bricked because threshold is updated with validSignerCount instead of newThreshold
A signer-gate contract meant to lower a Safe's signing threshold used the raw valid signer count instead of the computed minimum value. When there were more valid signers than the target threshold, the Safe's threshold was set too high, causing a post-execution check to fail and every Safe transaction to revert, potentially bricking the Safe permanently.
Source: https://github.com/sherlock-audit/2023-02-hats-judging/issues/37
Found by
Allarious, Dug, GimelSec, Met, carrot, cccz, duc, obront, roguereddwarf
Summary
The safe's threshold is supposed to be set with the lower value of the validSignerCount and the targetThreshold (intended to serve as the maximum). However, the wrong value is used in the call to the safe's function, which in some circumstances can lead to the safe being permanently bricked.
Vulnerability Detail
In reconcileSignerCount(), the valid signer count is calculated. We then create a value called newThreshold, and set it to the minimum of the valid signer count and the target threshold. This is intended to be the value that we update the safe's threshold with.
if (validSignerCount <= target && validSignerCount != currentThreshold) {
newThreshold = validSignerCount;
} else if (validSignerCount > target && currentThreshold < target) {
newThreshold = target;
}
However, there is a typo in the contract call, which accidentally uses validSignerCount instead of newThreshold.
The result is that, if there are more valid signers than the targetThreshold that was set, the threshold will be set higher than intended, and the threshold check in checkAfterExecution() will fail for being above the max, causing all safe transactions to revert.
This is a major problem because it cannot necessarily be fixed. In the event that it is a gate with a single hat signer, and the eligibility module for the hat doesn't have a way to turn off eligibility, there will be no way to reduce the number of signers. If this number is greater than maxSigners, there is no way to increase targetThreshold sufficiently to stop the reverting.
The result is that the safe is permanently bricked, and will not be able to perform any transactions.
Impact
All transactions will revert until validSignerCount can be reduced back below targetThreshold, which re
Code Snippet
Tool used
Manual Review
Recommendation
Change the value in the function call from validSignerCount to newThreshold.
if (newThreshold > 0) {
- bytes memory data = abi.encodeWithSignature("changeThreshold(uint256)", validSignerCount);
+ bytes memory data = abi.encodeWithSignature("changeThreshold(uint256)", newThreshold);
bool success = safe.execTransactionFromModule(
address(safe), // to
0, // value
data, // data
Enum.Operation.Call // operation
);
if (!success) {
revert FailedExecChangeThreshold();
}
}
Discussion
spengrah
https://github.com/Hats-Protocol/hats-zodiac/pull/9
MLON33
zobront added "Fix Approved" label
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a typo in the contract call: the code passes validSignerCount to changeThreshold instead of the computed newThreshold, so the threshold can exceed the intended maximum.
Impact
All Safe transactions revert until the valid signer count can be brought back below the target threshold, and in some configurations the Safe is permanently bricked with no way to recover.
What the attacker needed
Valid signers exceed target threshold; eligibility cannot be revoked; signer count above maxSigners
The fix
The function call should pass newThreshold rather than validSignerCount to changeThreshold; the text notes a fix was approved.
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.
A Safe is a shared wallet that needs a certain number of owners to approve a transaction before it goes through; that number is the threshold. This contract was supposed to keep the threshold at a sensible maximum, but it passed the wrong number when updating it, so the threshold ended up too high. Because a later check rejects any threshold above the maximum, every transaction from that wallet then failed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.