This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
bin2chen - checkTransaction() can skip minThreshold limt #31
Labels
Duplicate
A valid issue that is a duplicate of an issue with `Has Duplicates` label
Escalation Resolved
This issue's escalations have been approved/rejected
High
A valid High severity issue
Reward
A payout will be made for this issue
bin2chen
high
checkTransaction() can skip minThreshold limt
Summary
Malicious users can forge the last few signatures that are not checked by
GnosisSafe
, skipping the minThreshold limitVulnerability Detail
checkTransaction() use for Pre-flight check on a
safe
transaction to ensure that it s signers are valid.one very important function is to check that the number of signatures cannot be less than
minThreshold
The implementation code is as follows:
get the number of valid signatures by
countingValidSignatures()
, and revert if the number is less thanminThreshold
countingValidSignatures()'s implementation:
this method modified from
GnosisSafe.sol#checkNSignatures()
, and made some changes:currentOwner
directly, and do not verify the signature contentThese security restrictions are ignored because
signatures
come from GnosisSafe, which has already verified by GnosisSafeBut there is a problem: GnosisSafe does verify
signatures
, but GnosisSafe only verifies the first few signatures ofthreshold
The GnosisSafe code is as follows:
https://github.com/safe-global/safe-contracts/blob/c36bcab46578a442862d043e12a83fec41143dec/contracts/GnosisSafe.sol#L145
but
HatsSignerGateBase.checkTransaction
use allsignatures
bysignatures.length / 65
countValidSignatures(txHash, signatures, signatures.length / 65)
so malicious user can forge the last few signatures of
threshold
, because the last few signatures are not checked byGnosisSafe
For example:
minThreshold =2
targetThreshold=2
maxSigners=5
safe.threshold = 2
safe.owners=[alice,bob,jack,jimmy]
For some reason alice and bob has lost hats , has become invalid signer, but still in safe.owners[]
Although alice and bob are already invalid Signer, it is still possible to construct a malicious signature to skip the minThreshold limit
signatures:
[0] = alice signature ---> real signature, for
safe
verification[1] = bob signature ---> real signature, for
safe
verification[2] = jack fake signature (v=1 r=jack s=000) -- >
safe
will Ignore ,HatsSignerGateBase
will count[3] = jimmy fake signature (v=1 r=jimmy s=000) -- >
safe
will Ignore,HatsSignerGateBase
will countThis gets
validSigCount = 2
, which can skip minThreshold limitImpact
minThreshold mechanism fails ,can malicious execution of illegal transactions
Code Snippet
https://github.com/Hats-Protocol/hats-zodiac/blob/9455cc0957762f5dbbd8e62063d970199109b977/src/HatsSignerGateBase.sol#L488
https://github.com/Hats-Protocol/hats-zodiac/blob/9455cc0957762f5dbbd8e62063d970199109b977/src/HatsSignerGateBase.sol#L565-L569
https://github.com/safe-global/safe-contracts/blob/c36bcab46578a442862d043e12a83fec41143dec/contracts/GnosisSafe.sol#L145
Tool used
Manual Review
Recommendation
Use
safe.getThreshold()
instead ofsignatures.length / 65
Duplicate of #50
The text was updated successfully, but these errors were encountered: