CVE-2022-31170
JSON

7.5high

OpenZeppelin Contracts's ERC165Checker may revert instead of returning false

Severity
7.5high CVSS:3.1 by GitHub_M
Exploit likelihood
0.81% (higher than 57% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-qh9x-gcfh-pcrw

Description

OpenZeppelin Contracts is a library for smart contract development. Versions 4.0.0 until 4.7.1 are vulnerable to ERC165Checker reverting instead of returning `false`. `ERC165Checker.supportsInterface` is designed to always successfully return a boolean, and under no circumstance revert. However, an incorrect assumption about Solidity 0.8's `abi.decode` allows some cases to revert, given a target contract that doesn't implement EIP-165 as expected, specifically if it returns a value other than 0 or 1. The contracts that may be affected are those that use `ERC165Checker` to check for support for an interface and then handle the lack of support in a way other than reverting. The issue was patched in version 4.7.1.

Affected

Product or packageVersionsReported by
OpenZeppelin openzeppelin-contracts>= 4.0.0, < 4.7.1CVE List
@openzeppelin/contracts (npm)from 4.0.0 before 4.7.1GitHub Advisory Database
@openzeppelin/contracts-upgradeable (npm)from 4.0.0 before 4.7.1GitHub Advisory Database
openzeppelin contractsfrom 4.0.0 before 4.7.1NVD

All scores

GitHub_M7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

Classification

CWE-20CWE-252

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

OpenZeppelin Contracts is a library for smart contract development. Versions 4.0.0 until 4.7.1 are vulnerable to ERC165Checker reverting instead of returning `false`. `ERC165Checker.supportsInterface` is designed to always successfully return a boolean, and under no circumstance revert. However, an incorrect assumption about Solidity 0.8's `abi.decode` allows some cases to revert, given a target contract that doesn't implement EIP-165 as expected, specifically if it returns a value other than 0 or 1. The contracts that may be affected are those that use `ERC165Checker` to check for support for an interface and then handle the lack of support in a way other than reverting. The issue was patched in version 4.7.1.

GitHub Advisory Database
Impact

ERC165Checker.supportsInterface is designed to always successfully return a boolean, and under no circumstance revert. However, an incorrect assumption about Solidity 0.8's abi.decode allows some cases to revert, given a target contract that doesn't implement EIP-165 as expected, specifically if it returns a value other than 0 or 1.

The contracts that may be affected are those that use ERC165Checker to check for support for an interface and then handle the lack of support in a way other than reverting.

Patches

The issue was patched in 4.7.1.

References

https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3552

For more information

If you have any questions or comments about this advisory, or need assistance deploying the fix, email us at security@openzeppelin.com.

NVD (es)

OpenZeppelin Contracts es una biblioteca para el desarrollo de contratos inteligentes. Las versiones 4.0.0 hasta 4.7.1, son vulnerables a una reversión de ERC165Checker en lugar de devolver "false". ERC165Checker.supportsInterface está diseñado para devolver siempre un booleano con éxito, y bajo ninguna circunstancia revertir. Sin embargo, una suposición incorrecta sobre "abi.decode" de Solidity versión 0.8 permite que algunos casos sean revertidos, dado un contrato de destino que no implementa EIP-165 como es esperado, específicamente si devuelve un valor distinto de 0 o 1. Los contratos que pueden verse afectados son los que usan "ERC165Checker" para comprobar el soporte de una interfaz y luego manejar la falta de soporte de una manera distinta a la reversión. El problema fue parcheado en versión 4.7.1

References

Sources

SourceRecordLicence
CVE ListCVE-2022-31170 changed 2025-04-23CVE Terms of Use
GitHub Advisory DatabaseGHSA-qh9x-gcfh-pcrw changed 2023-11-08CC-BY-4.0
NVDCVE-2022-31170 changed 2026-06-17Public domain