-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PhiFactory:claim
Potentially Causing Loss of Funds If mintFee
Changed Beforehand
#109
Comments
fatherGoose1 changed the severity to 2 (Med Risk) |
fatherGoose1 marked the issue as satisfactory |
I would like to argue that this is a valid Med, but not a duplicate of Issue #11: 1. Distinct Root Causes and ImpactsIssue #11: Incorrect Handling of
Issue #109 (this original finding): Incorrect Handling of
2. Fix for Issue #11 Does Not Address Issue #109
3. Severity of Similar Cases to #109Duplicates of #109 which missed the critical condition of the |
I agree with your assessment. The |
fatherGoose1 marked the issue as not a duplicate |
fatherGoose1 marked the issue as primary issue |
fatherGoose1 marked the issue as selected for report |
Lines of code
https://github.com/code-423n4/2024-08-phi/blob/main/src/PhiFactory.sol#L283
https://github.com/code-423n4/2024-08-phi/blob/main/src/PhiFactory.sol#L300
Vulnerability details
Impact
mintFee
was lowered by the Art creator viaupdateArtSettings
before theclaim
was executed, themsg.value
from user would become larger than the updated value ofmintFee
. As the function does not validatemsg.value
and consumes themintFee
directly, the excess ETH sent by the user will not be refunded, causing a loss of funds for user.PhiFactory
still holds positive ETH balance, a malicious user can exploit this by sending lessmsg.value
than expected (or no ETH at all). This results inPhiFactory
's ETH being used for themintFee
payment instead, causing a loss for the protocol.Proof of Concept
This external call to
this.merkleClaim
forwards themintFee
value of ETH without validating it againstmsg.value
.Found in src/PhiFactory.sol at Line 283
Similarly, this external call to
this.signatureClaim
forwards themintFee
value of ETH without validating it againstmsg.value
.Found in src/PhiFactory.sol at Line 300
Although the
merkleClaim
andsignatureClaim
functions can process refunds, theclaim
function calls of these two functionsexternally
(defined asexternal
instead ofpublic
), results in themsg.value
being overridden by themintFee
. As a result, the originalmsg.value
sent to claim() remains unvalidated and become vulnerable to exploits.POC
Apply patch & run
forge test -vvv --mt test_claim_exploit
Result:
This confirms both cases where
msg.value > mintFee
andmsg.value = 0
could be exploited, causing loss of funds for both users and the protocol.Tools Used
Foundry test
Recommended Mitigation Steps
Validate
msg.value
againstmintFee
to ensure the caller sent in the correct amount of ETH.Or forward
msg.value
directly to subsequent claim process since the_processClaim
will eventually handle the refund.Assessed type
Payable
The text was updated successfully, but these errors were encountered: