-
Notifications
You must be signed in to change notification settings - Fork 958
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formal Verification for Safe v1.5 Audit (#901)
This pull request corresponds to the formal verification aspect of the Safe v1.5 audit done by Certora. ## Summary of Changes ### Added Configuration and Specification files corresponding to new rules: * `execute.conf` and `Execute.spec` * `extensible.conf` and `Extensible.spec` * `fallback.conf` and `Fallback.spec` * `guards.conf` and `Guards.spec` * `hash.conf` and `Hash.spec` * `setup.conf` and `Setup.spec` Harness: * `ExtensibleFallbackHandlerHarness.sol` to reason about the fallback handler Mocks: * `DummyHandler.sol` for reasoning about the fallback handler * `TxnGuardMock.sol` and `TxnGuardMockDuplicate.sol` for reasoning about the transaction guard * `ModuleGuardMock.sol` and `ModuleGuardMockDuplicate.sol` for reasoning about the module guard ### Modified * `applyHarness.patch` - added some minor munging as explained in the audit report * `run.conf` - remove a deprecated configuration tag that was giving errors to the Prover * `Safe.spec` - moved a rule about guards to `Guard.spec` for logical continuity * `SafeHarness.sol` - added some view functionality to the Safe harness for some rules Co-authored-by: Derek Sorensen <[email protected]>
- Loading branch information
1 parent
0372c8a
commit 8677f32
Showing
22 changed files
with
1,191 additions
and
28 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
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 @@ | ||
{ | ||
"files": [ | ||
"certora/harnesses/SafeHarness.sol", | ||
"certora/mocks/ModuleGuardMock.sol", // a module guard | ||
"certora/mocks/TxnGuardMock.sol", // a (safe) guard | ||
], | ||
"link": [ | ||
|
||
], | ||
"verify": "SafeHarness:certora/specs/Execute.spec", | ||
|
||
"assert_autofinder_success": true, | ||
"optimistic_summary_recursion": true, | ||
"optimistic_contract_recursion": true, | ||
|
||
"summary_recursion_limit": "2", | ||
"contract_recursion_limit": "2", | ||
"loop_iter": "3", | ||
"optimistic_loop": true, | ||
"optimistic_hashing": true, | ||
"optimistic_fallback": true, | ||
|
||
"rule_sanity": "basic", | ||
|
||
"solc": "solc7.6", | ||
"solc_via_ir": false, | ||
} |
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 @@ | ||
{ | ||
"files": [ | ||
"certora/harnesses/SafeHarness.sol", | ||
"certora/harnesses/ExtensibleFallbackHandlerHarness.sol", | ||
"certora/mocks/DummyHandler.sol" | ||
], | ||
"link": [ | ||
|
||
], | ||
"verify": "SafeHarness:certora/specs/Extensible.spec", | ||
|
||
"assert_autofinder_success": true, | ||
"optimistic_summary_recursion": true, | ||
"optimistic_contract_recursion": true, | ||
|
||
"summary_recursion_limit": "2", | ||
"contract_recursion_limit": "2", | ||
"loop_iter": "3", | ||
"optimistic_loop": true, | ||
"optimistic_hashing": true, | ||
"optimistic_fallback": true, | ||
|
||
"rule_sanity": "basic", | ||
|
||
"solc": "solc7.6", | ||
"solc_via_ir": false, | ||
} |
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 @@ | ||
{ | ||
"files": [ | ||
"certora/harnesses/SafeHarness.sol", | ||
"certora/harnesses/ExtensibleFallbackHandlerHarness.sol", | ||
"certora/mocks/DummyHandler.sol" | ||
], | ||
"link": [ | ||
|
||
], | ||
"verify": "SafeHarness:certora/specs/Fallback.spec", | ||
|
||
"assert_autofinder_success": true, | ||
"optimistic_summary_recursion": true, | ||
"optimistic_contract_recursion": true, | ||
|
||
"summary_recursion_limit": "2", | ||
"contract_recursion_limit": "2", | ||
"loop_iter": "3", | ||
"optimistic_loop": true, | ||
"optimistic_hashing": true, | ||
"optimistic_fallback": true, | ||
|
||
"rule_sanity": "basic", | ||
|
||
"solc": "solc7.6", | ||
"solc_via_ir": false, | ||
} |
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,35 @@ | ||
// a conf file for safe module guards | ||
{ | ||
"files": [ | ||
"certora/harnesses/SafeHarness.sol", | ||
"certora/mocks/ModuleGuardMock.sol", // a module guard | ||
"certora/mocks/ModuleGuardMockDuplicate.sol", | ||
"certora/mocks/TxnGuardMock.sol", // a (safe) guard | ||
"certora/mocks/TxnGuardMockDuplicate.sol", | ||
], | ||
"link": [ | ||
|
||
], | ||
"verify": "SafeHarness:certora/specs/Guards.spec", | ||
|
||
"assert_autofinder_success": true, | ||
"optimistic_summary_recursion": true, | ||
"optimistic_contract_recursion": true, | ||
|
||
"summary_recursion_limit": "2", | ||
"contract_recursion_limit": "2", | ||
"loop_iter": "3", | ||
"optimistic_loop": true, | ||
"optimistic_hashing": true, | ||
"optimistic_fallback": true, | ||
|
||
"rule_sanity": "basic", | ||
|
||
"solc": "solc7.6", | ||
"solc_via_ir": false, | ||
|
||
"prover_args": [ | ||
" -verifyCache -verifyTACDumps -testMode -checkRuleDigest -callTraceHardFail on", | ||
"-enableSolidityBasedInlining true" | ||
], | ||
} |
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,25 @@ | ||
{ | ||
"files": [ | ||
"certora/harnesses/SafeHarness.sol" | ||
], | ||
"link": [ | ||
|
||
], | ||
"verify": "SafeHarness:certora/specs/Hash.spec", | ||
|
||
"assert_autofinder_success": true, | ||
"optimistic_summary_recursion": true, | ||
"optimistic_contract_recursion": true, | ||
|
||
"summary_recursion_limit": "2", | ||
"contract_recursion_limit": "2", | ||
"loop_iter": "3", | ||
"optimistic_loop": true, | ||
"optimistic_hashing": true, | ||
"optimistic_fallback": true, | ||
|
||
"rule_sanity": "basic", | ||
|
||
"solc": "solc7.6", | ||
"solc_via_ir": false, | ||
} |
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,25 @@ | ||
{ | ||
"files": [ | ||
"certora/harnesses/SafeHarness.sol" | ||
], | ||
"link": [ | ||
|
||
], | ||
"verify": "SafeHarness:certora/specs/Setup.spec", | ||
|
||
"assert_autofinder_success": true, | ||
"optimistic_summary_recursion": true, | ||
"optimistic_contract_recursion": true, | ||
|
||
"summary_recursion_limit": "2", | ||
"contract_recursion_limit": "2", | ||
"loop_iter": "3", | ||
"optimistic_loop": true, | ||
"optimistic_hashing": true, | ||
"optimistic_fallback": true, | ||
|
||
"rule_sanity": "basic", | ||
|
||
"solc": "solc7.6", | ||
"solc_via_ir": false, | ||
} |
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,11 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
import "../munged/handler/ExtensibleFallbackHandler.sol"; | ||
import {ISafe} from "../munged/interfaces/ISafe.sol"; | ||
|
||
contract ExtensibleFallbackHandlerHarness is ExtensibleFallbackHandler { | ||
|
||
function getSafeMethod(ISafe safe, bytes4 selector) public view returns (bytes32) { | ||
return safeMethods[safe][selector]; | ||
} | ||
|
||
} |
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,24 @@ | ||
// a dummy handler contract | ||
import {ISafe, IStaticFallbackMethod, IFallbackMethod, ExtensibleBase} from "../munged/handler/extensible/ExtensibleBase.sol"; | ||
|
||
contract DummyHandler is IFallbackMethod { | ||
constructor(){ | ||
methodCalled = false ; | ||
} | ||
|
||
bool public methodCalled ; | ||
function resetMethodCalled() public { | ||
methodCalled = false; | ||
} | ||
|
||
// the DUMMY method | ||
function handle(ISafe safe, address sender, uint256 value, bytes calldata data) external override returns (bytes memory result) { | ||
methodCalled = true ; | ||
|
||
return "Hello, world!"; | ||
} | ||
|
||
function dummyMethod() public { | ||
methodCalled = true ; | ||
} | ||
} |
Oops, something went wrong.