Open howlbot-integration[bot] opened 1 month ago
We will disregard the proposed mitigation, cuz incorrect. Instead, we will extend the signature by introducing nonce, creator, and executor. However, I believe this issue should be classified as Medium rather than High. Addresses that appear to be invalid artist addresses are easily verifiable on the frontend (for example, by checking for lack of prior history). Additionally, artists have certification badges through EAS (Ethereum Attestation Service). so, we don't necessarily see a problem with multiple arts being created, but let me improve our logic by this.
struct SignatureData {
uint256 expiresIn;
uint256 nonce;
address creator;
address executor;
string uri;
bytes credData;
}
function createArt(
bytes calldata signedData_,
bytes calldata signature_,
CreateConfig memory createConfig_
)
external
payable
nonReentrant
whenNotPaused
returns (address)
{
_validateArtCreationSignature(signedData_, signature_);
SignatureData memory data = abi.decode(signedData_, (SignatureData));
ERC1155Data memory erc1155Data = _createERC1155Data(artIdCounter, createConfig_, data.uri, data.credData);
address artAddress = createERC1155Internal(artIdCounter, erc1155Data);
nonces[_msgSender()]++;
artIdCounter++;
return artAddress;
}
function _validateArtCreationSignature(bytes memory signedData_, bytes calldata signature_) private view {
SignatureData memory data = abi.decode(signedData_, (SignatureData));
if (_recoverSigner(keccak256(signedData_), signature_) != phiSignerAddress) revert AddressNotSigned();
if (data.expiresIn <= block.timestamp) revert SignatureExpired();
if (data.creator != address(0) && data.creator != _msgSender()) revert InvalidCreator();
if (data.executor != address(0) && data.executor != _msgSender()) revert InvalidExecutor();
if (data.nonce != nonces[_msgSender()]) revert InvalidNonce();
}
fatherGoose1 changed the severity to 2 (Med Risk)
fatherGoose1 changed the severity to 3 (High Risk)
High. This vulnerability would undermine the entire art creation process.
fatherGoose1 marked the issue as satisfactory
fatherGoose1 marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2024-08-phi/blob/8c0985f7a10b231f916a51af5d506dd6b0c54120/src/PhiFactory.sol#L196-L213 https://github.com/code-423n4/2024-08-phi/blob/8c0985f7a10b231f916a51af5d506dd6b0c54120/src/PhiFactory.sol#L551-L568
Vulnerability details
Impact
Loss of funds: anyone can frontrun the
createArt
transaction, reusing the original signature but supplying their own config. As a result the artist, the royalties recipient, as well the the royalty BPS can be set arbitrarily, leading to stealing the royalties from the artist, and achieving other impacts.Summary
Function PhiFactory::createArt() doesn't limit the signature to either the specific submitter, nor does it include into the signed data the
CreateConfig
parameters, which in particular include theartist
, the royaltiesreceiver
, as well as other parameters. Other impacts are possible but here is one specific scenario:createArt
transactioncreateArt
transaction in the mempool, and frontruns it, reusing the signature, but with their own config where they are the royalties recipientPhiNFT1155
contract is created, as well as when it exists alreadyArtContractCreated
andNewArtCreated
events are emitted correctly (onlyNewArtCreated
is emitted twice).As a result, the attacker gets all rewards sent to the
PhiRewards
contract fromPhiNFT1155
when the legitimate party claims an NFT token (see PhiNFT1155::claimFromFactory()).Other possible impacts (a non-exclusive list):
artist
, and gets the possibility to call the PhiNFT1155::updateRoyalties() function, thus setting theroyaltyBPS
to arbitrary value.artist
, and gets the possibility to call the PhiFactory::updateArtSettings() function, thus setting the parameters to arbitrary values, e.g.maxSupply
,endTime
, ormintFee
.Proof of Concept
Drop this test to PhiFactory.t.sol and execute via
forge test --match-test Kuprum
Tools Used
Manual review; Foundry.
Recommended Mitigation Steps
We recommend the following steps:
CreateConfig
parametersAssessed type
Invalid Validation