CVE-2024-32644: Github.com/evmos/evmos/v16 Evmos Transaction Execution Not Accounting Vulnerability

CRITICAL
Advisory Identifier: GHSA-3fp5-2xwh-fxm6
CVSS 9.1
CWE-662
Published
Advisory Summary

CVE-2024-32644 is a CRITICAL (CVSS 9.1) evmos transaction execution not accounting vulnerability (CWE-662: Improper Synchronization) affecting Github.com/evmos/evmos/v16 libraries in the Go ecosystem. The issue involves evmos transaction execution not accounting for all state transition after interaction with precompiles. Remediation is available by upgrading affected packages to version 17.0.0.

CVE-2024-32644 at a Glance

CVE Identifier CVE-2024-32644
GHSA Identifier GHSA-3fp5-2xwh-fxm6
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-662: Improper Synchronization
Affected Product Github.com/evmos/evmos/v16
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-32644

To remediate this vulnerability, upgrade all affected Github.com/evmos/evmos/v16 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/evmos/evmos/v16 fixed: 17.0.0
Upgrade github.com/evmos/evmos/v16 to 17.0.0
github.com/evmos/evmos/v7 fixed: Latest secure release
Upgrade github.com/evmos/evmos/v7 to Latest secure release
github.com/evmos/evmos/v6 fixed: Latest secure release
Upgrade github.com/evmos/evmos/v6 to Latest secure release
github.com/evmos/evmos/v5 fixed: Latest secure release
Upgrade github.com/evmos/evmos/v5 to Latest secure release
github.com/tharsis/evmos fixed: Latest secure release
Upgrade github.com/tharsis/evmos to Latest secure release
github.com/tharsis/evmos/v2 fixed: Latest secure release
Upgrade github.com/tharsis/evmos/v2 to Latest secure release
github.com/tharsis/evmos/v3 fixed: Latest secure release
Upgrade github.com/tharsis/evmos/v3 to Latest secure release
github.com/tharsis/evmos/v4 fixed: Latest secure release
Upgrade github.com/tharsis/evmos/v4 to Latest secure release
github.com/tharsis/evmos/v5 fixed: Latest secure release
Upgrade github.com/tharsis/evmos/v5 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 github.com/evmos/evmos/v16

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-32644, inspect your project dependencies for Github.com/evmos/evmos/v16:

inspect dependencies for github.com/evmos/evmos/v16

Analyze the terminal output to locate any version of Github.com/evmos/evmos/v16 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 17.0.0), 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-662: Improper Synchronization, where the product utilizes multiple threads, processes, components, or systems to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes. In Github.com/evmos/evmos/v16, 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

### Context - [`stateObject`](https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/state_object.go#L53-L68): represents the state of an account and is used to store its updates during a state transition. This is accomplished using two in memory Storage variables: `originStorage` and `dirtyStorage` - [`StateDB`](https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/statedb.go#L33-L55): it is the general interface to retrieve accounts and holds a map of stateObjects. ### Impact An external contributor, @iczc, discovered a way to mint arbitrary tokens due to the possibility to have two different states not in sync during the execution of a transaction. The exploit is based on the fact that to sync the Cosmos SDK state and the EVM one, we rely on the `stateDB.Commit()` method. When we call this method, we iterate though all the `dirtyStorage` and, **if and only if** it is different than the `originStorage`, we [set the new state](https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/statedb.go#L460-L465). Setting the new state means we update the Cosmos SDK KVStore. Below, are described the steps to perform the attack: - User send a tx to a smart contract (SC) that is calling a precompile. - The SC perform a state transition of its state from A to B. - The SC call the precompile. - The SC perform a state transition of its state from B to A (revert of the previous). - Once the transaction is executed, and the final **Commit** is performed, the state A will not be committed to the store because A is the same as `originStorage`. If the tx is executed correctly, this is what happens at the store level: - Initial state A is loaded from the KVStore and the dirtyStorage is set to B. - Before running the precompile, the `dirtyStorage` is committed to the KVStore without changing the `originStorage`. - Now, since we have a `dirtyStorage`, it is updated to the previous value A without changing the `originStorage`. Since the tx executed correctly, the evm calls the commit to persist the dirtyStorage. However, since dirtyStorage is equal to originStorage, nothing will be changed. To summarize, if a contract storage state that is the same before and after a transaction, but is changed during the transaction and can call an external contract after the change, it can be exploited to make the transaction similar to non-atomic. The vulnerability is **critical** since this could lead to drain of funds through creative SC interactions. ### Severity Based on [ImmuneFi Severity Classification System](https://immunefisupport.zendesk.com/hc/en-us/articles/13332717597585-Severity-Classification-System) the severity was evaluated to `Critical` since the attack could have lead to direct loss of funds. ### Patches The issue has been patched in versions >=V17.0.0. ## For more information If you have any questions or comments about this advisory: Reach out to the Core Team in [Discord](https://discord.gg/evmos) Open a discussion in [evmos/evmos](https://github.com/evmos/evmos/discussions) Email us at [security@evmos.org](mailto:security@evmos.org) for security questions

CVE-2024-32644 Affected Github.com/evmos/evmos/v16 Versions

9 component(s)
Fixed Versions:
17.0.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/evmos/evmos/v16
Go
< 17.0.0
17.0.0
github.com/evmos/evmos/v7
Go
≤ 7.0.0
github.com/evmos/evmos/v6
Go
≤ 6.0.4
github.com/evmos/evmos/v5
Go
≤ 5.0.0
github.com/tharsis/evmos
Go
≤ 1.1.3
github.com/tharsis/evmos/v2
Go
≤ 2.0.2
github.com/tharsis/evmos/v3
Go
≤ 3.0.3
github.com/tharsis/evmos/v4
Go
≤ 4.0.2
github.com/tharsis/evmos/v5
Go
≤ 5.0.1

References

Frequently Asked Questions

What is CVE-2024-32644?
CVE-2024-32644 is a security vulnerability in Github.com/evmos/evmos/v16 involving Evmos transaction execution not accounting for all state transition after interaction with precompiles under CWE-662: Improper Synchronization.
Which Github.com/evmos/evmos/v16 versions are affected?
Affected versions include releases prior to 17.0.0 across affected packages: github.com/evmos/evmos/v16, github.com/evmos/evmos/v7, github.com/evmos/evmos/v6, github.com/evmos/evmos/v5, github.com/tharsis/evmos, github.com/tharsis/evmos/v2, github.com/tharsis/evmos/v3, github.com/tharsis/evmos/v4, github.com/tharsis/evmos/v5.
What version fixes CVE-2024-32644?
Upgrading to 17.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/evmos/evmos/v16 affected?
Yes, github.com/evmos/evmos/v16 is affected in releases prior to 17.0.0. Upgrade your dependency to 17.0.0 or later.
Is github.com/evmos/evmos/v7 affected?
Yes, github.com/evmos/evmos/v7 is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What is the CVSS score of CVE-2024-32644?
CVE-2024-32644 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H.
What CWE is associated with CVE-2024-32644?
CVE-2024-32644 is classified under CWE-662: Improper Synchronization (The product utilizes multiple threads, processes, components, or systems to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes.).
How can I check Go dependencies for CVE-2024-32644?
Run the dependency tree command: 'inspect dependencies for github.com/evmos/evmos/v16'. 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-3fp5-2xwh-fxm6",
  "modified" : "2024-04-19T16:20:58Z",
  "published" : "2024-04-10T22:04:30Z",
  "aliases" : [ "CVE-2024-32644" ],
  "summary" : "Evmos transaction execution not accounting for all state transition after interaction with precompiles",
  "details" : "### Context\n\n- [`stateObject`](https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/state_object.go#L53-L68): represents the state of an account and is used to store its updates during a state transition. This is accomplished using two in memory Storage variables: `originStorage` and `dirtyStorage`\n- [`StateDB`](https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/statedb.go#L33-L55): it is the general interface to retrieve accounts and holds a map of stateObjects.\n\n### Impact\n\nAn external contributor, @iczc, discovered a way to mint arbitrary tokens due to the possibility to have two different states not in sync during the execution of a transaction. The exploit is based on the fact that to sync the Cosmos SDK state and the EVM one, we rely on the `stateDB.Commit()` method. When we call this method, we iterate though all the `dirtyStorage` and, **if and only if** it is different than the `originStorage`, we [set the new state](https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/statedb.go#L460-L465). Setting the new state means we update the Cosmos SDK KVStore. \n\nBelow, are described the steps to perform the attack:\n\n- User send a tx to a smart contract (SC) that is calling a precompile. \n- The SC perform a state transition of its state from A to B.\n- The SC call the precompile.\n- The SC perform a state transition of its state from B to A (revert of the previous).\n- Once the transaction is executed, and the final **Commit** is performed, the state A will not be committed to the store because A is the same as `originStorage`. \n\nIf the tx is executed correctly, this is what happens at the store level:\n\n- Initial state A is loaded from the KVStore and the dirtyStorage is set to B.\n- Before running the precompile, the `dirtyStorage` is committed to the KVStore without changing the `originStorage`.\n- Now, since we have a `dirtyStorage`, it is updated to the previous value A without changing the `originStorage`.\n\nSince the tx executed correctly, the evm calls the commit to persist the dirtyStorage. However, since dirtyStorage is equal to originStorage, nothing will be changed.\n\nTo summarize, if a contract storage state that is the same before and after a transaction, but is changed during the transaction and can call an external contract after the change, it can be exploited to make the transaction similar to non-atomic. The vulnerability is **critical** since this could lead to drain of funds through creative SC interactions. \n\n### Severity\n\nBased on [ImmuneFi Severity Classification System](https://immunefisupport.zendesk.com/hc/en-us/articles/13332717597585-Severity-Classification-System) the severity was evaluated to `Critical` since the attack could have lead to direct loss of funds.\n\n### Patches\n\nThe issue has been patched in versions >=V17.0.0. \n\n## For more information\nIf you have any questions or comments about this advisory:\n\nReach out to the Core Team in [Discord](https://discord.gg/evmos)\nOpen a discussion in [evmos/evmos](https://github.com/evmos/evmos/discussions)\nEmail us at [security@evmos.org](mailto:security@evmos.org) for security questions\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/evmos/evmos/v16"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "17.0.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 16.0.4"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/evmos/evmos/v7"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "7.0.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/evmos/evmos/v6"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "6.0.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/evmos/evmos/v5"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "5.0.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/tharsis/evmos"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "1.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/tharsis/evmos/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.0.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/tharsis/evmos/v3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "3.0.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/tharsis/evmos/v4"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "4.0.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/tharsis/evmos/v5"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "5.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/evmos/evmos/security/advisories/GHSA-3fp5-2xwh-fxm6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-32644"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evmos/evmos/commit/08982b5ee726b97bc50eaf58d1914829648b6a5f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/evmos/evmos"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/state_object.go#L53-L68"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/statedb.go#L33-L55"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evmos/evmos/blob/b196a522ba4951890b40992e9f97aa610f8b5f9c/x/evm/statedb/statedb.go#L460-L465"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-662" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-10T22:04:30Z",
    "nvd_published_at" : "2024-04-19T15:15:50Z"
  }
}