When PhiFactory.claim
function is called with a msg.value
that is more than total mint fee, the difference between such msg.value
and total mint fee cannot be refunded to caller of such function
#28
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-109
🤖_primary
AI based primary recommendation
🤖_04_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-08-phi/blob/3a817c9dedca53ea27ff3e7988f8389086935b8b/src/PhiFactory.sol#L723-L758
https://github.com/code-423n4/2024-08-phi/blob/3a817c9dedca53ea27ff3e7988f8389086935b8b/src/PhiFactory.sol#L264-L304
Vulnerability details
Impact
As a part of the refund mechanisms throughout the protocol, the
PhiFactory._processClaim
function, which is eventually called by thePhiFactory.claim
function, would executeuint256 mintFee = getArtMintFee(artId_, quantity_)
andif ((etherValue_ - mintFee) > 0) { _msgSender().safeTransferETH(etherValue_ - mintFee); }
for handling a refund. Also, https://docs.philand.xyz/explore-phi/developers/architecture#example-flow-for-paid-mint-with-referral states that a normal workflow would include thatUser calls ``claim`` function with sufficient ETH to cover the total mint fee
. Therefore, the caller of thePhiFactory.claim
function should expect a refund of the difference between themsg.value
and total mint fee when calling such function with amsg.value
that is more than the total mint fee.https://github.com/code-423n4/2024-08-phi/blob/3a817c9dedca53ea27ff3e7988f8389086935b8b/src/PhiFactory.sol#L723-L758
However, the
PhiFactory.claim
function executesthis.merkleClaim{ value: mintFee }(proof, claimData, mintArgs, leafPart_)
ifart.verificationType
isMERKLE
orthis.signatureClaim{ value: mintFee }(signature_, claimData, mintArgs)
ifart.verificationType
isSIGNATURE
, where themintFee
is the total mint fee that is returned bygetArtMintFee(artId, quantity_)
. Since only themintFee
is sent when calling thePhiFactory.merkleClaim
orPhiFactory.signatureClaim
function, the difference between themsg.value
and total mint fee would remain in thePhiFactory
contract and not be refunded to the caller of thePhiFactory.claim
function when thePhiFactory.claim
function is called with suchmsg.value
that is more than the total mint fee. As a result, such caller of thePhiFactory.claim
function loses such ETH difference that should be refunded to him.https://github.com/code-423n4/2024-08-phi/blob/3a817c9dedca53ea27ff3e7988f8389086935b8b/src/PhiFactory.sol#L264-L304
Proof of Concept
Please add the following test in
test\PhiFactory.t.sol
. This test will pass to demonstrate the described scenario.Tools Used
Manual Review
Recommended Mitigation Steps
The
PhiFactory.claim
function can be updated to send the difference between themsg.value
and total mint fee to the function caller when such function is called with amsg.value
that is more than the total mint fee.Assessed type
Other
The text was updated successfully, but these errors were encountered: