Skip to content
Smart contracts Audit finding Intermediate

Beebots.TradeValid() Will Erroneously Return True When Maker Is Set To Address(0) and makerIds Are Set To The TokenIds of Unminted Beebot NFTs

The Beebots contract's signature verification returns true when the signer is the zero address, and unminted NFTs are treated as owned by the zero address. An attacker could call tradeValid with maker set to the zero address and makerIds of unminted tokens to make the function erroneously return true.

Larva Labs Meebits

Originally disclosed on Code4rena

Beebots.TradeValid() will erroneously return true when maker is set to address(0) and makerIds are set to the tokenIds of unminted beebot NFTs.

Beebots.verify() returns true no matter what signature is given when signer is set to address(0). This means that BeeBots.tradeValid() will erroneously return true when maker is set to address(0).

Finally, before an NFT has even been minted at all, it is assumed to have an owner of address(0) due to the idToOwner mapping being initialized to zero for all uninitialized slots, so an attacker can call tradeValid() with maker set to address(0) and makerIds set to the tokenIds of any unminted nftIds, and tradeValid() will erroneously return true.

  • (1) Beebots.verify() returns true no matter what signature is given when signer is set to address(0).

    • (1a) BeeBots.verify() does not check to ensure that signer is not address(0).
    • (1b) This is a problem because ecrecover fails silently if the signature does not match and returns zero.
    • (1c) So if an attacker passes in address(0) as the signer, then verify will return true no matter what signature is provided, since ecrecover will return address(0), and the signer is address(0), so verify will pass.
    • (1d) This means that BeeBots.tradeValid() will erroneously return true when maker is set to address(0).
  • (2) Before an NFT has even been minted at all, it is assumed to have an owner of address(0) due to the idToOwner mapping being initialized to zero for all uninitialized slots

    • (2a) Solidity initializes all mappings to 0 for all slots that have not yet been set.
    • (2b) So for any NFT ID that has not yet been minted, the corresponding owner in the mapping BeeBots.idToOwner is address(0), even though that NFT should not even exist.
    • (2c) This means that an attacker can call tradeValid() with maker set to address(0) and makerIds set to any unminted nftIds, and tradeValid() will erroneously return true.

(1) Recommend adding this check to Beebots.verify(): require(signer != address(0), "Cannot verify signatures from 0x0");

(2) Recommend adding this check to Beebots.tradeValid(): require(maker != address(0), "Maker 0x0 not allowed");

dangerousfood (Meebits) commented:

Wow, this exploit is absolutely stunning.

The original report as published on Code4rena. 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 contract fails to reject the zero address as a signer and treats unminted token IDs as owned by the zero address.

Impact

An attacker could make tradeValid return true for unminted tokens, potentially enabling invalid trades.

What the attacker needed

None

The fix

The report recommends adding checks to reject address(0) in both verify and tradeValid.

How it was found

  1. Call tradeValid with maker set to address(0).
  2. Set makerIds to the tokenIds of unminted NFTs.
  3. Observe that tradeValid returns true.

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.

A smart contract checks signatures to prove who approved a trade. If the expected signer is the special zero address, the check always passes because the recovery function returns zero on failure. Also, unminted tokens appear to be owned by the zero address. So an attacker can pretend a trade is valid for tokens that do not exist yet.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from Larva Labs Meebits

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.