CVE-2022-21685: Pallet evm precompile modexp Integer Underflow Vulnerability

MODERATE
Advisory Identifier: GHSA-cjg2-2fjg-fph4
CWE-191
Published
Advisory Summary

CVE-2022-21685 is a MODERATE integer underflow vulnerability (CWE-191: Integer Underflow (Wrap or Wraparound)) affecting Pallet evm precompile modexp libraries in the crates.io ecosystem. The issue involves integer underflow in frontier. Remediation is available in the latest vendor maintenance releases.

CVE-2022-21685 at a Glance

CVE Identifier CVE-2022-21685
GHSA Identifier GHSA-cjg2-2fjg-fph4
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-191: Integer Underflow (Wrap or Wraparound)
Affected Product Pallet evm precompile modexp
Package Ecosystem crates.io
Published Date
Last Updated

How to Fix CVE-2022-21685

To remediate this vulnerability, upgrade all affected Pallet evm precompile modexp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pallet-evm-precompile-modexp fixed: Latest secure release
Upgrade pallet-evm-precompile-modexp to Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for pallet-evm-precompile-modexp

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-21685, inspect your project dependencies for Pallet evm precompile modexp:

inspect dependencies for pallet-evm-precompile-modexp

Analyze the terminal output to locate any version of Pallet evm precompile modexp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-191: Integer Underflow (Wrap or Wraparound), where the product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result. In Pallet evm precompile modexp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact A bug in Frontier's MODEXP precompile implementation can cause an integer underflow in certain conditions. This will cause a node crash for debug builds. For release builds (and production WebAssembly binaries), the impact is limited as it can only cause a normal EVM out-of-gas. It is recommended that you apply the patch as soon as possible. If you do not use MODEXP precompile in your runtime, then you are not impacted. ### Patches Patches are applied in PR #549. ### Workarounds None. ### References Patch PR: #549 ### Credits Thanks to SR-Labs for discovering the security vulnerability, and thanks to PureStake team for the patches. ### For more information If you have any questions or comments about this advisory: * Open an issue in the [Frontier repo](https://github.com/paritytech/frontier)

CVE-2022-21685 Affected Pallet evm precompile modexp Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
pallet-evm-precompile-modexp
crates.io
≤ 1.0.0

References

Frequently Asked Questions

What is CVE-2022-21685?
CVE-2022-21685 is a security vulnerability in Pallet evm precompile modexp involving Integer underflow in Frontier under CWE-191: Integer Underflow (Wrap or Wraparound).
Which Pallet evm precompile modexp versions are affected?
Affected versions include releases prior to current release patches across affected packages: pallet-evm-precompile-modexp.
What version fixes CVE-2022-21685?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is pallet-evm-precompile-modexp affected?
Yes, pallet-evm-precompile-modexp is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with CVE-2022-21685?
CVE-2022-21685 is classified under CWE-191: Integer Underflow (Wrap or Wraparound) (The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result.).
How can I check crates.io dependencies for CVE-2022-21685?
Run the dependency tree command: 'inspect dependencies for pallet-evm-precompile-modexp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cjg2-2fjg-fph4",
  "modified" : "2024-10-24T21:50:43Z",
  "published" : "2022-01-14T21:03:36Z",
  "aliases" : [ "CVE-2022-21685" ],
  "summary" : "Integer underflow in Frontier",
  "details" : "### Impact\n\nA bug in Frontier's MODEXP precompile implementation can cause an integer underflow in certain conditions. This will cause a node crash for debug builds. For release builds (and production WebAssembly binaries), the impact is limited as it can only cause a normal EVM out-of-gas. It is recommended that you apply the patch as soon as possible.\n\nIf you do not use MODEXP precompile in your runtime, then you are not impacted.\n\n### Patches\n\nPatches are applied in PR #549.\n\n### Workarounds\n\nNone.\n\n### References\n\nPatch PR: #549\n\n### Credits\n\nThanks to SR-Labs for discovering the security vulnerability, and thanks to PureStake team for the patches.\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in the [Frontier repo](https://github.com/paritytech/frontier)\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "pallet-evm-precompile-modexp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/paritytech/frontier/security/advisories/GHSA-cjg2-2fjg-fph4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-21685"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/paritytech/frontier/pull/549"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/paritytech/frontier/commit/8a93fdc6c9f4eb1d2f2a11b7ff1d12d70bf5a664"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/paritytech/frontier"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-191" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-14T19:58:51Z",
    "nvd_published_at" : "2022-01-14T17:15:00Z"
  }
}