fastTrackProposalExecution doesn’t check intendedRecipient
The fast-track execution path in the TemporalGovernor contract did not verify that a cross-chain message was addressed to that contract, unlike the normal queueing path. Because Wormhole messages are multicast, a guardian could execute a message intended for a different contract on another chain.
immeas Follow with 0xComfyCat, Vagner and 4 others
Originally disclosed on Code4rena
Submitted by immeas, also found by 0xComfyCat, Vagner, markus_ether, kutugu, ast3ros, and volodya
Wormhole cross chain communication is multicasted to all their supported chains:
Please notice that there is no destination address or chain in these functions. VAAs simply attest that “this contract on this chain said this thing.” Therefore, VAAs are multicast by default and will be verified as authentic on any chain they are brought to.
The TermporalGovernor contract handles this by checking queueProposal that the intendedRecipient is itself:
File: core/Governance/TemporalGovernor.sol
320: // Very important to check to make sure that the VAA we're processing is specifically designed
321: // to be sent to this contract
322: require(intendedRecipient == address(this), "TemporalGovernor: Incorrect destination");
There is also a fastTrackProposalExecution that the guardian can perform (owner is referred ot as guardian):
File: core/Governance/TemporalGovernor.sol
261: /// @notice Allow the guardian to process a VAA when the
262: /// Temporal Governor is paused this is only for use during
263: /// periods of emergency when the governance on moonbeam is
264: /// compromised and we need to stop additional proposals from going through.
265: /// @param VAA The signed Verified Action Approval to process
266: function fastTrackProposalExecution(bytes memory VAA) external onlyOwner {
267: _executeProposal(VAA, true); /// override timestamp checks and execute
268: }
This will bypass the queueProposal flow and execute commands immediately.
The issue here is that there is no check in _executeProposal that the intendedRecipient is this TemporalGovernor.
Impact
governor can execute any commands communicated across Wormhole as long as they are from a trusted source.
This requires that the targets line up between chains for a governor to abuse this. However only one target must line up as the .call made does not check for contract existence. Since “unaligned” addresses between chains will most likely not exist on other chains these calls will succeeed.
Proof of Concept
Test in TemporalGovernorExec.t.sol, all of the test is copied from testProposeFailsIncorrectDestination with just the change at the end where instead of calling queueProposal, fastTrackProposalExecution is called instead, which doesn’t revert, thus highligting the issue.
function testFasttrackExecuteSucceedsIncorrectDestination() public {
address[] memory targets = new address[](1);
targets[0] = address(governor);
uint256[] memory values = new uint256[](1);
values[0] = 0;
TemporalGovernor.TrustedSender[]
memory trustedSenders = new TemporalGovernor.TrustedSender[](1);
trustedSenders[0] = ITemporalGovernor.TrustedSender({
chainId: trustedChainid,
addr: newAdmin
});
bytes[] memory payloads = new bytes[](1);
payloads[0] = abi.encodeWithSignature( /// if issues use encode with selector
"setTrustedSenders((uint16,address)[])",
trustedSenders
);
/// wrong intendedRecipient
bytes memory payload = abi.encode(newAdmin, targets, values, payloads);
mockCore.setStorage(
true,
trustedChainid,
governor.addressToBytes(admin),
"reeeeeee",
payload
);
// guardian can fast track execute calls intended for other contracts
governor.fastTrackProposalExecution("");
}
Recommended Mitigation Steps
Consider adding a check in _executeProposal for intendedRecipient same as is done in _queueProposal.
ElliotFriedman (Moonwell) confirmed and commented:
This is a valid finding. However, in order for this to be exploitable, the proper governor would have to emit the proper calldata on another chain, with the exactly needed calldata formatting, and call publishMessage for this to be exploitable which is a 0% chance of happening.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the fast-track execution path calls the shared execution routine without the intended-recipient check that the queueing path performs.
Impact
The guardian could execute commands from a trusted source that were addressed to another contract, though the project notes this needs the proper governor on another chain to emit exactly matching calldata, which they consider very unlikely.
What the attacker needed
Guardian (owner) role; trusted sender on another chain; matching calldata emitted elsewhere
The fix
The execution routine should check the intended recipient the same way the queueing routine does.
How it was found
- Build a payload whose intended recipient is not the governor.
- Store it as a trusted message in the mock core contract.
- Call the fast-track execution function as the guardian.
- Observe that it does not revert, unlike the queueing path.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Cross-chain messages can be delivered to many chains at once, so a contract must check that a message was really meant for it. The normal path did this check, but the emergency fast-track path skipped it, so a message aimed at another contract could be run here instead.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.