Repository: ghost-dao-contracts ( ghostchain/ghost-dao-contracts: Logic behind the ghostDAO protocol - ghost-dao-contracts - Git for ghostchain project )
Revision audited: 22a9325e3ffb710f485a564549627db331f80329
Files: src/Gatekeeper.sol L216-232, src/types/StorageHistory.sol L39-43
Why this is filed as a question and not as a vulnerability
The code path below looks deliberate: there is a dedicated GovernanceExecutionFailed event
(src/interfaces/IGatekeeper.sol:26) emitted exactly when the target call fails, and marking the session before the dispatch is a standard replay/reentrancy guard. So this is not a coding slip and we are not claiming fund loss.
We are raising it because the observable consequence of those two deliberate choices together is a state that no consumer of the interface can distinguish from success, and that cannot be undone:
StorageHistory.isTransactionExecuted(session)returnstruefor a governance action that never took
effect, and- the same signed action can never be retried (
trySetTransactionExecutedrevertsAlreadyExecuted).
If “one attempt per session, no retry, failure is terminal” is intended, then this is informational and we would ask for nothing, but a one-line confirmation (or a note in the NatSpec) would be useful, because the flag currently reads as “this governance action happened”.
Observed behaviour (code)
// src/Gatekeeper.sol
function govern(uint256 exodusSession, uint256 packed, bytes calldata call) external {
if (msg.sender != address(this)) revert NotGatekeeper(); // L221
GhostPacking.GovernancePayload memory payload = GhostPacking.unpackGovernance(packed);
if (payload.chainId != block.chainid) revert WrongChainId(); // L224
StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession); // L226 — marked FIRST
(bool success, bytes memory ret) = payload.target.call(call); // L228 — dispatch
if (!success) {
emit GovernanceExecutionFailed(exodusSession, payload.target, ret); // L229-231 — logs, does not revert
}
}
// src/types/StorageHistory.sol
function trySetTransactionExecuted(uint256 session) external override {
if (msg.sender != _currentOwner) revert NotOwner();
if (_executedTransaction.get(session)) revert AlreadyExecuted(); // L41-42 — second attempt always reverts
_executedTransaction.set(session);
}
Since govern returns normally, the enclosing signed verify() call succeeds too, so nothing rolls the bit back.
Reproduction (Foundry, real contracts)
The project’s own governance tests only dispatch to 0x0101…0101, an address with no code, calls to it always succeed in the EVM, so the failure path is not exercised anywhere in the suite. The test below exercises it.
function test_govern_marks_session_executed_when_target_reverts() public {
RevertingTarget target = new RevertingTarget(); // reverts with Nope()
StorageHistory history = StorageHistory(gk.storageHistory());
uint256 session = 42;
uint256 packed = (uint256(block.chainid) << 192) | (uint256(uint160(address(target))) << 32);
bytes memory call = abi.encodeCall(RevertingTarget.boom, ());
assertFalse(history.isTransactionExecuted(session));
vm.prank(address(gk)); // only the Gatekeeper may call govern
gk.govern(session, packed, call); // target reverts; govern logs and returns
assertTrue(history.isTransactionExecuted(session),
"session marked executed although the dispatched call reverted");
vm.prank(address(gk));
vm.expectRevert(); // AlreadyExecuted
gk.govern(session, packed, call); // the action can never be retried
}
$ forge test --match-path test/audit/GhostBountyPoC.t.sol
[PASS] test_govern_marks_session_executed_when_target_reverts() (gas: 240870)
Questions for the team
- Is it intended that a governance action which fails on dispatch is recorded as executed and can never be retried with that session?
- If yes: would you consider making the failure state distinguishable (e.g. a separate “attempted” marker, or
documenting thatisTransactionExecuted == truemeans “attempted” and not “succeeded”)? Right now the flag is consumed as proof that the action happened. - If no: the minimal change is to write the executed bit only when
successis true, or to revert on failure so the signed session stays retryable.
Suggested minimal change (optional)
- StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession);
-
(bool success, bytes memory ret) = payload.target.call(call);
- if (!success) {
- emit GovernanceExecutionFailed(exodusSession, payload.target, ret);
- }
+ if (!success) {
+ emit GovernanceExecutionFailed(exodusSession, payload.target, ret);
+ revert GovernanceTargetFailed(); // session stays retryable
+ }
+ StorageHistory(storageHistory).trySetTransactionExecuted(exodusSession);
(If retry must stay impossible, keeping the write before the call is fine, the only ask is that the interface semantics be documented, since the flag is currently indistinguishable from a successful execution.)
Novelty check (done before posting)
The Bug Bounty category was enumerated in full (~80 topics over 3 pages) and searched with terms specific to this behaviour: GovernanceExecutionFailed → 0 results forum-wide; isTransactionExecuted, mark executed before, session burned, cannot be retried, govern revert → only unrelated reports (verify signature replay #134, key-epoch invalidation #125/#162, rotate chain-binding #117/#159, deployer key registration #85/#160, GhostGovernor proposal lock #119). The closest neighbour, #134, covers the opposite case: a signed call that never reaches trySetTransactionExecuted at all.
Honesty statement
No funds are lost and nothing is unauthorised: reaching govern requires a valid authority signature, and the consequence only materialises when the signed target call reverts. This is submitted as a design question about interface semantics and recoverability, not as an exploit.