Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1mOTJ2LWdyYzItdzJmZ84AAuFq

Ethermint vulnerable to DoS through unintended Contract Selfdestruct

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 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 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. 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:

Credits

Thanks to the

Permalink: https://github.com/advisories/GHSA-f92v-grc2-w2fg
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1mOTJ2LWdyYzItdzJmZ84AAuFq
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: over 1 year ago
Updated: over 1 year ago


CVSS Score: 8.2
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H

Identifiers: GHSA-f92v-grc2-w2fg, CVE-2022-35936
References: Repository: https://github.com/evmos/ethermint
Blast Radius: 15.6

Affected Packages

go:github.com/Kava-Labs/kava
Dependent packages: 0
Dependent repositories: 0
Downloads:
Affected Version Ranges: <= 0.17.5
Fixed in: 0.18.0
All affected versions: 0.1.1, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.4.1, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.10.0, 0.11.0, 0.11.1, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.17.0, 0.17.1, 0.17.3, 0.17.4, 0.17.5
All unaffected versions: 0.17.7, 0.18.0, 0.18.1, 0.18.2, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.21.0, 0.21.1, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.24.0, 0.24.1, 0.24.2, 0.24.3, 0.25.0, 0.25.1, 0.26.0
go:github.com/crypto-org-chain/cronos
Dependent packages: 7
Dependent repositories: 3
Downloads:
Affected Version Ranges: <= 0.7.0
Fixed in: 0.7.1-rc2
All affected versions: 0.5.1, 0.5.2, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.6.5, 0.6.6, 0.6.7, 0.6.8, 0.6.9, 0.6.10, 0.6.11, 0.7.0
All unaffected versions: 0.7.1, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15
go:github.com/evmos/evmos
Dependent packages: 0
Dependent repositories: 0
Downloads:
Affected Version Ranges: <= 6.0.3
Fixed in: 7.0.0
All affected versions: 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.2.0, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 1.1.3
All unaffected versions:
go:github.com/evmos/ethermint
Dependent packages: 189
Dependent repositories: 81
Downloads:
Affected Version Ranges: <= 0.17.2
Fixed in: 0.18.0
All affected versions: 0.0.0, 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.4.0, 0.4.1, 0.5.0, 0.6.0, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 0.8.1, 0.9.0, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.11.0, 0.11.1, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.14.0, 0.14.1, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.17.1, 0.17.2
All unaffected versions: 0.18.0, 0.19.0, 0.19.1, 0.19.2, 0.19.3, 0.20.0, 0.21.0, 0.22.0