Artist signatures can be forged to impersonate the artist behind a collection
The setCollectionData function allowed a collection admin to set an artist address while the total supply was zero, then have that fake artist sign the collection, and finally change the artist address to a legitimate one. This let a collection admin impersonate any artist and make it appear that the legitimate artist had signed the collection.
The_Kakers Follow with mrudenko, alexfilippov314 and 9 others
Originally disclosed on Code4rena
Submitted by The_Kakers, also found by mrudenko, alexfilippov314, xuwinnie, xAriextz, Draiakoo, Stryder, 0xblackskull, VAD37, rotcivegaf, BugzyVonBuggernaut, and zach
Artist signatures can be forged, making it possible to sign any message, while “proving” that it was signed by any address.
This can be done to impersonate any address from any artist, breaking a core protocol functionality, and losing users’ trust. The signature can’t be deleted by anyone, nor the artist address, once the collection is signed.
This also breaks one of the main invariants of the protocol:
Properties that should NEVER be broken under any circumstance:
- Only artists can sign their collections.
Evaluated as Medium since it breaks a core contract functionality, and a main invariant, regardless of trusted roles. As any collection admin can impersonate any legit address, which should be consider a way to “escalate their authority beyond their role” as mentioned on the Access Control and Permissions Attack Ideas.
Proof of Concept
setCollectionData() allows to set the artist address when the current collectionTotalSupply == 0:
The problem is that it doesn’t check that the param collectionTotalSupply passed is != 0. Meaning that the function can be executed multiple times to change the artist address, as long as the total supply is zero:
So, it can be called first to set a fake artist address to call artistSignature() to sign the collection:
And then call setCollectionData() again to set the legit artist address.
Once the signature is set, it can’t be changed, nor the artist address, as it will always fall under the else clause:
The following coded POC shows how it can be done.
Coded Proof of Concept
- Run
forge init --no-git --forceto initiate Foundry on the root of the project. - Create
test/Poc.t.soland copy the snippet below. - Run
forge test.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Test, console2} from "forge-std/Test.sol";
import {NextGenAdmins} from "smart-contracts/NextGenAdmins.sol";
import {NextGenCore} from "smart-contracts/NextGenCore.sol";
contract AuctionTest is Test {
NextGenAdmins admin;
NextGenCore gencore;
address collectionAdmin;
function setUp() public {
admin = new NextGenAdmins();
gencore = new NextGenCore("core", "core", address(admin));
string[] memory collectionScript = new string[](0);
gencore.createCollection(
"Name", "Artist", "Description", "Website", "License", "https://base-uri.com/" "Library", "Script", new string[](0)
);
uint256 collectionId = 1;
collectionAdmin = makeAddr("collectionAdmin");
admin.registerCollectionAdmin(collectionId, collectionAdmin, true);
}
function testArtistSignature() public {
uint256 collectionId = 1;
address fakeArtist = collectionAdmin;
uint256 maxCollectionPurchases = 10;
uint256 zeroSupply = 0; // Supply = 0 allows this attack
uint256 setFinalSupplyTimeAfterMint = block.timestamp + 30 days;
// The collection admin sets the initial collection data with a fake artist
vm.prank(collectionAdmin);
gencore.setCollectionData(
collectionId,
fakeArtist,
maxCollectionPurchases,
zeroSupply,
setFinalSupplyTimeAfterMint
);
// Then uses the fake artist address to sign a message impersonating a legit artist
string memory fakeSignature = "I am the Legit Artist Behind CryptoPunks. This is my signature.";
vm.prank(fakeArtist);
gencore.artistSignature(collectionId, fakeSignature);
address legitArtist = makeAddr("legitArtist");
uint256 realTotalSupply = 1000;
// Finally sets the "initial" collection data again, but with the legit artist address and the real total supply
vm.prank(collectionAdmin);
gencore.setCollectionData(
collectionId,
legitArtist,
maxCollectionPurchases,
realTotalSupply,
setFinalSupplyTimeAfterMint
);
// The result is a collection impersonating a legit address, with a fake signature as a proof
assertEq(gencore.retrieveArtistAddress(collectionId), legitArtist);
assertEq(gencore.artistsSignatures(collectionId), fakeSignature);
}
}
Recommended Mitigation Steps
One way to prevent this is by checking that the collection total supply is set to a value > 0:
function setCollectionData(
uint256 _collectionID,
address _collectionArtistAddress,
uint256 _maxCollectionPurchases,
uint256 _collectionTotalSupply,
uint _setFinalSupplyTimeAfterMint
) public CollectionAdminRequired(_collectionID, this.setCollectionData.selector) {
require(
(isCollectionCreated[_collectionID] == true) &&
(collectionFreeze[_collectionID] == false) &&
+ (_collectionTotalSupply > 0)
(_collectionTotalSupply <= 10000000000
), "err/freezed");
The Warden specifies a potential attack path in the artist configuration of a collection by weaponizing the absence of an input sanitization for the
_collectionTotalSupplyargument.Specifically, they envision the following scenario:
- A collection is initialized with an artist but a zero
_collectionTotalSupplyvalue.- An artist signs the collection (this is permitted by
artistSignature).- A collection is re-initialized as the
ifstructure enters the first conditional, this time with a non-zero collection supply and a different artist.At this point, the collection will have a different artist than the one that signed the collection which breaks an invariant of the protocol and is incorrect behavior.
The Sponsor disputes this submission, but I invite them to re-consider the above step-by-step scenario which is presently possible in the codebase.
I believe that a medium-risk rating for this is correct, as the artist associated with a collection is crucial to the collection’s value, and a collection will appear “signed” even if the artist did not sign it.
The Warden’s submission was selected as the best due to pinpointing the exact problem in the codebase, outlining a step-by-step scenario via which it can be exploited, and assigning it an apt risk rating.
a2rocket (NextGen) disputed and commented:
NextGen admins are responsible for setting up a collection. The steps are here.
No one can sign a collection besides the address that was set during step 2, so the statement that anyone can impersonate artist is totally wrong!
The collection is deemed finalized when a
totalSupplyis set! Once atotalsupplyis set and the artist did not sign, the address of the artist can change. Once the artist signs the collection the signature cannot change. This is the process.
MrPotatoMagic (warden) commented:
@0xsomeone, this issue should be marked QA at most or even invalid imo. Here is why:
- In the follow-up feedback from the sponsor above, @a2rocket clearly mentions NextGen admins are responsible for setting up a collection. This means not anyone can just create a collection and launch this attack since it requires the NextGen team’s trust in a set of people.
- Even after the filtering process by the NextGen team, the signature can never be forged because on the blockchain you can clearly see who signed the transaction i.e. the call to artistSignature(), which can only be made by the current address set for the collection.
- Forgery of signature would only make sense for legal purposes and the proof of who signed artistSignature() is present on the Ethereum blockchain.
- If a collection turns out to be malicious, the NextGen team can just warn users and remove that specific collection from their frontend.
Due to all of these reasons, this issue should be QA or invalid.
@MrPotatoMagic, thanks for providing feedback on this! The submission has been graded as medium in severity due to breaking a core invariant of the protocol, which is that when an artist is associated with a particular collection and has signed it it cannot be altered.
- The response by the Sponsor concerning NextGen administrators is invalid. You can evaluate the code yourself and see that the collection administrator can independently perform these actions with no input from the administrative team of NextGen.
- The signature is forced because there is no obligation to provide any form of data in the
artistSignaturecall. Yes, anyone can go on-chain and see when theartistSignaturewas invoked using off-chain tracking tools but that does not correspond to the on-chain data reality. The on-chain data says that the collection has been signed by an artist who never did so, and this is an irreversible change even by administrators.- See #2 above.
- This is invalid reasoning as the same principle could apply to a wide variety of submissions in this context.
Conclusion - A core invariant of the protocol has been demonstrated to be possible to break with no input by the NextGen administrators whatsoever. Additionally, this invariant is irreversibly broken and cannot be rescued even by administrative action.
As such, I retain my judgment on this submission as being of medium-risk severity.
Note: For full discussion, see here.
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 setCollectionData function did not require the collection total supply to be greater than zero, allowing it to be called multiple times to change the artist address before the supply was finalised.
Impact
A collection admin could impersonate any artist and make it appear that the artist signed a collection, breaking a core protocol invariant; the fake signature and the artist address cannot be changed afterwards.
What the attacker needed
Caller is a collection admin; collection total supply is zero
The fix
The setCollectionData function should be fixed by requiring the collection total supply to be greater than zero.
How it was found
- Call setCollectionData with a fake artist address and a total supply of zero.
- Call artistSignature from the fake artist address to sign the collection.
- Call setCollectionData again with the legitimate artist address and a non-zero total supply.
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 collection admin could first set a fake artist address, have that fake address sign the collection, and then change the artist address to a real artist. Because the signature cannot be changed afterwards, the collection would appear to be signed by the real artist even though they never signed it.
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.