Diamond upgrade proposition can be falsified
The proposal ID for a Diamond upgrade was computed only from facet changes, ignoring the initialisation function and its calldata. A malicious or compromised admin could therefore execute arbitrary code via delegatecall while the proposal appeared to match the approved changes.
Submitted by Czar102, also found by shenwilly
DiamondCutFacet.sol#L16-L29 LibDiamond.sol#L94-L118 LibDiamond.sol#L222-L240
Diamond is to be upgraded after a certain delay to give time to the community to verify changes made by the developers. If the proposition can be falsified, the contract admins can exploit the contract in any way of their choice.
Proof of Concept
To determine the id of the proposal, only its facet changes are hashed, skipping two critical pieces of data - the _init and _calldata. During a diamond upgrade, devs can choose what code will be executed by the contract using a delegatecall. Thus, they can make the contract perform any actions of their choice.
Recommended Mitigation Steps
Add _init and _calldata to the proposition hash.
jakekidd (Connext) confirmed and resolved:
Resolved by connext/nxtp@63badc8
0xleastwood (judge) decreased severity to Medium and commented:
I consider this to be severe, however, it does require a malicious or compromised governance. Because of this, I would prefer to have this downgraded to
mediumseverity.
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 proposal hash omitted the `_init` and `_calldata` fields, so the ID did not commit to the full upgrade payload.
Impact
A malicious or compromised governance could execute arbitrary actions via delegatecall, though the judge noted this requires malicious or compromised governance and downgraded severity to medium.
What the attacker needed
Malicious or compromised governance
The fix
The issue was fixed by including `_init` and `_calldata` in the proposition hash.
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 Diamond is a smart contract that can be upgraded by swapping out parts of its code. The upgrade proposal ID was calculated without including the setup code that runs during the upgrade, so an attacker with admin rights could run any code they wanted while the proposal looked legitimate.
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.