QID 980025

QID 980025: Go (go) Security Update for github.com/ethereum/go-ethereum (GHSA-59hh-656j-3p7v)

Security update has been released for github.com/ethereum/go-ethereum to fix the vulnerability.

Note: The preceding description block is extracted directly from the security advisory. Using automation, we have attempted to clean and format it as much as possible without introducing additional issues.

A vulnerable node is susceptible to crash when processing a maliciously crafted message from a peer, via the `snap/1` protocol. The crash can be triggered by sending a malicious `snap/1` `GetTrieNodes` package.

  • CVSS V3 rated as Medium - 5.7 severity.
  • CVSS V2 rated as Medium - 3.5 severity.
  • Solution
    ```diff
    --- a/eth/protocols/snap/handler.go
    +++ b/eth/protocols/snap/handler.go
    @@ -469,7 +469,7 @@ func handleMessage(backend Backend, peer *Peer) error {
    // Storage slots requested, open the storage trie and retrieve from there
    account, err := snap.Account(common.BytesToHash(pathset[0]))
    loads++ // always account database reads, even for failures
    - if err != nil {
    + if err != nil || account == nil {
    break
    }
    stTrie, err := trie.NewSecure(common.BytesToHash(account.Root), triedb)
    diff --git a/trie/trie.go b/trie/trie.go
    index 7ea7efa835..d0f0d4e2bc 100644
    --- a/trie/trie.go
    +++ b/trie/trie.go
    @@ -174,6 +174,10 @@ func (t *Trie) TryGetNode(path []byte) ([]byte, int, error) {
    }

    func (t *Trie) tryGetNode(origNode node, path []byte, pos int) (item []byte, newnode node, resolved int, err error) {
    + // If non-existent path requested, abort
    + if origNode == nil {
    + return nil, nil, 0, nil
    + }
    // If we reached the requested path, return the current node
    if pos >= len(path) {
    // Although we most probably have the original node expanded, encoding
    @@ -193,10 +197,6 @@ func (t *Trie) tryGetNode(origNode node, path []byte, pos int) (item []byte, new
    }
    // Path still needs to be traversed, descend into children
    switch n := (origNode).(type) {
    - case nil:
    - // Non-existent path requested, abort
    - return nil, nil, 0, nil
    -
    case valueNode:
    // Path prematurely ended, abort
    return nil, nil, 0, nil

    ```
    The fixes were merged into [#23657](https://github.com/ethereum/go-ethereum/pull/23657), with commit [f1fd963](https://github.com/ethereum/go-ethereum/pull/23657/commits/f1fd963a5a965e643e52fcf805a2a02a323c32b8), and released as part of Geth [v1.10.9](https://github.com/ethereum/go-ethereum/tree/v1.10.9) on Sept 29, 2021.Workaround:
    Apply the patch above or upgrade to a version which is not vulnerable.
    Vendor References

    CVEs related to QID 980025

    Software Advisories
    Advisory ID Software Component Link
    GHSA-59hh-656j-3p7v github.com/ethereum/go-ethereum URL Logo github.com/advisories/GHSA-59hh-656j-3p7v