Open code423n4 opened 1 year ago
hansfriese marked the issue as primary issue
hansfriese marked the issue as satisfactory
wukong-particle marked the issue as sponsor acknowledged
We will likely fix the issue in another way. We will modify withdrawNftWithInterest
and withdrawEthWithInterest
into withdrawNft
and withdrawEth
, i.e., move the interest withdraw into the single account level interest withdraw function (similar to the suggestion made in https://github.com/code-423n4/2023-05-particle-findings/issues/31)
hansfriese marked the issue as selected for report
After discussion, I think that HIGH is the appropriate severity because this issue incurs loss for the protocol.
hansfriese changed the severity to 3 (High Risk)
Lines of code
https://github.com/code-423n4/2023-05-particle/blob/main/contracts/protocol/ParticleExchange.sol#L212
Vulnerability details
Treasury fee is not collected in
withdrawEthWithInterest()
The
withdrawEthWithInterest()
function fails to collect treasury fees from the lender interests.Impact
The Particle exchange collects treasury fees from the lender's interests. These interests are accumulated in the
interestAccrued
mapping and are withdrawn using the_withdrawAccountInterest()
function, which splits the portion that corresponds to the treasury.https://github.com/code-423n4/2023-05-particle/blob/main/contracts/protocol/ParticleExchange.sol#L231-L246
Lines 238-240 calculate treasury fees and accumulate them in the
_treasury
variable, which are later withdrawn by the owner using thewithdrawTreasury()
function.However, these fees fail to be considered in the case of
withdrawEthWithInterest()
:https://github.com/code-423n4/2023-05-particle/blob/main/contracts/protocol/ParticleExchange.sol#L192-L223
As we can see in the previous snippet of code, the interests are calculated in line 201 but that amount is then transferred, along with the lien price, back to the lender in full in line 212, without deducting any treasury fees.
Recommendation
The interest can be simply accumulated in the
interestAccrued
mapping, which are later withdrawn (correctly taking into account treasury fees) in the already present call to_withdrawAccountInterest()
.Assessed type
Other