Skip to content
Access control Audit finding Intermediate

Public to all funds escape

The LooksRareAggregator contract's execute function returns any leftover ERC20 tokens and Ether to the caller, allowing anyone to withdraw funds that were accidentally sent to the contract. This undermines the owner-only rescue functions and lets an attacker front-run the owner's rescue attempt.

V_B Follow with Decurity, hyh and 15 others

Originally disclosed on Code4rena

Submitted by V_B, also found by Decurity, hyh, carrotsmuggler, vv7, teawaterwire, M0ndoHEHE, hanxin, HE1M, rbserver, R2, zaskoh, Vadis, koxuan, Koolex, aviggiano, chaduke, and Rolezn

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/TokenRescuer.sol#L22

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/TokenRescuer.sol#L34

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/LooksRareAggregator.sol#L27

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/LooksRareAggregator.sol#L108

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/LooksRareAggregator.sol#L109

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/LooksRareAggregator.sol#L245

https://github.com/code-423n4/2022-11-looksrare/blob/main/contracts/lowLevelCallers/LowLevelETH.sol#L43

Vulnerability Details

The LooksRareAggregator smart contract implements a bunch of functions to escape funds by the contract owner (see rescueETH, rescueERC20, rescueERC721, and rescueERC1155). In this way, any funds that were accidentally sent to the contract or were locked due to incorrect contract implementation can be returned to the owner. However, locked funds can be rescued by anyone without the owner’s permission. This is completely contrary to the idea of having rescue functions.

In order to withdraw funds from the contract, a user may just call the execute function in the ERC20EnabledLooksRareAggregator with tokenTransfers that contains the addresses of tokens to be withdrawn.

Thus, after the order execution _returnERC20TokensIfAny and _returnETHIfAny will be called, and the whole balance of provided ERC20 tokens and Ether will be returned to msg.sender.

Please note, that means that the owner can be front-ran with rescue functions and an attacker will receive funds instead.

Impact

Useless of rescue functionality and vulnerability to jamming funds.

Recommended Mitigation Steps

_returnETHIfAny and _returnERC20TokensIfAny should return the amount of the token that was deposited.

Picodes (judge) decreased severity to Medium and commented:

As only stuck funds are at risk, and as the aggregator contract itself is not supposed to handle funds, I don’t think this qualifies for High Severity.

0xhiroshi (LooksRare) disputed and commented:

We have decided that any ERC20 tokens sent there accidentally are free for all.

Picodes (judge) commented:

Keeping the Medium severity because the contract implements TokenRescuer, so the intent “that any ERC20 tokens sent there accidentally are free for all” totally makes sense but wasn’t clear prior to the audit. So I consider this a case where tokens that should belong to the protocol could be withdrawn by anyone.


The original report as published on Code4rena, by V_B. 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 execute function returns the entire contract balance of specified tokens and Ether to the caller instead of only the amount deposited during that execution.

Impact

Any accidentally sent ERC20 tokens or Ether could be taken by anyone, and the owner's rescue could be front-run, though the judge noted only stuck funds are at risk and the contract is not meant to hold funds.

What the attacker needed

Funds accidentally sent to the contract; attacker can call execute

How it was found

  1. Call the execute function on ERC20EnabledLooksRareAggregator with tokenTransfers listing the tokens to withdraw.
  2. The contract calls _returnERC20TokensIfAny and _returnETHIfAny after order execution.
  3. The entire balance of those ERC20 tokens and Ether is sent to the caller.

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 can hold funds that people accidentally send to it. The contract had special functions for the owner to rescue such funds, but another function let anyone take those funds by simply calling it. This means the owner's rescue could be beaten by an attacker who calls first.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by V_B

View all

7 more disclosed reports, best first.

More from LooksRare Aggregator contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.