Submitted by unforgiven, also found by hansfriese
Function purchaseLiquidationAuctionNFT() purchases a liquidation auction with the controllers papr token. The liquidator pays the papr amount which is equal to price of the auction and receives the auctioned  NFT. Contract would transfer paid papr and pay borrower debt and if there is extra papr left, it would be transferred to the user. 
For extra papr that is not required for brining user debt under max debt, contract gets liquidation penalty but in some cases (when the auctioned NFT is users last collateral) contract take penalty from all of the transferred papr and not just the extra. So users would lose funds in those situations because of this and the fund could be big because the penalty is 10% of the price of the auction and in most cases user would lose 10% of his debt (the value of the NFT).
This is purchaseLiquidationAuctionNFT() code:
As you can see when collateralValueCached is 0 and user has no more collaterals left then the value of isLastCollateral set as true. And when isLastCollateral is true the value of maxDebtCached set as debtCached (line maxDebtCached = isLastCollateral ? debtCached : _maxDebt(collateralValueCached, updateTarget());) and the value of the neededToSaveVault would be 0 (line neededToSaveVault = maxDebtCached > debtCached ? 0 : debtCached - maxDebtCached) and the excess would be equal to price (in the line excess = price > neededToSaveVault ? price - neededToSaveVault : 0) so all the papr paid by liquidator would be considered as excess and the contract would get liquidation penalty out of that. So in the current implementation in last collateral liquidation all of the paid papr by liquidator would be considered excess:
Code wants to take penalty from what borrower is going to receive (other than the required amount for extra debt), but in the current implementation when it is last NFT code took fee from all of the payment. These are the steps that show how the issue would harm the borrower and borrower would lose funds: (of course user debt would be set to 0 in the end, but if price was higher than user debt user wont receive the extra amount).
So users would receive less amount when their last NFT is liquidated and the price is higher than debt. Users would lose 10% of their entitled fund. Most users can use one token as collateral so the bug can happen most of the time.
VIM
The code should be like this:
wilsoncusack (Backed) confirmed
trust1995 (judge) decreased severity to Medium
For this contest, 34 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by yixxas received the top score from the judge.
The following wardens also submitted reports: Breeje,
gz627,
ak1,
Franfran,
wait,
0xSmartContract,
Aymen0909,
SaharDevep,
lukris02,
bin2chen,
tnevler,
Diana,
imare,
Jeiwan,
unforgiven,
HE1M,
HollaDieWaldfee,
brgltd,
shark,
SmartSek,
IllIllI,
0x52,
0xAgro,
chrisdior4,
rvierdiiev,
Secureverse,
RaymondFam,
Bobface,
ladboy233,
Bnke0x0,
oyc_109,
Rolezn, and
0xhacksmithh
.
