Closed code423n4 closed 1 year ago
hansfriese marked the issue as satisfactory
wukong-particle marked the issue as sponsor acknowledged
Good finding. The suggested fix is counter-intuitive for developer though, the new lien shouldn't take over old lien's tokenId (it's already out of the protocol).
The solution should be that the newLien shouldn't be able to withdrawNft, because it's in active loan. The fix from https://github.com/code-423n4/2023-05-particle-findings/issues/13 (check if it's active loan) should suffice to fix this issue here too.
wukong-particle marked the issue as sponsor confirmed
wukong-particle marked the issue as sponsor acknowledged
hansfriese marked the issue as duplicate of #13
hansfriese marked the issue as not a duplicate
As the sponsor pointed out, the essential vulnerability lies in the lack of validation for the function withdrawNftWithInterest
and the suggested mitigation from the warden is not accepted.
Nullifying this one with issue #39 from the same warden in mind.
hansfriese marked the issue as nullified
The solution should be that the newLien shouldn't be able to withdrawNft, because it's in active loan. The fix from https://github.com/code-423n4/2023-05-particle-findings/issues/13 (check if it's active loan) should suffice to fix this issue here too.
Fixed with https://github.com/Particle-Platforms/particle-exchange-protocol/pull/2
Lines of code
https://github.com/code-423n4/2023-05-particle/blob/bbd1c01407a017046c86fdb483bbabfb1fb085d8/contracts/protocol/ParticleExchange.sol#L544-L613 https://github.com/code-423n4/2023-05-particle/blob/bbd1c01407a017046c86fdb483bbabfb1fb085d8/contracts/protocol/ParticleExchange.sol#L172-L189
Vulnerability details
Impact
After calling the following
ParticleExchange.refinanceLoan
function,collection
are the same andtokenId
becomenewLien.tokenId
for both the old and new liens.https://github.com/code-423n4/2023-05-particle/blob/bbd1c01407a017046c86fdb483bbabfb1fb085d8/contracts/protocol/ParticleExchange.sol#L544-L613
In this situation, because both
oldLien.lender
andnewLien.lender
are the lenders of the liens for the same NFT, which corresponds to the samecollection
-tokenId
combination,newLien.lender
can call the followingParticleExchange.withdrawNftWithInterest
function to withdraw such NFT. Then, calling theParticleExchange.withdrawNftWithInterest
function byoldLien.lender
reverts since theParticleExchange
contract no longer owns such NFT. As a result,oldLien.lender
loses the NFT that should belong to it after the refinancing.https://github.com/code-423n4/2023-05-particle/blob/bbd1c01407a017046c86fdb483bbabfb1fb085d8/contracts/protocol/ParticleExchange.sol#L172-L189
Proof of Concept
The following steps can occur for the described scenario.
ParticleExchange.refinanceLoan
function, Alice isoldLien.lender
, Bob isnewLien.lender
,oldLien.collection
andnewLien.collection
are Milady, andnewLien.tokenId
is 8621.ParticleExchange.refinanceLoan
function, both the old and new liens are for Milady 8621.ParticleExchange.withdrawNftWithInterest
function to withdraw Milady 8621.ParticleExchange.withdrawNftWithInterest
function by Alice reverts. Hence, Alice loses Milady 8621 that should belong to her.Tools Used
VSCode
Recommended Mitigation Steps
https://github.com/code-423n4/2023-05-particle/blob/bbd1c01407a017046c86fdb483bbabfb1fb085d8/contracts/protocol/ParticleExchange.sol#L593-L607 can be updated to the following code, where
tokenId
is set tooldLien.tokenId
instead ofnewLien.tokenId
.Assessed type
Token-Transfer