CVE-2022-31170: CWE-20: Improper Input Validation in OpenZeppelin openzeppelin-contracts
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 Analysis
Technical Summary
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.
Affected Countries
Germany, France, Netherlands, Switzerland, United Kingdom, Estonia, Luxembourg
CVE-2022-31170: CWE-20: Improper Input Validation in OpenZeppelin 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
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.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
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: 8/14/2025, 5:04:55 AM
Views: 12
Related Threats
CVE-2025-9091: Hard-coded Credentials in Tenda AC20
LowCVE-2025-9090: Command Injection in Tenda AC20
MediumCVE-2025-9092: CWE-400 Uncontrolled Resource Consumption in Legion of the Bouncy Castle Inc. Bouncy Castle for Java - BC-FJA 2.1.0
LowCVE-2025-9089: Stack-based Buffer Overflow in Tenda AC20
HighCVE-2025-9088: Stack-based Buffer Overflow in Tenda AC20
HighActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.