Skip to content
Business logic Audit finding Intermediate

User loses collateral converted to pendingBalance when cash() or list() is called

Trust Follow with Lambda

Originally disclosed on Code4rena

Submitted by Trust, also found by Lambda

https://github.com/code-423n4/2022-12-tessera/blob/f37a11407da2af844bbfe868e1422e3665a5f8e4/src/seaport/modules/OptimisticListingSeaport.sol#L295

https://github.com/code-423n4/2022-12-tessera/blob/f37a11407da2af844bbfe868e1422e3665a5f8e4/src/seaport/modules/OptimisticListingSeaport.sol#L232

Description

In OptimisticListingOpensea, there are several functions which update pendingBalances of a proposer:

  1. list()
  2. cash()
  3. propose()

Unfortunately, in list() and cash() the = operator is used instead of += when writing the new pendingBalances. For example:

function cash(address _vault, bytes32[] calldata _burnProof) external {
    // Reverts if vault is not registered
    (address token, uint256 id) = _verifyVault(_vault);
    // Reverts if active listing has not been settled
    Listing storage activeListing = activeListings[_vault];
    // Reverts if listing has not been sold
    if (!_verifySale(_vault)) {
        revert NotSold();
    } else if (activeListing.collateral != 0) {
        uint256 collateral = activeListing.collateral;
        activeListing.collateral = 0;
        // Sets collateral amount to pending balances for withdrawal
        pendingBalances[_vault][activeListing.proposer] = collateral;
    }
	...

pendingBalances is not guaranteed to be zero. There could be funds from previous proposals which are not yet collected. Propose updates pendingBalance correctly:

// Sets collateral amount to pending balances for withdrawal
pendingBalances[_vault][proposedListing.proposer] += proposedListing.collateral;

So, when propose is followed by another propose(), the pendingBalance is updated correctly, but in cash and list we don’t account for pre-existing balance. This issue would manifest even after the fix suggested in the issue “User can send a proposal and instantly take back their collateral” because reject functions would increment the pendingBalance and then it would be overriden.

Impact

User loses collateral converted to pendingBalance when cash() or list() is called.

Proof of Concept

  1. User calls propose() and gets pendingBalance = x
  2. User calls propose() with an improved proposal and gets pendingBalance = 1.5x
  3. proposal is successfull and the listing purchased the NFT
  4. cash() is called to convert the Raes to ETH amount from the sell. pendingBalance is overridden by the current “collateral” value. pendingBalance = 0.5x
  5. User loses x collateral value which is stuck in the contract

Recommended Mitigation Steps

Change the = operator to += in list() and cash().

mehtaculous (Tessera) confirmed and commented:

Agree with High severity. Solution is to replace = with += for both list and cash functions.

stevennevins (Tessera) mitigated:

https://github.com/fractional-company/modular-fractional/pull/202

Status: Mitigation confirmed by gzeon, IllIllI, and Lambda.


The original report as published on Code4rena, by Trust. 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.

What is known

A high-severity business logic bug in Tessera - Versus contest. Code4rena made it public on 18 April 2023. Found in the 2022-12-tessera audit contest (finding H-07), also found by 1 other warden.

About Business logic

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

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

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 Trust

View all

77 more disclosed reports, best first.

More from Tessera - Versus 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.