Skip to content

Consensus flaw during block processing in github.com/ethereum/go-ethereum

Moderate severity GitHub Reviewed Published Dec 11, 2020 in ethereum/go-ethereum • Updated Feb 14, 2023

Package

gomod github.com/ethereum/go-ethereum (Go)

Affected versions

>= 1.9.4, < 1.9.20

Patched versions

1.9.20

Description

Impact

A consensus-vulnerability in Geth could cause a chain split, where vulnerable versions refuse to accept the canonical chain.

Description

A flaw was repoted at 2020-08-11 by John Youngseok Yang (Software Platform Lab), where a particular sequence of transactions could cause a consensus failure.

  • Tx 1:

    • sender invokes caller.
    • caller invokes 0xaa. 0xaa has 3 wei, does a self-destruct-to-self
    • caller does a 1 wei -call to 0xaa, who thereby has 1 wei (the code in 0xaa still executed, since the tx is still ongoing, but doesn't redo the selfdestruct, it takes a different path if callvalue is non-zero)
  • Tx 2:

    • sender does a 5-wei call to 0xaa. No exec (since no code).

In geth, the result would be that 0xaa had 6 wei, whereas OE reported (correctly) 5 wei. Furthermore, in geth, if the second tx was not executed, the 0xaa would be destructed, resulting in 0 wei. Thus obviously wrong.

It was determined that the root cause was this commit from this PR. The semantics of createObject was subtly changd, into returning a non-nil object (with deleted=true) where it previously did not if the account had been destructed. This return value caused the new object to inherit the old balance:

func (s *StateDB) CreateAccount(addr common.Address) {
	newObj, prev := s.createObject(addr)
	if prev != nil {
		newObj.setBalance(prev.data.Balance)
	}
}

It was determined that the minimal possible correct fix was

+++ b/core/state/statedb.go
@@ -589,7 +589,10 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
                s.journal.append(resetObjectChange{prev: prev, prevdestruct: prevdestruct})
        }
        s.setStateObject(newobj)
-       return newobj, prev
+       if prev != nil && !prev.deleted {
+               return newobj, prev
+       }
+       return newobj, nil

Patches

See above. The fix was included in Geth v1.9.20 "Paragade".

Credits

The bug was found by @johnyangk and reported via [email protected].

For more information

If you have any questions or comments about this advisory:

References

@fjl fjl published to ethereum/go-ethereum Dec 11, 2020
Reviewed May 21, 2021
Published to the GitHub Advisory Database Jun 29, 2021
Last updated Feb 14, 2023

Severity

Moderate

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
High
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

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:H/PR:L/UI:N/S:U/C:N/I:H/A:N

EPSS score

0.050%
(21st percentile)

Weaknesses

CVE ID

CVE-2020-26265

GHSA ID

GHSA-xw37-57qp-9mm4

Source code

Credits

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