Skip to content

Ethermint vulnerable to DoS through unintended Contract Selfdestruct

High severity GitHub Reviewed Published Aug 5, 2022 in evmos/ethermint • Updated Jan 30, 2023

Package

gomod github.com/Kava-Labs/kava (Go)

Affected versions

<= 0.17.5

Patched versions

0.18.0
gomod github.com/crypto-org-chain/cronos (Go)
<= 0.7.0
0.7.1-rc2
gomod github.com/evmos/ethermint (Go)
<= 0.17.2
0.18.0
gomod github.com/evmos/evmos (Go)
<= 6.0.3
7.0.0

Description

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:

  • Reach out to the Core Team in Discord

Credits

Thanks to the

References

@fedekunze fedekunze published to evmos/ethermint Aug 5, 2022
Published by the National Vulnerability Database Aug 5, 2022
Published to the GitHub Advisory Database Aug 18, 2022
Reviewed Aug 18, 2022
Last updated Jan 30, 2023

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:H

EPSS score

0.131%
(50th percentile)

Weaknesses

CVE ID

CVE-2022-35936

GHSA ID

GHSA-f92v-grc2-w2fg

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.