Skip to content
Smart contracts Audit finding Advanced

OZ ERC1155Supply vulnerability

The project used a vulnerable version of OpenZeppelin's ERC1155Supply contract where totalSupply was not updated before a callback during minting. An attacker could call build and then unwind in the same transaction to manipulate totalSupply-dependent calculations.

pauliax Follow

Originally disclosed on Code4rena

Submitted by pauliax, also found by hubble and defsec

Impact

Overlay uses OZ contracts version 4.3.2:

  dependencies:
    - OpenZeppelin/[email protected]

and has a contract that inherits from ERC1155Supply:

  contract OverlayV1OVLCollateral is ERC1155Supply

This version has a recently discovered vulnerability: https://github.com/OpenZeppelin/openzeppelin-contracts/security/advisories/GHSA-wmpv-c2jp-j2xg

In your case, function unwind relies on totalSupply when calculating \_userNotional, \_userDebt, \_userCost, and \_userOi, so a malicious actor can exploit this vulnerability by first calling ‘build’ and then on callback ‘unwind’ in the same transaction before the total supply is updated.

Recommended Mitigation Steps

Consider updating to a patched version of 4.3.3.

mikeyrf (Overlay) confirmed

The original report as published on Code4rena, by pauliax. 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 ERC1155Supply contract from OpenZeppelin 4.3.2 did not update totalSupply before invoking a callback during minting, allowing reentrancy-like manipulation.

What the attacker needed

Ability to call build and unwind in one transaction

The fix

The project should update to OpenZeppelin contracts version 4.3.3 or later.

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.

This report is about a smart contract that relied on an outdated library with a known bug. The bug meant that a value tracking the total number of tokens was not updated at the right moment, so someone could quickly perform two actions in one transaction to take advantage of the stale value. The fix is simply to upgrade the library to a patched version.

What is Smart contracts?

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

More by pauliax

View all

16 more disclosed reports, best first.

More from Overlay Protocol contest

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.