Skip to content
Business logic Audit finding Intermediate

High risk checks can be bypassed with extra `calldata` padding

The high-risk proposal check in the governance contract used strict length equality on calldata, so adding extra unused bytes made a high-risk proposal appear low-risk. An attacker could then pass a high-risk proposal with a lower quorum.

IllIllI Follow with Kow, cawfree and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-01-olympus-on-chain-governance-judging/issues/100

Found by

IllIllI, Kow, cawfree, fibonacci, haxatron, r0ck3tz

Summary

Adding extra unused bytes to proposal calldata can trick the _isHighRiskProposal() function

Vulnerability Detail

The length checks on the transaction calldata of what falls into the 'high risk' proposal category is too strict, and incorrectly fails with extra padding. In solidity, any extra bytes of calldata, beyond what is required to satisfy the function arguments, are ignored, and have no effect on the operation of the function being called.

Impact

A proposal that should have been flagged as high risk, is not, and therefore can be passed with the easier, lower, quorum. This violates a critical invariant.

Code Snippet

Checks for calls to the kernel's executeAction() function, expect exactly the right number of bytes to satisfy the function arguments, and no more:

Solidity
// File: src/external/governance/GovernorBravoDelegate.sol : GovernorBravoDelegate._isHighRiskProposal()   #1

631                    // Check if the action is making a core change to system via the kernel
632                    if (selector == Kernel.executeAction.selector) {
633                        uint8 action;
634                        address actionTarget;
635    
636 @>                     if (bytes(signature).length == 0 && data.length == 0x44) {
637                            assembly {
638                                action := mload(add(data, 0x24)) // accounting for length and selector in first 4 bytes
639                                actionTarget := mload(add(data, 0x44))
640                            }
641 @>                     } else if (data.length == 0x40) {
642                            (action, actionTarget) = abi.decode(data, (uint8, address));
643                        } else {
644                            continue;
645:                       }

https://github.com/sherlock-audit/2024-01-olympus-on-chain-governance/blob/main/bophades/src/external/governance/GovernorBravoDelegate.sol#L631-L645

this results in an easier quorum threshold:

Solidity
// File: src/external/governance/GovernorBravoDelegate.sol : GovernorBravoDelegate.propose()   #2

168                // Identify the quorum level to use
169 @>             if (_isHighRiskProposal(targets, signatures, calldatas)) {
170                    quorumVotes = getHighRiskQuorumVotes();
171                } else {
172 @>                 quorumVotes = getQuorumVotes();
173:               }

https://github.com/sherlock-audit/2024-01-olympus-on-chain-governance/blob/main/bophades/src/external/governance/GovernorBravoDelegate.sol#L168-L173

Tool used

Manual Review

Recommendation

Change length checks to be >=, rather than strict equality, since the function signature already specifies the number of arguments

PoC

The following test shows that extending the calldata by an empty byte still triggers a valid call to executeAction(), but is categorized as lower severity:

Diff
diff --git a/bophades/src/test/external/GovernorBravoDelegate.t.sol b/bophades/src/test/external/GovernorBravoDelegate.t.sol
index 778163c..bdb6ae2 100644
--- a/bophades/src/test/external/GovernorBravoDelegate.t.sol
+++ b/bophades/src/test/external/GovernorBravoDelegate.t.sol
@@ -386,6 +386,10 @@ contract GovernorBravoDelegateTest is Test {
         assertEq(quorum, 200_000e18);
     }
 
+    function executeAction(Actions action_, address target_) external {
+        console2.log("executed with extra calldata");
+    }
+
     function testCorrectness_proposeCapturesCorrectQuorum_highRisk() public {
         // Activate TRSRY
         vm.prank(address(timelock));
@@ -404,9 +408,12 @@ contract GovernorBravoDelegateTest is Test {
         calldatas[0] = abi.encodeWithSelector(
             kernel.executeAction.selector,
             Actions.ActivatePolicy,
-            address(custodian)
+            address(custodian),
+            ""
         );
 
+        address(this).call(calldatas[0]);
+
         vm.prank(alice);
         bytes memory data = address(governorBravoDelegator).functionCall(
             abi.encodeWithSignature(

Output:

Text
% forge test --match-test testCorrectness_proposeCapturesCorrectQuorum_highRisk -vv
...
[FAIL. Reason: assertion failed] testCorrectness_proposeCapturesCorrectQuorum_highRisk() (gas: 568208)
Logs:
  executed with extra calldata
  Error: a == b not satisfied [uint]
    Expected: 300000000000000000000000
      Actual: 200000000000000000000000

Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 14.92ms
...

Discussion

0xLienid

Valid, will fix by reverting if the calldata doesn't match the right size since we know what the size must be for an executeAction call

0xLienid

Fix: https://github.com/OlympusDAO/bophades/pull/299

IllIllI000

The PR introduces a new revert error, and reverts if the length is longer than expected, rather than allowing the code to continue if the calldata is longer than expected. Since the selector ensures that the right number of arguments is passed, there is no error in restricting possible future uses of extra calldata. The PR also adds a test.

The original report as published on Sherlock, by IllIllI. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

The code used strict equality (==) to check calldata length instead of a minimum length check (>=), so extra padding bypassed the high-risk classification.

Impact

A proposal that should require a high quorum could be passed with a lower quorum, violating a critical invariant.

What the attacker needed

Ability to submit a governance proposal

The fix

The fix reverts if the calldata length does not match the expected size for an executeAction call.

How it was found

  1. Create a proposal that calls the kernel's executeAction function with extra empty bytes appended to the calldata.
  2. Submit the proposal through the propose function.
  3. The _isHighRiskProposal function fails to recognise it as high risk because the length check uses strict equality.
  4. The proposal is assigned the lower quorum threshold instead of the high-risk one.

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.

A governance contract decides how many votes are needed to pass a proposal. It checks if a proposal is 'high risk' by looking at the exact size of the data sent. If you add extra empty bytes to that data, the check fails to recognise it as high risk, so the proposal needs fewer votes to pass.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by IllIllI

View all

119 more disclosed reports, best first.

More from Olympus On-Chain Governance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.