Skip to content
Business logic Audit finding Intermediate

Usage of HSG for existing safe can brick safe

A signer-gate contract deployed for an existing Safe can be configured with a maximum signer count lower than the Safe's current number of valid signers. Because the pre-transaction check reverts when the valid signer count exceeds that maximum, the Safe can no longer execute any transaction until enough signers lose their hats.

cducrest-brainbot Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-02-hats-judging/issues/93

Found by

cducrest-brainbot

Summary

The HatsSignerGateFactory allows for deployment of HSG / MHSG for existing safes. I believe the intention is to let the user call enableModule() and setGuard() on the safe after deployme with the HSG / MHSG address.

This can result in unmatching values of maxSigners in the HSG and number of valid signers of the safe. That will prevent further interaction with the safe rendering it unusable.

Vulnerability Detail

If a safe has 10 owners with valid hats, and a HSG / MHSG is deployed with a value of maxSigners < 10 and this HSG / MHSG is wired to the safe, the checks for validSignerCount <= maxSigners will revert in the HSG.

These checks are present in reconcileSignerCount and claimSigner. However reconcileSignerCount is a core function that is called by checkTransaction(), the pre-flight check on the safe transaction.

Impact

The safe will not be able to execute any transaction until the number of valid signers is lowered (some hat wearers give up their hats / some hats turns invalid ...)

Code Snippet

reconcileSignerCount checks maxSigners value:

https://github.com/Hats-Protocol/hats-zodiac/blob/9455cc0957762f5dbbd8e62063d970199109b977/src/HatsSignerGateBase.sol#L183-L189

It is called during checkTransaction:

https://github.com/Hats-Protocol/hats-zodiac/blob/9455cc0957762f5dbbd8e62063d970199109b977/src/HatsSignerGateBase.sol#L464

The value is set once during setup and not changeable:

https://github.com/Hats-Protocol/hats-zodiac/blob/9455cc0957762f5dbbd8e62063d970199109b977/src/HatsSignerGateBase.sol#L66-L84

Tool used

Manual Review

Recommendation

Allow this value to be changed by owner, or have a function that checks the HSG is safe before making it active after it is wired to an existing safe.

Discussion

spengrah

I like the recommendation to add a function to check that HSG is can be safely wired up to an existing Safe.

Another approach could be to check in the factory that maxSigners >= hat.currentSupply — or use the recommendation from #104 of ensuring that maxSigners > safe.getOwners() — but this wouldn't completely solve it because more hats could be minted to existing signers between deployment and wiring up.

cc @zobront

zobront

@spengrah I agree that the check needs to be at the "wiring up" time and not earlier.

spengrah

Re-adding the severity dispute tag since existing signers (who have full control over the safe prior to attaching HSG) would be both the ones attaching HSG in the first place and needing to renounce or be revoked if they made a mistake to attach. To me, this means that this is not a high severity bug, since attaching / fixing an attachment of HSG are incentive-aligned.

MLON33

zobront added "Fix Approved" label

jacksanford1

Adding the fix PR from spengrah for reference: https://github.com/Hats-Protocol/hats-zodiac/pull/14

The original report as published on Sherlock, by cducrest-brainbot. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 the maximum signer count is fixed at deployment and never validated against the Safe's existing signer count when the gate is attached, so the pre-flight check always reverts.

Impact

The Safe cannot execute any transaction until the number of valid signers drops below the configured maximum, effectively bricking it; the discussion argues this is not high severity because the same owners both attach the gate and can fix it.

What the attacker needed

An existing Safe with several owners; owners hold valid hats; gate deployed with maxSigners below owner count; gate wired to the Safe

The fix

The maximum signer count should be changeable by the owner, or a check should run at wiring-up time to confirm the gate is safe for the existing Safe; a fix PR was referenced.

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 crypto wallet that needs several owners to approve a transaction. A helper contract was added to such a wallet with a limit set lower than the number of current owners, so every approval check fails and the wallet is stuck. The limit cannot be changed afterwards, so owners must give up their rights before the wallet works again.

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.

More by cducrest-brainbot

View all

11 more disclosed reports, best first.

More from Hats

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.