Skip to content
Business logic Audit finding Intermediate

User collateral NFT open auctions would be sold as min price immediately next time user health factor gets below the liquidation threshold, protocol should check health factor and set auctionValidityTime value anytime a valid action happens to user account to invalidate old open auctions

Open NFT auctions started during an earlier period of poor health remain valid indefinitely because the user's auction validity timestamp is only updated manually. When the user's health factor later drops again, an attacker can liquidate the collateral at the minimum auction price straight away.

unforgiven Follow

Originally disclosed on Code4rena

Submitted by unforgiven

https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/protocol/pool/DefaultReserveAuctionStrategy.sol#L90-L135 https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/protocol/tokenization/libraries/MintableERC721Logic.sol#L424-L434

Attacker can liquidate users NFT collaterals with min price immediately after user health factor gets below the liquidation threshold for NFT collaterals that have old open auctions and setAuctionValidityTime() is not get called for the user. Whenever user’s account health factor gets below the NFT liquidation threshold attacker can start auction for all of users NFTs in the protocol. User needs to call setAuctionValidityTime() to invalidated all of those open auctions whenever his/her account health factor is good, but if user doesn’t call this and doesn’t close those auctions then next time user’s accounts health factor gets below the threshold, attacker would liquidate all of those NFTs with minimum price immediately.

Proof of Concept

This is calculateAuctionPriceMultiplier() code in DefaultReserveAuctionStrategy:

    function calculateAuctionPriceMultiplier(
        uint256 auctionStartTimestamp,
        uint256 currentTimestamp
    ) external view override returns (uint256) {
        uint256 ticks = PRBMathUD60x18.div(
            currentTimestamp - auctionStartTimestamp,
            _tickLength
        );
        return _calculateAuctionPriceMultiplierByTicks(ticks);
    }

    function _calculateAuctionPriceMultiplierByTicks(uint256 ticks)
        internal
        view
        returns (uint256)
    {
        if (ticks < PRBMath.SCALE) {
            return _maxPriceMultiplier;
        }

        uint256 ticksMinExp = PRBMathUD60x18.div(
            (PRBMathUD60x18.ln(_maxPriceMultiplier) -
                PRBMathUD60x18.ln(_minExpPriceMultiplier)),
            _stepExp
        );
        if (ticks <= ticksMinExp) {
            return
                PRBMathUD60x18.div(
                    _maxPriceMultiplier,
                    PRBMathUD60x18.exp(_stepExp.mul(ticks))
                );
        }

        uint256 priceMinExpEffective = PRBMathUD60x18.div(
            _maxPriceMultiplier,
            PRBMathUD60x18.exp(_stepExp.mul(ticksMinExp))
        );
        uint256 ticksMin = ticksMinExp +
            (priceMinExpEffective - _minPriceMultiplier).div(_stepLinear);

        if (ticks <= ticksMin) {
            return priceMinExpEffective - _stepLinear.mul(ticks - ticksMinExp);
        }

        return _minPriceMultiplier;
    }

As you can see when long times passed from auction start time the price of auction would be minimum. This is isAuctioned() code in MintableERC721Data contract:

    function isAuctioned(
        MintableERC721Data storage erc721Data,
        IPool POOL,
        uint256 tokenId
    ) public view returns (bool) {
        return
            erc721Data.auctions[tokenId].startTime >
            POOL
                .getUserConfiguration(erc721Data.owners[tokenId])
                .auctionValidityTime;
    }

As you can see auction is valid if startTime is bigger than user’s auctionValidityTime. but the value of auctionValidityTime should be set manually by calling PoolParameters.setAuctionValidityTime(), so by default auction would stay open. imagine this scenario:

  1. user NFT health factor gets under the liquidation threshold.
  2. attacker calls startAuction() for all user collateral NFT tokens.
  3. user supply some collateral and his health factor become good.
  4. some time passes and user NFT health factor gets under the liquidation threshold.
  5. attacker can liquidate all of user NFT collateral with minimum price of auction immediately.
  6. user would lose his NFTs without proper auction.

This scenario can be common because liquidation and health factor changes happens on-chain and most of the user isn’t always watches his account health factor and he wouldn’t know when his account health factor gets below the liquidation threshold and when it’s needed for him to call setAuctionValidityTime(). so over time this would happen to more users.

Tools Used

VIM

Recommended Mitigation Steps

Contract should check and set the value of auctionValidityTime for user whenever an action happens to user account. Also there should be some incentive mechanism for anyone starting or ending an auction.


The original report as published on Code4rena, by unforgiven. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the auction validity timestamp is only refreshed when the user calls a setter manually, so stale open auctions are never invalidated by ordinary account activity.

Impact

Users could lose their NFT collateral at the minimum auction price without a proper auction, and the report notes this may become more common over time as users do not watch their health factor.

What the attacker needed

User has NFT collateral in the protocol; user's health factor drops below threshold; user does not refresh auction validity

The fix

The contract should check and set the user's auction validity time whenever any action happens on the user's account, and the report also suggests adding an incentive for starting or ending auctions.

How it was found

  1. The user's NFT health factor falls below the liquidation threshold.
  2. The attacker starts an auction for all of the user's collateral NFT tokens.
  3. The user adds collateral and the health factor recovers.
  4. Time passes and the health factor falls below the threshold again.
  5. The attacker liquidates the collateral at the minimum auction price immediately.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a borrower's collateral is at risk, the protocol can auction it off, and the price falls over time until it reaches a floor. This report says an old auction can stay 'open' from a previous scare, so if the borrower is at risk again much later, someone can buy the collateral at that floor price at once instead of a fair auction.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by unforgiven

View all

50 more disclosed reports, best first.

More from ParaSpace contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.