Skip to content
Access control Audit finding Beginner

Escher721 contract does not have setTokenRoyalty function

The Escher721 contract lacks a public setTokenRoyalty function, so artists cannot set a per-token royalty as the documentation states. An artist could not configure a custom royalty receiver for an individual token.

HollaDieWaldfee Follow with 0xNazgul, hansfriese and 2 others

Originally disclosed on Code4rena

Submitted by HollaDieWaldfee, also found by 0xNazgul, hansfriese, cccz, and obront

On the Code4rena page of this contest there is a “SALES PATTERNS” section that describes the flow of how to use Sales:

https://code4rena.com/contests/2022-12-escher-contest

It contains this statement:

If the artist would like sales and royalties to go somewhere other than the default royalty receiver, they must call setTokenRoyalty with the following variables

So an artist should be able to call the setTokenRoyalty function on the Escher721 contract.

However this function cannot be called. It does not exist. There exists a _setTokenRoyalty in ERC2981.sol from OpenZeppelin. This function however is internal (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/3d7a93876a2e5e1d7fe29b5a0e96e222afdc4cfa/contracts/token/common/ERC2981.sol#L94).

So there is no setTokenRoyalty function that can be called by the artist. So an artist cannot set a royalty individually for a token as is stated in the documentation.

Proof of Concept

I tried calling setTokenRoyalty from inside Escher721.t.sol with the following test:

function test_setDefaultRoyalty() public {
    edition.setTokenRoyalty(1,address(this), 5);
}

This won’t even compile because the setTokenRoyalty function does not exist.

Tools Used

VS Code

Recommended Mitigation Steps

In order to expose the internal _setTokenRoyalty function to the artist, add the following function to the Escher721 contract:

function setTokenRoyalty(
    uint256 tokenId,
    address receiver,
    uint96 feeNumerato r
) public onlyRole(DEFAULT_ADMIN_ROLE) {
    _setTokenRoyalty(tokenId,receiver,feeNumerator);
}

mehtaculous (Escher) disputed


The original report as published on Code4rena, by HollaDieWaldfee. 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

Likely the contract inherited OpenZeppelin's ERC2981, which only provides an internal royalty setter, and the developers never added a public wrapper for it.

Impact

Artists could not set a royalty individually for a token as the documentation promised.

What the attacker needed

Artist role on the contract

The fix

A public setTokenRoyalty function should be added to Escher721 that calls the internal _setTokenRoyalty, restricted to the admin role.

How it was found

  1. Attempt to call setTokenRoyalty on the Escher721 contract from a test.
  2. Observe that the code does not compile because the function does not exist.

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 royalty is a payment made to the creator each time a token is resold. The project's instructions said artists could choose where that payment goes for each token, but the code never included a way to do that, so the feature simply could not be used.

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 HollaDieWaldfee

View all

39 more disclosed reports, best first.

More from Escher 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.