-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"files": [ | ||
"certora/harnesses/Safe4337ModuleHarness.sol", | ||
"certora/harnesses/Account.sol", | ||
], | ||
"optimistic_loop": true, | ||
"msg": "Safe4337Module: Signatures Length Check", | ||
"rule_sanity": "basic", | ||
"solc": "solc8.23", | ||
"verify": "Safe4337ModuleHarness:certora/specs/SignatureLengthCheck.spec", | ||
"packages": [ | ||
"@account-abstraction=../../node_modules/.pnpm/@account-abstraction+contracts@0.7.0/node_modules/@account-abstraction", | ||
"@safe-global=../../node_modules/.pnpm/@safe-global+safe-contracts@1.4.1-build.0_ethers@6.13.1_bufferutil@4.0.8_utf-8-validate@5.0.10_/node_modules/@safe-global" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.8.0; | ||
import {Safe4337Module} from "./../../contracts/Safe4337Module.sol"; | ||
|
||
contract Safe4337ModuleHarness is Safe4337Module { | ||
constructor(address entryPoint) Safe4337Module(entryPoint) {} | ||
|
||
function checkSignaturesLength(bytes calldata signatures, uint256 threshold) external pure returns (bool) { | ||
return _checkSignaturesLength(signatures, threshold); | ||
} | ||
|
||
function combineBytes(bytes calldata signatures, bytes calldata data) external pure returns (bytes memory) { | ||
return abi.encode(signatures, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Account as safeContract; | ||
|
||
methods { | ||
function checkSignaturesLength(bytes, uint256) external returns(bool) envfree; | ||
function combineBytes(bytes, bytes) external returns(bytes) envfree; | ||
|
||
// Safe Contract functions | ||
function safeContract.containsContractSignature(bytes, uint256) external returns(bool) envfree; | ||
function safeContract.canonicalSignatureHash(bytes, uint256) external returns(bytes32) envfree; | ||
} | ||
|
||
// This rule verifies that if excess data is added to the dynamic part of the signature, then the signature check will fail. | ||
rule signatureLengthCheckDirectly(bytes signatures, bytes gasGriefingData, uint256 threshold) { | ||
require signatures.length > 0; | ||
require gasGriefingData.length > 0; | ||
assert checkSignaturesLength(signatures, threshold) => !checkSignaturesLength(combineBytes(signatures,gasGriefingData), threshold); | ||
} | ||
|
||
// This rule verifies that if excess data is added to the dynamic part of the signature, though it could pass in the safe contract's | ||
// `checkSignatures(...)`, it will be caught within the `_checkSignaturesLength(...)` call, as the dynamic length is checked. | ||
rule canonicalHashBasedLengthCheck(bytes signatures, bytes griefedSignatures, uint256 threshold) { | ||
require safeContract.canonicalSignatureHash(signatures, threshold) == safeContract.canonicalSignatureHash(griefedSignatures, threshold); | ||
require signatures.length < griefedSignatures.length; | ||
require safeContract.containsContractSignature(signatures, threshold); | ||
|
||
assert checkSignaturesLength(signatures, threshold) => !checkSignaturesLength(griefedSignatures, threshold); | ||
} |