File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ library SignatureValidator {
1414 EIP712,
1515 EthSign,
1616 SmartWallet,
17- Spoof
17+ Spoof,
18+ // WARNING: must always be last
19+ LastUnused
1820 }
1921
2022 // bytes4(keccak256("isValidSignature(bytes32,bytes)"))
@@ -28,6 +30,8 @@ library SignatureValidator {
2830 require (sig.length >= 1 , "SV_SIGLEN " );
2931 uint8 modeRaw;
3032 unchecked { modeRaw = uint8 (sig[sig.length - 1 ]); }
33+ // Ensure we're in bounds for mode; Solidity does this as well but it will just silently blow up rather than showing a decent error
34+ require (modeRaw < uint8 (SignatureMode.LastUnused), "SV_SIGMODE " );
3135 SignatureMode mode = SignatureMode (modeRaw);
3236
3337 // {r}{s}{v}{mode}
@@ -56,10 +60,12 @@ library SignatureValidator {
5660 return address (wallet);
5761 // {address}{mode}; the spoof mode is used when simulating calls
5862 } else if (mode == SignatureMode.Spoof && allowSpoofing) {
63+ // This is safe cause it's specifically intended for spoofing sigs in simulation conditions, where tx.origin can be controlled
64+ // slither-disable-next-line tx-origin
5965 require (tx .origin == address (1 ), "SV_SPOOF_ORIGIN " );
6066 require (sig.length == 33 , "SV_SPOOF_LEN " );
6167 sig.trimToSize (32 );
6268 return abi.decode (sig, (address ));
63- } else revert ( " SV_SIGMODE " ) ;
69+ };
6470 }
6571}
You can’t perform that action at this time.
0 commit comments