Open c4-bot-7 opened 2 months ago
All data is signed by phiSignerAddress
fatherGoose1 marked the issue as unsatisfactory: Invalid
@fatherGoose1
Above all, the createArt
function is accessible to anyone wishing to create their own art pieces. While all data is indeed signed by the phiSignerAddress
, individuals can potentially attach their own signatures and merkle proofs to go through the art creation process - which results in above issue.
This vulnerability was likely demonstrated in the previous proof of concept (PoC). Malicious actors can exploit this to invalidate the minting capability of existing artworks by overwriting the merkle proof.
This poses a risk of financial loss to artists who have paid art creation fees and invested in their artworks. I strongly recommend that the protocol be designed to prevent such actions, safeguarding users' rights to claim and protecting them from potential losses, provided it's feasible.
Thank you for reconsidering this matter!
But the phiSignerAddress
would need to sign twice, with cred datas:
credData = abi.encode(1, owner, "MERKLE", 31_337, expectedRoot1);
AND
credData = abi.encode(1, owner, "MERKLE", 31_337, expectedRoot2);
I'm unsure what you mean by individuals can potentially attach their own signatures and merkle proofs to go through the art creation process
. They can only attach what the PhiSigner signs. Could you please clarify?
Sure,
Individuals (not particularly an attacker) may use same credId
and credChainId
to create their own arts. Since this request comes legitimate, they can have their own expectedRoot
signed with which they intend to verify claims.
For those NFT contracts, a check is in place to re-use already created contract in createERC1155Internal
, but _initializePhiArt
doesn't check such conditions.
This would be unlikely to occur, but I agree it should be checked. QA
fatherGoose1 changed the severity to QA (Quality Assurance)
fatherGoose1 marked the issue as grade-a
Lines of code
https://github.com/code-423n4/2024-08-phi/blob/main/src/PhiFactory.sol#L617 https://github.com/code-423n4/2024-08-phi/blob/main/src/PhiFactory.sol#L365
Vulnerability details
Impact
The
credMerkleRoot[credChainId][credId]
can be overwritten, potentially erasing the previouscredMerkleRoot
for art creators with the samecredChainId
andcredId
. If those former creators utilized theMERKLE
type, they would be unable to claim.Proof of Concept
Art creators utilize the
createArt
function in thePhiFactory
contract to generate new Art. Based on thecredChainId
andcredId
provided, either a newPhiNFT1155
contract is created, or an existing contract is reused. During the retrieval of the art contract in thecreateERC1155Internal
function, new art data is initialized through the_initializePhiArt
function, wherecredMerkleRoot[credChainId][credId]
is set up.Here, we face an issue for art creators using the
MERKLE
type. ThecredMerkleRoot[credChainId][credId]
might already be initialized by a previous creator with the samecredChainId
andcredId
. Without a check for an existing value, it is overwritten with the newmerkleRootHash
regardless of whether it matches. If overwritten with a different hash, it poses a problem for the previous creator, ascredMerkleRoot[credChainId][credId]
is crucial for verifying the merkleProof during NFT claims in themerkleClaim
function.Without its original root hash, the function will revert with an
InvalidMerkleProof
error.Here's a PoC to prove the claiming fails. Full script can be found here.
Run the test by
Tools Used
Manual Review
Recommended Mitigation Steps
Verify if
credMerkleRoot[credChainId][credId]
already exists and matches the current value if previously set.Assessed type
Error