sherlock-audit / 2023-06-symmetrical-judging

5 stars 4 forks source link

simon135 - PartyB before A liquidation can tranfser out and not get liquidated in`transferAllocation` #352

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

simon135

high

PartyB before A liquidation can tranfser out and not get liquidated intransferAllocation

Summary

PartyB before A liquidation can transfer out and not get liquidated intransferAllocation

Vulnerability Detail

Similar impact to H-16 but PartyB can get out liquidations/bad positions in transferAllocation

steps: PartyB is in the red and their position is about to be liquidated he as to position one with Bob(bad pos) and Alice(good pos ) PartyB will transfer all allocated to Alice's position to get out liquidations

Impact

Loss of spec of and PartyB can skip liquidations

Code Snippet

        LibMuon.verifyPartyBUpnl(upnlSig, msg.sender, origin);
        int256 availableBalance = LibAccount.partyBAvailableForQuote(
            upnlSig.upnl,
            msg.sender,
            origin
        );
        require(availableBalance >= 0, "PartyBFacet: Available balance is lower than zero");
        require(uint256(availableBalance) >= amount, "PartyBFacet: Will be liquidatable");

        accountLayout.partyBNonces[msg.sender][origin] += 1;
        accountLayout.partyBAllocatedBalances[msg.sender][origin] -= amount;
        // allocate for recipient
        accountLayout.partyBNonces[msg.sender][recipient] += 1;
        accountLayout.partyBAllocatedBalances[msg.sender][recipient] += amount;

Tool used

Manual Review

Recommendation

same as other issue