Skip to content
Access control Audit finding Advanced

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.

Czar102 Follow

Originally disclosed on Code4rena

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 medium severity.


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

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.

More by Czar102

View all

12 more disclosed reports, best first.

More from Connext Amarok contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.