Junglewise Threat Intelligence

CVE-2022-31172: OpenZeppelin Contracts SignatureChecker unexpected revert on invalid EIP-1271 signers

CVE-2022-31172 · Severity: low · CVSS 3.1 · Published 2022-07-21

Technologies: @openzeppelin/contracts (npm), OpenZeppelin Contracts, OpenZeppelin Contracts Upgradeable, @openzeppelin/contracts-upgradeable (npm). Vendors: npm, OpenZeppelin.

Executive brief

OpenZeppelin Contracts provides a widely-used library for secure Ethereum smart contract development, including signature validation functions. A logic error in the SignatureChecker component can cause it to unexpectedly revert when validating signatures from contracts that don't properly implement the EIP-1271 standard, potentially breaking applications that rely on graceful handling of invalid signatures rather than exceptions.

Technical details

The vulnerability exists in OpenZeppelin Contracts' SignatureChecker.isValidSignatureNow function, which is designed to validate EIP-1271 signatures without reverting. However, a behavioral change in Solidity 0.8's abi.decode—which now reverts when raw bytes data overflows the target type—was not accounted for in the implementation. When SignatureChecker invokes abi.decode on a response from a contract that doesn't properly implement EIP-1271, the decode operation can revert unexpectedly. This affects applications that use SignatureChecker and expect to handle invalid signatures through normal control flow rather than exception handling. The fix was released in version 4.7.1, which properly handles abi.decode reverts using try-catch mechanisms or alternative decoding strategies.

Affected products

  • OpenZeppelin @openzeppelin/contracts >=4.1.0, <4.7.1
  • OpenZeppelin @openzeppelin/contracts-upgradeable >=4.1.0, <4.7.1

Timeline

  • 2022-07-21: disclosed: Advisory published
  • 2022-07-18: patched: Fix merged in PR #3552

References

Related threats