Open code423n4 opened 1 year ago
More like a suggestion for improvement. Likely to downgrade to LOW. Leave open for sponsor's review for now.
hansfriese marked the issue as satisfactory
wukong-particle marked the issue as sponsor confirmed
wukong-particle marked the issue as disagree with severity
Agree with Judge, severity can be low.
Downgrading to LOW with the sponsor's comment and precedents in mind.
hansfriese changed the severity to QA (Quality Assurance)
hansfriese marked the issue as grade-b
Lines of code
https://github.com/code-423n4/2023-05-particle/blob/main/contracts/protocol/ParticleExchange.sol#L346
Vulnerability details
Function
buyNftFromMarket()
should not be payableThe
buyNftFromMarket()
function is marked as payable but fails to consider callvalue.Impact
The
buyNftFromMarket()
function present in the ParticleExchange contract implements the flow in which the borrower buys an NFT in the marketplace in order to repay and close the loan.https://github.com/code-423n4/2023-05-particle/blob/main/contracts/protocol/ParticleExchange.sol#L338-L393
The required funds to purchase the NFT are used from the contract. As we can see in line 361, the
amount
value (which is the purchase price) is subtracted from the borrower's quota (credit and lien price) along with the due interests (payableInterest
). If the amount weren't enough this calculation would overflow.The particular issue here is that the function is marked as payable and could potentially receive ETH, but the function doesn't consider any attached value during its implementation.
This might be caused by an initial version of the function that could receive ETH and was later iterated and changed. If the borrower needs to increase their margin they could call the
addCredit()
function.We can double check this by noting that
msg.value
isn't taken into account in the implementation ofbuyNftFromMarket()
or the internal function_execBuyNftFromMarket()
. This means that any ETH sent to this function will be effectively lost in the contract.Recommendation
Remove the
payable
modifier from thebuyNftFromMarket()
function.Assessed type
Payable