Skip to content
DoS Audit finding Intermediate

DOS possible while stopping a rental with erc777 tokens

When a rental order uses an ERC777 token as payment, the renter can implement a tokensReceived hook that reverts during the payment settlement in stopRent. This causes the transaction to fail, leaving the lender's assets stuck in the rental safe.

CipherSleuths Follow with BARW

Originally disclosed on Code4rena

Submitted by CipherSleuths, also found by BARW

https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/policies/Stop.sol#L265

https://github.com/re-nft/smart-contracts/blob/3ddd32455a849c3c6dc3c3aad7a33a6c9b44c291/src/modules/PaymentEscrow.sol#L100

If an order involves erc777 token for a pay order then in the tokensReceived callback the renter can create DOS situation resulting in the lender’s assets being stuck in the rental safe.

Proof of Concept

ERC777 token standard which is backward compatible with erc20 implies that on the transfer of the tokens the recipient can implement a tokensReceived hook to notify of any increment of the balance.

Now suppose a pay order is created with an erc 777 consideration asset as there is no restriction on that and also the eip specifies that

The difference for new contracts implementing ERC-20 is that tokensToSend and tokensReceived hooks take precedence over ERC-20. Even with an ERC-20 transfer and transferFrom call, the token contract MUST check via ERC-1820 if the from and the to address implement tokensToSend and tokensReceived hook respectively. If any hook is implemented, it MUST be called. Note that when calling ERC-20 transfer on a contract, if the contract does not implement tokensReceived, the transfer call SHOULD still be accepted even if this means the tokens will probably be locked.

So the tokensReceived hook is optional for a transfer/transferFrom call. Hence sending the assets from the lender’s wallet to the escrow contract shouldn’t be an issue.

Now when the rental period is over or in/between, the stopRent method in stop policy is called, which calls settlePayment in escrow module. Now on the token transfer

        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transfer.selector, to, value)
        );

The tokensReceived hook if implemented by the renter, would be called and they could just revert the tx inside the tokensReceived hook which would mean that the assets lent by the lender are locked forever.

Recommended Mitigation Steps

It is recommended to prohibit erc777 tokens from being used as consideration items.

0xean (Judge) decreased severity to Medium and commented:

Batching all the ERC777 token issues together.

Alec1017 (reNFT) confirmed

reNFT mitigated:

The PR here - Implements a whitelist so only granted assets can be used in the protocol. The PR here - Implements batching functionality for whitelisting tokens so that multiple can be added at once.

Status: Mitigation confirmed. Full details in reports from EV_om, sin1st3r__ and juancito.


The original report as published on Code4rena, by CipherSleuths. 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 protocol allows arbitrary ERC777 tokens as payment without accounting for the recipient hook that can revert transfers.

Impact

The lender's assets could be permanently locked in the rental safe because the rental cannot be stopped.

What the attacker needed

Rental order uses an ERC777 token as payment; renter controls a contract with a reverting hook

The fix

The protocol was fixed by implementing a whitelist so only granted assets can be used.

How it was found

  1. Create a pay order using an ERC777 token as the consideration asset.
  2. Implement a tokensReceived hook in the renter's contract that reverts.
  3. Call stopRent after the rental period, which triggers settlePayment and the token transfer.
  4. The transfer calls the renter's hook, which reverts, causing the whole transaction to fail.

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.

Some tokens, called ERC777, can run code on the receiver whenever tokens are sent to them. Here, the person renting can use that code to make the payment fail on purpose. Because the payment always fails, the rental can never be properly closed and the lender's items stay locked.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More from reNFT

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.