CVE-2022-35936: Github.com/evmos/ethermint Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-f92v-grc2-w2fg
CVSS 8.2
CWE-668
Published
Advisory Summary

CVE-2022-35936 is a HIGH (CVSS 8.2) denial of service vulnerability (CWE-668: Exposure of Resource to Wrong Sphere) affecting Github.com/evmos/ethermint libraries in the Go ecosystem. The issue involves ethermint vulnerable to dos through unintended contract selfdestruct. Remediation is available by upgrading affected packages to version 0.18.0, 7.0.0, 0.7.1-rc2.

CVE-2022-35936 at a Glance

CVE Identifier CVE-2022-35936
GHSA Identifier GHSA-f92v-grc2-w2fg
Severity HIGH
CVSS v3.1 Base Score 8.2
CWE Classification CWE-668: Exposure of Resource to Wrong Sphere
Affected Product Github.com/evmos/ethermint
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.2

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:L/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 Low (I:L)
Availability High (A:H)

How to Fix CVE-2022-35936

To remediate this vulnerability, upgrade all affected Github.com/evmos/ethermint 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/ethermint fixed: 0.18.0
Upgrade github.com/evmos/ethermint to 0.18.0
github.com/evmos/evmos fixed: 7.0.0
Upgrade github.com/evmos/evmos to 7.0.0
github.com/crypto-org-chain/cronos fixed: 0.7.1-rc2
Upgrade github.com/crypto-org-chain/cronos to 0.7.1-rc2
github.com/Kava-Labs/kava fixed: 0.18.0
Upgrade github.com/Kava-Labs/kava to 0.18.0
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/ethermint

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-35936, inspect your project dependencies for Github.com/evmos/ethermint:

inspect dependencies for github.com/evmos/ethermint

Analyze the terminal output to locate any version of Github.com/evmos/ethermint in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.18.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-668: Exposure of Resource to Wrong Sphere, where the product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource. In Github.com/evmos/ethermint, 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

# Vulnerability Report ## Impact Smart contract applications that make use of the `selfdestruct` functionality and their end-users. ## Classification The vulnerability has been classified as `high` with a CVSS score of `8.2`. It has the potential to create a denial-of-service to all contracts that can invoke the [`selfdestruct`](https://ethereum.stackexchange.com/questions/315/why-are-selfdestructs-used-in-contract-programming#347) function to destroy a smart contract. ## Users Impacted Due to the successfully coordinated security vulnerability disclosure, no smart contracts were impacted through the use of this vulnerability. Smart contract states and storage values are not affected by this vulnerability. User funds and balances are safe. ## Disclosure In Ethermint running versions before `v0.17.2`, the contract `selfdestruct` invocation permanently removes the corresponding bytecode from the internal database storage. However, due to a bug in the [`DeleteAccount`](https://github.com/evmos/ethermint/blob/c9d42d667b753147977a725e98ed116c933c76cb/x/evm/keeper/statedb.go#L199-L203) function, all contracts that used the identical bytecode (i.e shared the same `CodeHash`) will also stop working once one contract invokes `selfdestruct`, even though the other contracts did not invoke the `selfdestruct` OPCODE. ### Additional Details The same contract bytecode can be deployed multiple times to create multiple contract instances. In the internal database, the bytecode is stored as a key-value entry `bytecode hash --> bytecode` which is shared by those contracts. Unfortunately, when one of the contracts invokes `selfdestruct`, it will remove the corresponding `bytecode hash -> bytecode` entry, and thus it disables all the contracts that share the same bytecode. The attack scenario is as follows: 1. The malicious attacker identifies a vulnerable contract that can invoke `selfdestruct` 2. The attacker deploys a copy of the contract with identical bytecode 3. Finally, the attacker triggers the `selfdestruct` operation on their redeployed contract, actively causing a DoS on the original and vulnerable contract. All transactions will fail until a workaround is used (see below). ## Patches *Has the problem been patched? What versions should users upgrade to?* This vulnerability has been patched in Ethermint versions ≥[v0.18.0](https://github.com/evmos/ethermint/releases/tag/v0.18.0). The patch has state machine-breaking changes for applications using Ethermint so a coordinated upgrade procedure is required. #### Details The patch removes the bytecode deletion logic, i.e. contract bytecodes are never deleted from the internal database after the patch. At the moment, Ethermint does not track how many times each bytecode is used, and thus it cannot determine if it is safe to delete a particular bytecode on `selfdestruct` invocations. This behavior is the same with go-ethereum. ## Workarounds _Is there a way for users to fix or remediate the vulnerability without upgrading?_ If a contract is subject to DoS due to this issue, the user can redeploy the same contract, _i.e_ with identical bytecode, so that the original contract's code is recovered. The new contract deployment restores the `bytecode hash -> bytecode` entry in the internal state. ## References *Are there any links users can visit to find out more?* ### 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/ethermint](https://github.com/evmos/ethermint/discussions) * Email us at [security@evmos.org](mailto:security@evmos.org) for security questions * For Press, email us at [evmos@west-comms.com](mailto:evmos@west-comms.com). ### Credits Thanks to the - Cronos Team: @yihuang and @tomtau for discovering the issue, @gakuzen-crypto, @polycryptics, @FinnZhangCrypto, @wilson-ang, @brianatcrypto for the impact analysis. - Evmos Team: @facs95 for patching the issue and @fedekunze for managing the release and coordinating between teams.

CVE-2022-35936 Affected Github.com/evmos/ethermint Versions

4 component(s)
Fixed Versions:
0.18.07.0.00.7.1-rc2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/evmos/ethermint
Go
< 0.18.0
0.18.0
github.com/evmos/evmos
Go
< 7.0.0
7.0.0
github.com/crypto-org-chain/cronos
Go
< 0.7.1-rc2
0.7.1-rc2
github.com/Kava-Labs/kava
Go
< 0.18.0
0.18.0

References

Frequently Asked Questions

What is CVE-2022-35936?
CVE-2022-35936 is a security vulnerability in Github.com/evmos/ethermint involving Ethermint vulnerable to DoS through unintended Contract Selfdestruct under CWE-668: Exposure of Resource to Wrong Sphere.
Which Github.com/evmos/ethermint versions are affected?
Affected versions include releases prior to 0.18.0, 7.0.0, 0.7.1-rc2 across affected packages: github.com/evmos/ethermint, github.com/evmos/evmos, github.com/crypto-org-chain/cronos, github.com/Kava-Labs/kava.
What version fixes CVE-2022-35936?
Upgrading to 0.18.0, 7.0.0, 0.7.1-rc2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/evmos/ethermint affected?
Yes, github.com/evmos/ethermint is affected in releases prior to 0.18.0. Upgrade your dependency to 0.18.0 or later.
Is github.com/evmos/evmos affected?
Yes, github.com/evmos/evmos is affected in releases prior to 7.0.0. Upgrade your dependency to 7.0.0 or later.
What is the CVSS score of CVE-2022-35936?
CVE-2022-35936 has a CVSS v3.1 base score of 8.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H.
What CWE is associated with CVE-2022-35936?
CVE-2022-35936 is classified under CWE-668: Exposure of Resource to Wrong Sphere (The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.).
How can I check Go dependencies for CVE-2022-35936?
Run the dependency tree command: 'inspect dependencies for github.com/evmos/ethermint'. 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-f92v-grc2-w2fg",
  "modified" : "2022-08-18T19:04:47Z",
  "published" : "2022-08-18T19:04:47Z",
  "aliases" : [ "CVE-2022-35936" ],
  "summary" : "Ethermint vulnerable to DoS through unintended Contract Selfdestruct",
  "details" : "# Vulnerability Report\n\n## Impact\n\nSmart contract applications that make use of the `selfdestruct` functionality and their end-users.\n\n## Classification\n\nThe vulnerability has been classified as `high` with a CVSS score of `8.2`. It has the potential to create a denial-of-service to all contracts that can invoke the [`selfdestruct`](https://ethereum.stackexchange.com/questions/315/why-are-selfdestructs-used-in-contract-programming#347) function to destroy a smart contract. \n\n## Users Impacted\n\nDue to the successfully coordinated security vulnerability disclosure, no smart contracts were impacted through the use of this vulnerability. Smart contract states and storage values are not affected by this vulnerability. User funds and balances are safe.\n\n## Disclosure\n\nIn Ethermint running versions before `v0.17.2`, the contract `selfdestruct` invocation permanently removes the corresponding bytecode from the internal database storage. However, due to a bug in the [`DeleteAccount`](https://github.com/evmos/ethermint/blob/c9d42d667b753147977a725e98ed116c933c76cb/x/evm/keeper/statedb.go#L199-L203) function, all contracts that used the identical bytecode (i.e shared the same `CodeHash`) will also stop working once one contract invokes `selfdestruct`, even though the other contracts did not invoke the `selfdestruct` OPCODE.\n\n### Additional Details\n\nThe same contract bytecode can be deployed multiple times to create multiple contract instances. In the internal database, the bytecode is stored as a key-value entry `bytecode hash --> bytecode` which is shared by those contracts. Unfortunately, when one of the contracts invokes `selfdestruct`, it will remove the corresponding `bytecode hash -> bytecode` entry, and thus it disables all the contracts that share the same bytecode.\n\nThe attack scenario is as follows:\n\n1. The malicious attacker identifies a vulnerable contract that can invoke `selfdestruct`\n2. The attacker deploys a copy of the contract with identical bytecode\n3. Finally, the attacker triggers the `selfdestruct` operation on their redeployed contract, actively causing a DoS on the original and vulnerable contract. All transactions will fail until a workaround is used (see below).\n\n## Patches\n\n*Has the problem been patched? What versions should users upgrade to?*\n\nThis vulnerability has been patched in Ethermint versions ≥[v0.18.0](https://github.com/evmos/ethermint/releases/tag/v0.18.0). The patch has state machine-breaking changes for applications using Ethermint so a coordinated upgrade procedure is required.\n\n#### Details\n\nThe patch removes the bytecode deletion logic, i.e. contract bytecodes are never deleted from the internal database after the patch.\nAt the moment, Ethermint does not track how many times each bytecode is used, and thus it cannot determine if it is safe to delete a particular bytecode on `selfdestruct` invocations. This behavior is the same with go-ethereum.\n\n## Workarounds\n\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_\n\nIf a contract is subject to DoS due to this issue, the user can redeploy the same contract, _i.e_ with identical bytecode, so that the original contract's code is recovered.\n\nThe new contract deployment restores the `bytecode hash -> bytecode` entry in the internal state.\n\n## References\n\n*Are there any links users can visit to find out more?*\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n- Reach out to the Core Team in [Discord](https://discord.gg/evmos)\n* Open a discussion in [evmos/ethermint](https://github.com/evmos/ethermint/discussions)\n* Email us at [security@evmos.org](mailto:security@evmos.org) for security questions\n* For Press, email us at [evmos@west-comms.com](mailto:evmos@west-comms.com).\n\n### Credits\n\nThanks to the \n\n- Cronos Team: @yihuang and @tomtau for discovering the issue, @gakuzen-crypto, @polycryptics, @FinnZhangCrypto, @wilson-ang, @brianatcrypto for the impact analysis.\n- Evmos Team: @facs95 for patching the issue and @fedekunze for managing the release and coordinating between teams.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/evmos/ethermint"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.18.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.17.2"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/evmos/evmos"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.0.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 6.0.3"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/crypto-org-chain/cronos"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.7.1-rc2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.7.0"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/Kava-Labs/kava"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.18.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.17.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/evmos/ethermint/security/advisories/GHSA-f92v-grc2-w2fg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35936"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evmos/ethermint/commit/144741832007a26dbe950512acbda4ed95b2a451"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/evmos/ethermint"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/evmos/ethermint/blob/c9d42d667b753147977a725e98ed116c933c76cb/x/evm/keeper/statedb.go#L199-L203"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-668" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-18T19:04:47Z",
    "nvd_published_at" : "2022-08-05T13:15:00Z"
  }
}