# GHSA-wmpv-c2jp-j2xg: ERC1155Supply vulnerability in OpenZeppelin Contracts


- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Fix available:** Yes
- **Published:** 15 Nov 2021

## What is GHSA-wmpv-c2jp-j2xg?

GHSA-wmpv-c2jp-j2xg is a vulnerability in @openzeppelin/contracts, published on 15 Nov 2021. 

### Official description

When ERC1155 tokens are minted, a callback is invoked on the receiver of those tokens, as required by the spec. When including the `ERC1155Supply` extension, total supply is not updated until after the callback, thus during the callback the reported total supply is lower than the real number of tokens in circulation.

### Impact
If a system relies on accurately reported supply, an attacker may be able to mint tokens and invoke that system after receiving the token balance but before the supply is updated.

### Patches
A fix is included in version 4.3.3 of `@openzeppelin/contracts` and `@openzeppelin/contracts-upgradeable`.

### Workarounds
If accurate supply is relevant, do not mint tokens to untrusted receivers.

### Credits
The issue was identified and reported by @ChainSecurityAudits.

### For more information
Read [TotalSupply Inconsistency in ERC1155 NFT Tokens](https://medium.com/chainsecurity/totalsupply-inconsistency-in-erc1155-nft-tokens-8f8e3b29f5aa) by @ChainSecurityAudits for a more detailed breakdown.

If you have any questions or comments about this advisory, email us at security@openzeppelin.com.

## Which versions are affected by GHSA-wmpv-c2jp-j2xg?

4 open source packages ship an affected version, including @openzeppelin/contracts and @openzeppelin/contracts-upgradeable.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@openzeppelin/contracts` | npm | From 4.2.0 | 4.3.3 |
| `@openzeppelin/contracts` | npm | From 4.2.0 | 4.3.3 |
| `@openzeppelin/contracts-upgradeable` | npm | From 4.2.0 | 4.3.3 |
| `@openzeppelin/contracts-upgradeable` | npm | From 4.2.0 | 4.3.3 |

## How do I fix GHSA-wmpv-c2jp-j2xg?

Upgrade @openzeppelin/contracts to 4.3.3 or later.

## Is GHSA-wmpv-c2jp-j2xg being exploited?

There is no known exploitation of GHSA-wmpv-c2jp-j2xg in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-wmpv-c2jp-j2xg and fix it if it is affected.

What it is: GHSA-wmpv-c2jp-j2xg is a vulnerability in @openzeppelin/contracts, published on 15 Nov 2021. 
Exploitation: There is no known exploitation of GHSA-wmpv-c2jp-j2xg in the wild and no public exploit code.

Affected packages and fixed versions:
- @openzeppelin/contracts (npm): affected from 4.2.0; fixed in 4.3.3
- @openzeppelin/contracts (npm): affected from 4.2.0; fixed in 4.3.3
- @openzeppelin/contracts-upgradeable (npm): affected from 4.2.0; fixed in 4.3.3
- @openzeppelin/contracts-upgradeable (npm): affected from 4.2.0; fixed in 4.3.3

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-wmpv-c2jp-j2xg/ (Markdown: https://insights.sbomify.com/GHSA-wmpv-c2jp-j2xg/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-wmpv-c2jp-j2xg

---
From sbomify Insights: https://insights.sbomify.com/GHSA-wmpv-c2jp-j2xg/
Summaries are generated and may contain mistakes; the official description above is the record.
