# CVE-2024-38365: btcd did not correctly re-implement Bitcoin Core's "FindAndDelete()" functionality

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.4
- **CVSS:** 7.4 (v3.1, CNA) `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H`
- **CVSS metrics:** Attack vector: Network; Attack complexity: High; Privileges required: None; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Remote, no login needed
- **EPSS:** 1.23% (percentile 69, 2026-11-28)
- **CWE:** CWE-670
- **Aliases:** GHSA-27vh-h6mc-q6g8, GO-2024-3189
- **Published:** 2024-10-10T16:43:17.000Z
- **Modified:** 2026-06-17T07:39:59.977Z

## Who should check

- Projects that depend on Go package github.com/btcsuite/btcd (\< 0.24.2-beta.rc1)
- Anyone running btcsuite btcd \>= 0.10.0, \< 0.24.2

## Description

btcd is an alternative full node bitcoin implementation written in Go (golang). 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. \`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. This has been patched in btcd version v0.24.2. Users are advised to upgrade. There are no known workarounds for this issue.

## Affected and fixed versions

- Go `github.com/btcsuite/btcd`: affected \< 0.24.2-beta.rc1; fixed 0.24.2-beta.rc1 (osv)
- btcsuite btcd: \>= 0.10.0, \< 0.24.2 (cvelist)

## Mitigation

- Upgrade github.com/btcsuite/btcd to 0.24.2-beta.rc1 or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2024-38365. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2024-38365.md
Affected: github.com/btcsuite/btcd < 0.24.2-beta.rc1
Fixed in: 0.24.2-beta.rc1

Steps:
1. Search this machine and project for github.com/btcsuite/btcd (Go), btcsuite btcd: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2024-38365 being exploited?

There is no confirmed exploitation: CVE-2024-38365 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 1.23% chance of exploitation in the next 30 days (as of 2026-11-28).

### How serious is CVE-2024-38365?

High: CVSS 7.4 (v3.1, scored by CNA). Remote, no login needed. The attack needs conditions outside the attacker's control, which makes it harder.

### Which versions are affected by CVE-2024-38365?

github.com/btcsuite/btcd \< 0.24.2-beta.rc1.

### Is there a fix for CVE-2024-38365?

Yes. Fixed in 0.24.2-beta.rc1. Upgrade github.com/btcsuite/btcd to 0.24.2-beta.rc1 or later.

### How do I check if I'm affected by CVE-2024-38365?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/btcsuite/btcd/security/advisories/GHSA-27vh-h6mc-q6g8>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2024-38365>
- patch: <https://github.com/btcsuite/btcd/commit/04469e600e7d4a58881e2e5447d19024e49800f5>
- other: <https://delvingbitcoin.org/t/cve-2024-38365-public-disclosure-btcd-findanddelete-bug/1184>
- other: <https://github.com/btcsuite/btcd/releases/tag/v0.24.2>
- other: <https://github.com/btcsuite/btcd>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2024-38365>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-27vh-h6mc-q6g8> (license: <https://creativecommons.org/licenses/by/4.0/>)
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GO-2024-3189> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2024-38365> · JSON: <https://flawdb.com/api/v1/entries/CVE-2024-38365>
