Ecosyste.ms: Advisories

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

Security Advisories: GSA_kwCzR0hTQS0yN3ZoLWg2bWMtcTZnOM4ABALR

btcd did not correctly re-implement Bitcoin Core's "FindAndDelete()" functionality

Impact

The btcd Bitcoin client (versions 0.10 to 0.24) did not correctly re-implement Bitcoin Core's "FindAndDelete()" functionality. This
logic is consensus-critical: the difference in behavior with the other Bitcoin clients can lead to btcd clients accepting an invalid Bitcoin block (or rejecting a valid one).

This consensus failure can be leveraged to cause a chain split (accepting an invalid Bitcoin block) or be exploited to DoS the btcd nodes (rejecting a valid Bitcoin block). An attacker can create a standard transaction where FindAndDelete doesn't return a match but removeOpCodeByData does making btcd get a different sighash, leading to a chain split. Importantly, this vulnerability can be exploited remotely by any Bitcoin user and does not require any hash power. This is because the difference in behavior can be triggered by a "standard" Bitcoin
transaction, that is a transaction which gets relayed through the P2P network before it gets included in a Bitcoin block.

FindAndDelete vs. removeOpcodeByData

removeOpcodeByData(script []byte, dataToRemove []byte) removes any data pushes from script that contain dataToRemove. However, FindAndDelete only removes exact matches. So for example, with script = "<data> <data||foo>" and dataToRemove = "data" btcd will remove both data pushes but Bitcoin Core's FindAndDelete only removes the first <data> push.

Patches

This has been patched in btcd version v0.24.2-beta.

References

FindAndDelete: https://github.com/btcsuite/btcd/security/advisories/GHSA-27vh-h6mc-q6g8

Permalink: https://github.com/advisories/GHSA-27vh-h6mc-q6g8
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS0yN3ZoLWg2bWMtcTZnOM4ABALR
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 5 days ago
Updated: 4 days ago


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

Identifiers: GHSA-27vh-h6mc-q6g8, CVE-2024-38365
References: Repository: https://github.com/btcsuite/btcd
Blast Radius: 29.8

Affected Packages

go:github.com/btcsuite/btcd
Dependent packages: 11,705
Dependent repositories: 10,491
Downloads:
Affected Version Ranges: >= 0.10, < 0.24.2-beta.rc1
Fixed in: 0.24.2-beta.rc1
All affected versions: 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.14.4, 0.14.5, 0.14.6, 0.14.7, 0.15.0, 0.15.1, 0.15.2, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.16.4, 0.16.5, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.22.1, 0.22.2, 0.22.3, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.24.0
All unaffected versions: 0.24.2