Skip to main content
Press slash or control plus K to focus the search. Use the arrow keys to navigate results and press enter to open a threat.
Reconnecting to live updates…

CVE-2022-31170: CWE-20: Improper Input Validation in OpenZeppelin openzeppelin-contracts

0
Medium
Published: Thu Jul 21 2022 (07/21/2022, 14:00:18 UTC)
Source: CVE
Vendor/Project: OpenZeppelin
Product: openzeppelin-contracts

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.

AI-Powered Analysis

AILast updated: 06/23/2025, 01:21:29 UTC

Technical Analysis

CVE-2022-31170 is a medium-severity vulnerability affecting OpenZeppelin Contracts, a widely used library for developing smart contracts on blockchain platforms. The vulnerability exists in versions 4.0.0 through 4.7.0 of the openzeppelin-contracts package, specifically in the ERC165Checker utility. ERC165Checker is designed to verify whether a target contract supports a particular interface by calling the supportsInterface function, which should always return a boolean value without reverting. However, due to an incorrect assumption in Solidity 0.8's abi.decode behavior, the ERC165Checker.supportsInterface function can revert unexpectedly if the target contract does not implement the EIP-165 standard correctly and returns a value other than 0 or 1. This improper input validation (CWE-20) leads to a scenario where the function call reverts instead of returning false, breaking the expected control flow. Contracts relying on ERC165Checker to detect interface support and handle unsupported interfaces gracefully (without reverting) may instead experience unintended reverts, potentially causing denial of service or disrupting contract logic. The issue was fixed in version 4.7.1 of openzeppelin-contracts. No known exploits have been reported in the wild to date. This vulnerability primarily impacts smart contracts that integrate ERC165Checker for interface detection and expect non-reverting behavior, which is common in decentralized applications (dApps) and blockchain infrastructure components that rely on OpenZeppelin libraries for security and standard compliance.

Potential Impact

For European organizations involved in blockchain development, decentralized finance (DeFi), or other smart contract-based applications, this vulnerability can cause unexpected contract reverts leading to denial of service or degraded functionality. Since OpenZeppelin Contracts is a de facto standard library, many European blockchain projects and enterprises may be indirectly affected if they use vulnerable versions. The improper input validation could disrupt automated contract interactions, cause transaction failures, and undermine trust in smart contract reliability. Financial applications relying on interface detection to enable or disable features dynamically may experience logic errors or service interruptions. While the vulnerability does not directly lead to unauthorized access or data leakage, the availability and integrity of smart contract operations could be compromised. This may have regulatory and reputational consequences for European organizations, especially those operating in regulated sectors like finance or critical infrastructure. The lack of known exploits reduces immediate risk, but the widespread use of OpenZeppelin Contracts means the attack surface is significant if adversaries develop exploits.

Mitigation Recommendations

European organizations should immediately audit their smart contract codebases to identify usage of openzeppelin-contracts versions between 4.0.0 and 4.7.0, particularly focusing on the ERC165Checker utility. Upgrading to version 4.7.1 or later, where the issue is patched, is the primary and most effective mitigation. For contracts already deployed and immutable, consider implementing fallback mechanisms or wrapper contracts that handle potential reverts gracefully. Testing contracts against non-compliant EIP-165 implementations can help identify potential revert scenarios. Additionally, organizations should incorporate rigorous input validation and error handling around interface detection calls. Monitoring blockchain transactions for unusual revert patterns related to ERC165Checker can provide early warning of exploitation attempts. Finally, educating developers about the nuances of Solidity's abi.decode behavior and the importance of adhering to interface standards will reduce future risks.

Need more detailed analysis?Upgrade to Pro Console

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-05-18T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9844c4522896dcbf3911

Added to database: 5/21/2025, 9:09:24 AM

Last enriched: 6/23/2025, 1:21:29 AM

Last updated: 2/7/2026, 11:02:49 AM

Views: 45

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console in Console -> Billing for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats