bughuntoor - Signer can avoid restrictions and change safe
state variables
#3
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
bughuntoor
High
Signer can avoid restrictions and change
safe
state variablesSummary
In order to make sure that a delegatecall does not change Safe's state, HSG's
checkTransaction
stores the current threshold, owners list and fallback handler. Then, after the call is executed,checkAfterExecution
is supposed to verify that these variables have not been changed.However, since the
checkTransaction
can be re-entered by a new call, these restrictions can easily be bypassed. If the delegatecall changes the owners and the threshold, the executing signer can then just provide a new transaction to be executed with the new owners being just him and threshold set to 1. This will then override the above stored variables. Because of this thecheckAfterExecution
check will also succeed.Root Cause
Possible reentrancy within
checkTransaction
Attack Path
delegatecall
, the only remaining owner signs a new transaction and executes it. It doesn't realistically mater what the tx is.checkTransaction
is entered._existingOwnersHash
and_existingThreshold
are overwritten to their new values.checkAfterExecution
on both the inner and the outer call check against the altered values, hence they both succeed.Affected Code
https://github.com/sherlock-audit/2024-11-hats-protocol/blob/main/hats-zodiac/src/HatsSignerGate.sol#L471
Impact
Users can bypassed intended restrictions not to be able to overwrite the owner list and threshold variables.
Mitigation
If
checkTransaction
is entered, and the transient variables have already been assigned values, revert if the values differ from the current ones.The text was updated successfully, but these errors were encountered: