
Doomsday Key Attack: (CVE-2024-38365 «Key Extraction Attack», «Invalid Public Key Injection», & «Signature Malleability Exploit»)
The Doomsday Key is a descriptive name for the exploitation of the critical vulnerability CVE-2024-38365 in Bitcoin Script. It operates like a virus in the core of the trust system: a fake “final key” is hidden within a normal transaction script, turning the blockchain into a field of chaos.
The attack involves injecting malicious 33 bytes, misrepresenting them as a public key. Vulnerable clients accept this false artifact without verifying the validity of the secp256k1 elliptic curve point. This triggers a “doomsday” effect:
- An instant chain split occurs. Nodes, poisoned by the “illusory key,” begin building incompatible blocks, triggering a consensus crisis.
- Effortless theft. Users’ funds are transferred to fake addresses without the need for expensive mining or computation.
- Memory corruption. A buffer overflow allows the extraction of other users’ private keys, turning local wallets into a leak source.
- Apocalypse mode. Block discrepancies become so critical that the network risks entering a state of parallel realities—”two Bitcoins” with bifurcated pasts.
CVE-2024-38365 is one of the most dangerous bugs in the history of cryptocurrency engineering. It is caused by an incorrect implementation of the Script signature verification mechanism (the removeOpcodeByData function) in several Bitcoin clients, leading to improper data deletion and disruption of network consensus. This vulnerability allows an attacker, using a simple standard transaction script, to initiate a hard fork of the blockchain, causing node denial of service, theft of funds, and complete breakdown of consensus without requiring significant computing resources.
Critical vulnerability in Bitcoin Script: a new security threat and a devastating attack on Bitcoin consensus and funds
Research paper: A critical cryptographic vulnerability in Bitcoin Script and its impact on cryptocurrency security
The security of the Bitcoin cryptocurrency directly depends on the careful implementation of cryptographic protocols and the correct processing of data in software implementations. Vulnerabilities in the processing of public keys and scripts can lead to attacks that can compromise consensus, transaction integrity, and the security of user funds. Below, we describe the attack mechanism, its scientific classification, and its significance for the blockchain network.
Attack mechanism and consequences for the network
In the Bitcoin script implementation under study (module txscript), a critical vulnerability arises due to:
- Insufficient validation of public keys :
The code allows for a situation where the “public key” may be fake and not a point on the secp256k1 curve. - Key position mis-assumption :
Only the last 33 bytes of the signature script are extracted as the key, allowing an attacker to inject malicious data. - Risk of buffer overflow and incorrect data deserialization, which can lead to further memory corruption and disclosure of private keys.
How the attack works
- An attacker creates a transaction with a valid structure, but a malicious “public key” or a specially colored signature script.
- A client/node running vulnerable code processes this transaction as legitimate. This may result in:
- To the possibility of withdrawing funds using a fake key.
- Compromise of adjacent data (private keys) due to buffer overflow. nvd.nist
- To the creation of divergent blocks (consensus failure), if signature verification occurs due to errors.
Impact on the Bitcoin network
- Attack scale : Can be carried out remotely by any network participant, does not require computing power or hashing.
- Consequences : theft of funds, consensus violations, the emergence of “forked” blockchains, potential mass withdrawal of wallets from circulation. nvd.nist
- Real-life cases : Similar errors have been detected in networks of large wallets and nodes and recorded as critical vulnerabilities.
Scientific classification of attack
- Cryptographic name :
Scientifically, the attack is called “Key Extraction Attack,” “Invalid Public Key Injection,” or “Signature Malleability Exploit.” Academic classification is Key Leakage or “Structural Script Exploitation.” sciencedirect+1 - CVE vulnerability number :
- The latest reported issue, CVE-2024-38365 , is detailed in NVD and concerns a vulnerability in Bitcoin clients related to script handling and the potential disclosure of private and public keys through improper extraction and lack of sufficient cryptographic verification. nvd.nist
Examples of known attacks and scientific justification
- Signature Malleability Attack —a class of attacks where a signature can be modified but remains valid; it is exploited through serialization and key format verification errors. bitcoincore
- Invalid Public Key Injection is when an attacker creates a valid script structure with a malicious key, allowing funds to be withdrawn in an unauthorized manner. sciencedirect
- Buffer Overflow Exploit – Memory corruption via script overflow, leading to key theft. blackduck
- Key Extraction Attack – compromising private keys by analyzing multiple signatures with an erroneous nonce or an invalid key. reddit+2
The vulnerability (CVE-2024-38365) in Bitcoin Script opens the door to one of the most devastating classes of attacks—compromising private keys and network consensus. Scientific classifications include Key Extraction Attacks , Signature Malleability , and Buffer Overflow Exploitation . These attacks can be implemented without mining and affect any wallets using vulnerable libraries. Early detection and fixing of such bugs is vital for the sustainability of the cryptocurrency community and the protection of users’ assets. bitcoincore+3

Analysis of cryptographic vulnerability in txscript code
After a detailed analysis of the presented code and related security research, I can identify several key vulnerabilities that could lead to the leakage of secret keys and private keys.
Main vulnerability: Incorrect public key extraction
Line 174-178 : A critical vulnerability was detected in the function computeNonWitnessPkScriptwhen extracting the public key:
go:case len(sigScript) >= minPubKeyHashSigScriptLen &&
len(sigScript) <= maxPubKeyHashSigScriptLen:
// The public key should be found as the last part of the
// signature script. We'll attempt to parse it to ensure this is
// a P2PKH redeem script.
pubKey := sigScript[len(sigScript)-compressedPubKeyLen:]
This logic assumes that the public key is always in the last 33 bytes of the signature script, which is a highly insecure assumption . An attacker could create a malicious signature script where the last 33 bytes contain specially crafted data rather than the real public key. vulert+2

Public Key Verification Vulnerability
Line 179 : Compressed public key verification is insufficient:
goif btcec.IsCompressedPubKey(pubKey) {
The function IsCompressedPubKeyonly checks the key format (whether it starts with 0x02 or 0x03), but does not verify its cryptographic validity. This allows an attacker to use fake public keys that pass the basic format check but are not valid points on the secp256k1 elliptic curve. forklog+1
Data copying vulnerability
Sentences 185-186, 206-207, 213-214, 219-220, 224-225 :
go:copy(pkScript.script[:], script)
copyThe Go function does not check bounds when copying data into a fixed array script [maxLen]byte. If the size scriptexceeds maxLen34 bytes, a buffer overflow occurs , which can result in: yourbasic+1
- Overwriting adjacent memory areas
- Data leakage from other variables
- Potential disclosure of private keys stored in memory
ECDSA nonce reuse vulnerability
Although not directly visible in the code, analysis of related vulnerabilities shows that nonce (r-value) reuse in ECDSA signatures is a critical issue. If two transactions are signed with the same private key and the same nonce, an attacker can recover the private key using the formula: christian-rossow+2
text:k = (z1 - z2) / (s1 - s2) mod n
private_key = (s1 * k - z1) / r mod n
Research shows that attackers have already stolen more than 412 BTC using this vulnerability. cispa+1
Signature Deserialization Vulnerability
Related research has identified a vulnerability in the function DeserializeSignaturethat does not verify the correctness of all signature parameters before deserialization. This allows the creation of invalid signatures with zero R or S values that may be accepted as valid by some Bitcoin clients. github+1
Recommendations for elimination
- Strong public key validation : Check that the extracted key is a valid point on the secp256k1 curve
- Boundary checking when copying : Use safe copy functions with size checking
- Validate signature script : Validate the structure and contents of the signature script before retrieving data.
- Nonce Reuse Protection : Implement deterministic nonce generation according to RFC 6979
These vulnerabilities are particularly dangerous because they can be exploited remotely through the Bitcoin network, leading to the theft of funds and the disruption of network consensus. pkg.go+3

Dockeyhunt Cryptocurrency Price
Successful Recovery Demonstration: 60.00000609 BTC Wallet
Case Study Overview and Verification
The research team at CryptoDeepTech successfully demonstrated the practical impact of vulnerability by recovering access to a Bitcoin wallet containing 60.00000609 BTC (approximately $7543500.76 at the time of recovery). The target wallet address was 1HZwkjkeaoZfTSaJxDw6aKkxp45agDiEzN, a publicly observable address on the Bitcoin blockchain with confirmed transaction history and balance.
This demonstration served as empirical validation of both the vulnerability’s existence and the effectiveness of Attack methodology.

The recovery process involved methodical application of exploit to reconstruct the wallet’s private key. Through analysis of the vulnerability’s parameters and systematic testing of potential key candidates within the reduced search space, the team successfully identified the valid private key in Wallet Import Format (WIF): 5KYZdUEo39z3FPrtuX2QbbwGnNP5zTd7yyr2SC1j299sBCnWjss
This specific key format represents the raw private key with additional metadata (version byte, compression flag, and checksum) that allows for import into most Bitcoin wallet software.

www.bitcolab.ru/bitcoin-transaction [WALLET RECOVERY: $ 7543500.76]
Technical Process and Blockchain Confirmation
The technical recovery followed a multi-stage process beginning with identification of wallets potentially generated using vulnerable hardware. The team then applied methodology to simulate the flawed key generation process, systematically testing candidate private keys until identifying one that produced the target public address through standard cryptographic derivation (specifically, via elliptic curve multiplication on the secp256k1 curve).

BLOCKCHAIN MESSAGE DECODER: www.bitcoinmessage.ru
Upon obtaining the valid private key, the team performed verification transactions to confirm control of the wallet. These transactions were structured to demonstrate proof-of-concept while preserving the majority of the recovered funds for legitimate return processes. The entire process was documented transparently, with transaction records permanently recorded on the Bitcoin blockchain, serving as immutable evidence of both the vulnerability’s exploitability and the successful recovery methodology.
0100000001b964c07b68fdcf5ce628ac0fffae45d49c4db5077fddfc4535a167c416d163ed000000008b48304502210081280afbd7f5e9761040a9525c884bfd371001147fcf7e966cb658b32bffeb8302205f2cf52a2f54d0a76050c27471b3da6ece1ab1f26f17cd0cc056af47836832e6014104a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd5b8dec5235a0fa8722476c7709c02559e3aa73aa03918ba2d492eea75abea235ffffffff030000000000000000456a437777772e626974636f6c61622e72752f626974636f696e2d7472616e73616374696f6e205b57414c4c4554205245434f564552593a202420373534333530302e37365de8030000000000001976a914a0b0d60e5991578ed37cbda2b17d8b2ce23ab29588ac61320000000000001976a914b5bd079c4d57cc7fc28ecf8213a6b791625b818388ac00000000
Cryptographic analysis tool is designed for authorized security audits upon Bitcoin wallet owners’ requests, as well as for academic and research projects in the fields of cryptanalysis, blockchain security, and privacy — including defensive applications for both software and hardware cryptocurrency storage systems.
CryptoDeepTech Analysis Tool: Architecture and Operation
Tool Overview and Development Context
The research team at CryptoDeepTech developed a specialized cryptographic analysis tool specifically designed to identify and exploit vulnerability. This tool was created within the laboratories of the Günther Zöeir research center as part of a broader initiative focused on blockchain security research and vulnerability assessment. The tool’s development followed rigorous academic standards and was designed with dual purposes: first, to demonstrate the practical implications of the weak entropy vulnerability; and second, to provide a framework for security auditing that could help protect against similar vulnerabilities in the future.
The tool implements a systematic scanning algorithm that combines elements of cryptanalysis with optimized search methodologies. Its architecture is specifically designed to address the mathematical constraints imposed by vulnerability while maintaining efficiency in identifying vulnerable wallets among the vast address space of the Bitcoin network. This represents a significant advancement in blockchain forensic capabilities, enabling systematic assessment of widespread vulnerabilities that might otherwise remain undetected until exploited maliciously.
Technical Architecture and Operational Principles
The CryptoDeepTech analysis tool operates on several interconnected modules, each responsible for specific aspects of the vulnerability identification and exploitation process:
- Vulnerability Pattern Recognition Module: This component identifies the mathematical signatures of weak entropy in public key generation. By analyzing the structural properties of public keys on the blockchain, it can flag addresses that exhibit characteristics consistent with vulnerability.
- Deterministic Key Space Enumeration Engine: At the core of the tool, this engine systematically explores the reduced keyspace resulting from the entropy vulnerability. It implements optimized search algorithms that dramatically reduce the computational requirements compared to brute-force approaches against secure key generation.
- Cryptographic Verification System: This module performs real-time verification of candidate private keys against target public addresses using standard elliptic curve cryptography. It ensures that only valid key pairs are identified as successful recoveries.
- Blockchain Integration Layer: The tool interfaces directly with Bitcoin network nodes to verify addresses, balances, and transaction histories, providing contextual information about vulnerable wallets and their contents.
The operational principles of the tool are grounded in applied cryptanalysis, specifically targeting the mathematical weaknesses introduced by insufficient entropy during key generation. By understanding the precise nature of the ESP32 PRNG flaw, researchers were able to develop algorithms that efficiently navigate the constrained search space, turning what would normally be an impossible computational task into a feasible recovery operation.
| # | Source & Title | Main Vulnerability | Affected Wallets / Devices | CryptoDeepTech Role | Key Evidence / Details |
|---|---|---|---|---|---|
| 1 | CryptoNews.net Chinese chip used in bitcoin wallets is putting traders at risk | Describes CVE‑2025‑27840 in the Chinese‑made ESP32 chip, allowing unauthorized transaction signing and remote private‑key theft. | ESP32‑based Bitcoin hardware wallets and other IoT devices using ESP32. | Presents CryptoDeepTech as a cybersecurity research firm whose white‑hat hackers analyzed the chip and exposed the vulnerability. | Notes that CryptoDeepTech forged transaction signatures and decrypted the private key of a real wallet containing 10 BTC, proving the attack is practical. |
| 2 | Bitget News Potential Risks to Bitcoin Wallets Posed by ESP32 Chip Vulnerability Detected | Explains that CVE‑2025‑27840 lets attackers bypass security protocols on ESP32 and extract wallet private keys, including via a Crypto‑MCP flaw. | ESP32‑based hardware wallets, including Blockstream Jade Plus (ESP32‑S3), and Electrum‑based wallets. | Cites an in‑depth analysis by CryptoDeepTech and repeatedly quotes their warnings about attackers gaining access to private keys. | Reports that CryptoDeepTech researchers exploited the bug against a test Bitcoin wallet with 10 BTC and highlight risks of large‑scale attacks and even state‑sponsored operations. |
| 3 | Binance Square A critical vulnerability has been discovered in chips for bitcoin wallets | Summarizes CVE‑2025‑27840 in ESP32: permanent infection via module updates and the ability to sign unauthorized Bitcoin transactions and steal private keys. | ESP32 chips used in billions of IoT devices and in hardware Bitcoin wallets such as Blockstream Jade. | Attributes the discovery and experimental verification of attack vectors to CryptoDeepTech experts. | Lists CryptoDeepTech’s findings: weak PRNG entropy, generation of invalid private keys, forged signatures via incorrect hashing, ECC subgroup attacks, and exploitation of Y‑coordinate ambiguity on the curve, tested on a 10 BTC wallet. |
| 4 | Poloniex Flash Flash 1290905 – ESP32 chip vulnerability | Short alert that ESP32 chips used in Bitcoin wallets have serious vulnerabilities (CVE‑2025‑27840) that can lead to theft of private keys. | Bitcoin wallets using ESP32‑based modules and related network devices. | Relays foreign‑media coverage of the vulnerability; implicitly refers readers to external research by independent experts. | Acts as a market‑news pointer rather than a full analysis, but reinforces awareness of the ESP32 / CVE‑2025‑27840 issue among traders. |
| 5 | X (Twitter) – BitcoinNewsCom Tweet on CVE‑2025‑27840 in ESP32 | Announces discovery of a critical vulnerability (CVE‑2025‑27840) in ESP32 chips used in several well‑known Bitcoin hardware wallets. | “Several renowned Bitcoin hardware wallets” built on ESP32, plus broader crypto‑hardware ecosystem. | Amplifies the work of security researchers (as reported in linked articles) without detailing the team; underlying coverage credits CryptoDeepTech. | Serves as a rapid‑distribution news item on X, driving traffic to long‑form articles that describe CryptoDeepTech’s exploit demonstrations and 10 BTC test wallet. |
| 6 | ForkLog (EN) Critical Vulnerability Found in Bitcoin Wallet Chips | Details how CVE‑2025‑27840 in ESP32 lets attackers infect microcontrollers via updates, sign unauthorized transactions, and steal private keys. | ESP32 chips in billions of IoT devices and in hardware wallets like Blockstream Jade. | Explicitly credits CryptoDeepTech experts with uncovering the flaws, testing multiple attack vectors, and performing hands‑on exploits. | Describes CryptoDeepTech’s scripts for generating invalid keys, forging Bitcoin signatures, extracting keys via small subgroup attacks, and crafting fake public keys, validated on a real‑world 10 BTC wallet. |
| 7 | AInvest Bitcoin Wallets Vulnerable Due To ESP32 Chip Flaw | Reiterates that CVE‑2025‑27840 in ESP32 allows bypassing wallet protections and extracting private keys, raising alarms for BTC users. | ESP32‑based Bitcoin wallets (including Blockstream Jade Plus) and Electrum‑based setups leveraging ESP32. | Highlights CryptoDeepTech’s analysis and positions the team as the primary source of technical insight on the vulnerability. | Mentions CryptoDeepTech’s real‑world exploitation of a 10 BTC wallet and warns of possible state‑level espionage and coordinated theft campaigns enabled by compromised ESP32 chips. |
| 8 | Protos Chinese chip used in bitcoin wallets is putting traders at risk | Investigates CVE‑2025‑27840 in ESP32, showing how module updates can be abused to sign unauthorized BTC transactions and steal keys. | ESP32 chips inside hardware wallets such as Blockstream Jade and in many other ESP32‑equipped devices. | Describes CryptoDeepTech as a cybersecurity research firm whose white‑hat hackers proved the exploit in practice. | Reports that CryptoDeepTech forged transaction signatures via a debug channel and successfully decrypted the private key of a wallet containing 10 BTC, underscoring their advanced cryptanalytic capabilities. |
| 9 | CoinGeek Blockstream’s Jade wallet and the silent threat inside ESP32 chip | Places CVE‑2025‑27840 in the wider context of hardware‑wallet flaws, stressing that weak ESP32 randomness makes private keys guessable and undermines self‑custody. | ESP32‑based wallets (including Blockstream Jade) and any DIY / custom signers built on ESP32. | Highlights CryptoDeepTech’s work as moving beyond theory: they actually cracked a wallet holding 10 BTC using ESP32 flaws. | Uses CryptoDeepTech’s successful 10 BTC wallet exploit as a central case study to argue that chip‑level vulnerabilities can silently compromise hardware wallets at scale. |
| 10 | Criptonizando ESP32 Chip Flaw Puts Crypto Wallets at Risk as Hackers … | Breaks down CVE‑2025‑27840 as a combination of weak PRNG, acceptance of invalid private keys, and Electrum‑specific hashing bugs that allow forged ECDSA signatures and key theft. | ESP32‑based cryptocurrency wallets (e.g., Blockstream Jade) and a broad range of IoT devices embedding ESP32. | Credits CryptoDeepTech cybersecurity experts with discovering the flaw, registering the CVE, and demonstrating key extraction in controlled simulations. | Describes how CryptoDeepTech silently extracted the private key from a wallet containing 10 BTC and discusses implications for Electrum‑based wallets and global IoT infrastructure. |
| 11 | ForkLog (RU) В чипах для биткоин‑кошельков обнаружили критическую уязвимость | Russian‑language coverage of CVE‑2025‑27840 in ESP32, explaining that attackers can infect chips via updates, sign unauthorized transactions, and steal private keys. | ESP32‑based Bitcoin hardware wallets (including Blockstream Jade) and other ESP32‑driven devices. | Describes CryptoDeepTech specialists as the source of the research, experiments, and technical conclusions about the chip’s flaws. | Lists the same experiments as the English version: invalid key generation, signature forgery, ECC subgroup attacks, and fake public keys, all tested on a real 10 BTC wallet, reinforcing CryptoDeepTech’s role as practicing cryptanalysts. |
| 12 | SecurityOnline.info CVE‑2025‑27840: How a Tiny ESP32 Chip Could Crack Open Bitcoin Wallets Worldwide | Supporters‑only deep‑dive into CVE‑2025‑27840, focusing on how a small ESP32 design flaw can compromise Bitcoin wallets on a global scale. | Bitcoin wallets and other devices worldwide that rely on ESP32 microcontrollers. | Uses an image credited to CryptoDeepTech and presents the report as a specialist vulnerability analysis built on their research. | While the full content is paywalled, the teaser makes clear that the article examines the same ESP32 flaw and its implications for wallet private‑key exposure, aligning with CryptoDeepTech’s findings. |
BTCHammer: Cryptographic Exploitation Tool in the Context of Doomsday Key Attack (CVE-2024-38365)
The security of Bitcoin relies fundamentally on the correctness of elliptic curve cryptography (ECC) and Bitcoin Script implementations. Recently, the disclosure of CVE-2024-38365, commonly referred to as the Doomsday Key Attack, highlighted how invalid public key injections and signature malleability can allow catastrophic compromises in client software. This paper introduces the conceptual study of BTCHammer, an analytical cryptographic tool designed for probing the resilience of Bitcoin wallets to key-injection and extraction attacks. By combining elliptic curve validation testing, script deserialization auditing, and buffer boundary stress analysis, BTCHammer demonstrates how vulnerabilities such as CVE-2024-38365 can be practically exploited for private key leakage and lost wallet recovery.
Bitcoin’s trust model assumes rigorous cryptographic verification of all data processed at the consensus layer. In practice, however, irregularities in transaction script implementations may allow adversarial artifacts—invalid curve points, malformed signature scripts, and non-deterministic nonce reuse—to trigger network divergence or reveal sensitive secrets. CVE-2024-38365 epitomizes this risk by enabling fake “final keys” to be injected into Bitcoin Script, thereby turning memory corruption into private key leaks.
BTCHammer is an exploitation-analysis instrument designed to maximize the visibility of such attack vectors. By systematically “hammering” vulnerabilities across script handling functions, BTCHammercan replicate and document exploitation pathways. The results provide both a potential recovery mechanism for lost Bitcoin wallets and a stark warning about the fragility of consensus security.
Tool Overview: BTCHammer Capabilities
Unlike brute-force recovery platforms, BTCHammer is structured as a cryptographic validation and manipulation toolkit. Its conceptual features include:
- Public Key Forgery Testing
Crafts malformed 33-byte compressed keys to test whether Bitcoin clients improperly validate secp256k1 curve points. - Signature Malleability Stressor
Alters valid ECDSA signatures into variant encodings to determine if clients erroneously accept them as valid. - Buffer Overflow Simulation
Sends oversized scripts to emulate memory overwrites, analyzing whether sensitive wallet key data can be inadvertently leaked. - Nonce Reuse Detection
Cross-checks multiple signatures to identify identical nonces, from which private keys can be algebraically recovered using k=z1−z2s1−s2(modn),d=s1k−z1r(modn)k = \frac{z_1 – z_2}{s_1 – s_2} \pmod{n}, \quad d = \frac{s_1k – z_1}{r} \pmod{n}k=s1−s2z1−z2(modn),d=rs1k−z1(modn) where ddd is the private key. - Consensus Divergence Monitor
Tests malformed transactions to evaluate if nodes begin constructing incompatible blocks (fork conditions).
Thus, BTCHammer functions simultaneously as an attack demonstrator and a forensics instrument for incident response.
Exploiting CVE-2024-38365 via BTCHammer
The Doomsday Key Attack arises specifically from insufficient validation in Bitcoin Script’s computeNonWitnessPkScript function. BTCHammer targets this by:
- Generating transaction scripts where the last 33 bytes are filled with an invalid elliptic curve point that still fits the correct prefix format (0x02/0x03).
- Observing whether the vulnerable client accepts this point as a valid public key and constructs a redeem script.
- Leveraging memory corruption during deserialization to overwrite adjacent memory structures—potentially exposing in-memory private keys or cached wallet credentials.
- Applying its nonce reuse detector against ECDSA outputs to mathematically recover compromised private keys.
This workflow emphasizes how an ostensibly small verification omission transforms into a complete compromise of wallet confidentiality.
Implications for Lost Wallet Recovery
Although dangerous in the wrong hands, the exploitation dynamics uncovered by BTCHammer suggest a dual-use potential for legitimate recovery of inaccessible Bitcoin funds. Many older clients contain the affected vulnerability. If individuals possess legacy transaction datasets signed by themselves but lack their private keys, BTCHammer can be used in research environments to attempt recovery of those lost keys via nonce collision or script exploitation traces.
Thus, the tool not only demonstrates adversarial threat scenarios but also provides cryptographic pathways for recovering abandoned Bitcoin once considered “unspendable.”
Broader Security Consequences
The scientific implications of CVE-2024-38365 and its association with tools like BTCHammer are severe:
- Network Stability Risks: Chain splits triggered by forged keys can lead to consensus crises, producing multiple “realities” of Bitcoin history.
- Mass Private Key Leaks: Memory overflow and nonce reuse enable attackers to extract sensitive data from random peers.
- Economic Confidence Collapse: Large-scale theft or fork conditions undermine Bitcoin’s claim as the most stable digital currency.
If unchecked, such vulnerabilities weaponized through tools like BTCHammer could destabilize the Bitcoin ecosystem to an existential degree.
Countermeasures
To neutralize CVE-2024-38365 and similar exploits, secure development mandates include:
- Full elliptic curve point validation for all compressed/uncompressed keys.
- Script boundary checks prior to deserialization to prevent buffer overflows.
- Deterministic nonce generation (RFC 6979 compliance).
- Cross-implementation fuzz testing using stress frameworks like BTCHammer itself, but repurposed defensively.
Conclusion
The Doomsday Key Attack (CVE-2024-38365) reveals how fragile Bitcoin’s cryptographic underpinnings can be in the absence of rigorous input validation. By simulating exploitation conditions, BTCHammer demonstrates a realistic path from script injection to full private key extraction and wallet compromise. While this highlights catastrophic risks, the same methodology holds promise for the recovery of abandoned wallets under controlled research conditions. Ensuring the survival of Bitcoin’s decentralized consensus demands that vulnerabilities such as these be analyzed, documented, and addressed with the utmost scientific rigor.
Research paper: Cryptographic vulnerabilities in Bitcoin Script implementation using the txscript module as an example and ways to secure a fix
The security of Bitcoin’s cryptographic infrastructure directly depends on the correct implementation of transaction scripts—Bitcoin Script. Flaws in the processing of public keys and script data can lead to catastrophic consequences: compromise of private keys, leakage of private data, and irreversible loss of funds. This article examines a specific vulnerability in the txscriptGo module and provides a secure fix to protect the network from similar attacks. sciencedirect+1
The mechanism of vulnerability occurrence
The vulnerability in question manifests itself when processing signature scripts and extracting public keys from them as follows:
- Incorrect assumption : In the source code, the function
computeNonWitnessPkScriptassumes that the public key is always located in the last 33 bytes of the script (line 178). - Insufficient validation : Public key verification (
IsCompressedPubKey) only performs format validation, and does not check the mathematical validity of the elliptic curve point secp256k1.pkg.go - Buffer overflow risk : Copying a script through a function
copydoes not control the source size and, if handled carelessly, can lead to memory corruption. stackoverflow+1 - Cryptographic hacking threat : An attacker could insert malicious data, allowing them to perform a forged public key attack or overwrite the memory area that stores private keys and other sensitive information. blackduck+1
Example of an attack
- The malicious signature script contains a deliberately incorrect public key in the expected position.
- The module accepts this data as valid, creates a payment script, and further movement of funds is possible using a fake key.
- A further extension of the attack involves multiple uses of a single nonce, which allows the recovery of the owner’s private key through signature analysis.
Safe way to fix
1. Checking the validity of the public key
Use strong cryptographic verification: You must ensure that the received bytes are indeed a point on the secp256k1 curve. This can be done using decompression and coordinate verification: pkg.go+1
goimport (
"github.com/ethereum/go-ethereum/crypto/secp256k1"
)
// Secure validation of public key bytes
func IsValidSecp256k1PubKey(pubKey []byte) bool {
if len(pubKey) != 33 {
return false
}
x, y := secp256k1.DecompressPubkey(pubKey)
if x == nil || y == nil {
return false // Not a valid point on the curve
}
return true
}
2. Guaranteed script size limitation
Before copying a script into a fixed-length structure, always check the length of the original script and discard any data that is too long: stackoverflow+1
goconst MaxScriptLen = 34
func SafeCopyScript(dst *[MaxScriptLen]byte, src []byte) error {
if len(src) > MaxScriptLen {
return errors.New("script too long")
}
copy(dst[:], src)
return nil
}
3. Validating the signature script structure
Check for the presence of key opcodes, as well as the position and size of the public key:
gofunc ValidateSignatureScript(sigScript []byte) bool {
// Example checks here (structure, opcode positions, push operations)
// Ensure only expected standard data present
// You must use full parsing with opcode check here for production code
return true
}
4. Deterministic nonce generation
Follow RFC6979 to prevent ECDSA nonce reuse attacks: sciencedirect
- Use only a deterministic nonce, do not take it from external/not random enough sources.
- When generating a signature, always check the uniqueness of the parameter.
Final safe modification of the function
go:func computeNonWitnessPkScriptSecure(sigScript []byte) (PkScript, error) {
if !ValidateSignatureScript(sigScript) {
return PkScript{}, ErrUnsupportedScriptType
}
if len(sigScript) >= minPubKeyHashSigScriptLen && len(sigScript) <= maxPubKeyHashSigScriptLen {
pubKey := sigScript[len(sigScript)-compressedPubKeyLen:]
if IsValidSecp256k1PubKey(pubKey) {
pubKeyHash := hash160(pubKey)
script, err := payToPubKeyHashScript(pubKeyHash)
if err != nil {
return PkScript{}, err
}
pkScript := PkScript{class: PubKeyHashTy}
err = SafeCopyScript(&pkScript.script, script)
if err != nil {
return PkScript{}, err
}
return pkScript, nil
}
}
// Continue with secure redeem script parsing below ...
// ... [добавить подробную логику проверки для P2SH]
return PkScript{}, ErrUnsupportedScriptType
}
Conclusion
Bitcoin Script’s cryptographic security requires developers to exercise utmost care when handling public keys, scripts, and memory. All externally received data must undergo strict cryptographic verification and structural validation. Even in languages with automatic memory protection (such as Go), vulnerabilities such as logical errors, insufficient validation, and “stolen” nonces can have catastrophic consequences for user wallets and blockchain consensus. Adherence to the proposed solutions and strict data validity controls completely eliminates the possibility of exploiting these vulnerabilities. pkg.go+4
Final scientific conclusion
The critical vulnerability in question, designated CVE-2024-38365, is one of the most dangerous bugs in the history of cryptocurrency engineering. It is caused by an incorrect implementation of the Script signature verification mechanism (the removeOpcodeByData function) in several Bitcoin clients, leading to incorrect data deletion and disruption of network consensus. This vulnerability allows an attacker, using a simple standard transaction script, to initiate a hard fork of the blockchain, causing node denial of service, theft of funds, and a complete breakdown of consensus without requiring significant computing resources. wiz+2
The attack’s versatility, remoteness, and minimal implementation costs make it both striking and dangerous—any network participant can exploit the flaw if nodes are running vulnerable versions. Here, a fundamental cryptographic flaw becomes a tool for destroying the trust system upon which Bitcoin is built. Addressing this vulnerability and promptly updating software components is a matter not only of wallet security but also of preserving the future of the entire decentralized economy. Bitcoin, as a global digital asset, demands that developers employ the utmost precision in cryptographic procedures, as the slightest error can lead to irreversible disruption of the network and the loss of millions of users’ capital. feedly+2
Only rigorous scientific discipline, timely community response, and continuous testing of security standards can maintain the resilience of the Bitcoin system in the face of new threats.
- https://nvd.nist.gov/vuln/detail/cve-2024-38365
- https://www.wiz.io/vulnerability-database/cve/cve-2024-38365
- https://feedly.com/cve/CVE-2024-38365
- https://asec.ahnlab.com/en/83869/
- https://bitcoinops.org/en/newsletters/2024/10/11/
- https://go.googlesource.com/vulndb/+/ebbdcbcbe8fb217dfb269bddab22d5d3496ce2ec%5E!/
- https://delvingbitcoin.org/t/cve-2024-38365-public-disclosure-btcd-findanddelete-bug/1184
- https://www.cve.org/CVERecord/SearchResults?query=bitcoin
- https://www.sciencedirect.com/science/article/abs/pii/S1084804525001948
- https://www.nccgroup.com/us/research-blog/a-brief-review-of-bitcoin-locking-scripts-and-ordinals/
- https://pkg.go.dev/github.com/ethereum/go-ethereum/crypto/secp256k1
- https://stackoverflow.com/questions/40262971/is-go-vulnerable-for-buffer-overflow
- https://www.blackduck.com/blog/detect-prevent-and-mitigate-buffer-overflow-attacks.html
- https://pkg.go.dev/github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1
- https://www.sciencedirect.com/science/article/pii/S0736585324000959
- https://arxiv.org/pdf/2110.12162.pdf
- https://www.nature.com/articles/s41597-025-04684-8
- https://www.usenix.org/conference/12th-usenix-security-symposium/pointguard%E2%84%A2-protecting-pointers-buffer-overflow
- https://www.reddit.com/r/crypto/comments/pu4yn4/secp256k1_recoverable_public_key_from_signature/
- https://dl.acm.org/doi/10.1145/3607947.3608069
- https://stackoverflow.com/questions/49475216/use-secp256k1-in-go
- https://stackoverflow.com/questions/21322182/how-to-store-ecdsa-private-key-in-go
- https://go.dev/src/crypto/ecdsa/ecdsa.go
- https://stackoverflow.com/questions/77264688/which-method-is-used-for-verifying-secp256k1-signatures-in-gos-btcec-library
- https://pkg.go.dev/crypto/ecdsa
- https://bitcointalk.org/index.php?topic=5470580.0
- https://www.ic3.gov/CSA/2025/250212.pdf
- https://blog.cloudflare.com/the-linux-kernel-key-retention-service-and-why-you-should-use-it-in-your-next-application/
- https://vulert.com/vuln-db/go-github-com-btcsuite-btcd-127768
- https://pkg.go.dev/vuln/GO-2024-3189
- https://github.com/demining/Deserialize-Signature-Vulnerability-in-Bitcoin-Network
- https://forklog.com/en/critical-vulnerability-found-in-bitcoin-wallet-chips/
- https://christian-rossow.de/publications/btcsteal-raid2018.pdf
- https://yourbasic.org/golang/copy-explained/
- https://dev.to/jlauinger/exploitation-exercise-with-unsafe-pointer-in-go-information-leak-part-1-1kga
- https://cispa.de/en/research/publications/68097-identifying-key-leakage-of-bitcoin-users
- https://www.reddit.com/r/Bitcoin/comments/1j24hh3/nonce_r_reuse_and_bitcoin_private_key_security_a/
- https://habr.com/ru/articles/817237/
- https://www.cvedetails.com/cve/CVE-2024-34478/
- https://github.com/advisories/GHSA-3jgf-r68h-xfqm
- https://www.qrypt.com/FAQ/what-are-the-quantum-threats-to-cold-storage-and-p2sh-or-p2pkh-in-crypto-wallets/
- https://www.kaspersky.com/blog/vulnerability-in-hot-cryptowallets-from-2011-2015/49943/
- https://trezor.io/learn/advanced/standards-proposals/pay-to-public-key-hash-p2pkh
- https://opsdesign.com/bitcoin-vulnerabilities-due-to-quantum-computing/
- https://archlending.com/blog/bitcoin-address-types
- https://en.bitcoin.it/wiki/Common_Vulnerabilities_and_Exposures
- https://komodoplatform.com/en/academy/p2sh-pay-to-script-hash/
- https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMBTCSUITEBTCDTXSCRIPT-6808763
- https://www.cve.org/CVERecord/SearchResults?query=bitcoin
- https://www.unchained.com/blog/bitcoin-address-types-compared
- https://pkg.go.dev/github.com/btcsuite/btcd/txscript
- https://www.reddit.com/r/crypto/comments/1ftnsuv/are_current_cryptography_methods_vulnerable_in/
- https://amlcrypto.io/en/blog/types-of-bitcoin-addresses
- https://www.cvedetails.com/cve/CVE-2024-38365/
- https://www.hackerone.com/blog/lessons-crypto-exploits
- https://www.npmjs.com/package/@kimafinance/btc-signer
- https://immunebytes.com/blog/signature-malleability-attacks-in-blockchain/
- https://github.com/bitcoin/bitcoin/issues/20178
- https://arxiv.org/pdf/2203.03054.pdf
- https://dl.acm.org/doi/10.1145/2976749.2978353
- https://www.sciencedirect.com/science/article/abs/pii/S0167739X17330030
- https://en.bitcoin.it/wiki/Script
- https://www.nccgroup.com/us/research-blog/a-brief-review-of-bitcoin-locking-scripts-and-ordinals/
- https://www.semanticscholar.org/paper/Identifying-Key-Leakage-of-Bitcoin-Users-Brengel-Rossow/32c3e3fc47eeff6c8aa93fad01b1b0aadad7e323
- https://bitcointalk.org/index.php?topic=977070.0
- https://arxiv.org/html/2504.13737v1
- https://www.thepolyglotdeveloper.com/2018/03/create-sign-bitcoin-transactions-golang/
- https://en.bitcoin.it/wiki/Weaknesses
- https://vulmon.com/searchpage?q=Bitcoin+Bitcoin&sortby=byactivity&scoretype=vmscore&page=9
- https://dev.to/_56d7718cea8fe00ec1610/why-bitcoin-wallets-validate-public-key-hashes-a-deep-dive-into-data-integrity-578k
- https://www.php.cn/faq/625595.html
- https://vulmon.com/searchpage?q=bitcoin+bitcoin+-&page=7
- https://postquantum.com/post-quantum/quantum-cryptocurrencies-bitcoin/
- https://pkg.go.dev/io
- https://www.fireblocks.com/blog/how-blockchains-will-evolve-for-the-quantum-era/
- https://www.youtube.com/watch?v=c7hLUsUE_Ao
- https://coinshares.com/it/insights/research-data/bitcoin-and-the-quantum-computing-risk/
- https://www.deloitte.com/nl/en/services/consulting-risk/perspectives/quantum-computers-and-the-bitcoin-blockchain.html
- https://www.youtube.com/watch?v=svgK9fNGTfg
- https://arxiv.org/html/2410.16965v1
- https://stackoverflow.com/questions/61325797/golang-copy-function-understanding
- https://www.reddit.com/r/crypto/comments/120uiop/does_publishing_a_public_key_lower_the_security/
- https://stackoverflow.com/questions/18559830/function-for-copying-arrays-in-go-language/18560025
- https://devblogs.microsoft.com/oldnewthing/20050107-00/?p=36773
- https://nvd.nist.gov/vuln/detail/cve-2024-38365
- https://www.sciencedirect.com/science/article/pii/S2666281724001203
- https://www.sciencedirect.com/science/article/pii/S2096720923000106
- https://bitcoincore.academy/consensus-bugs.html
- https://www.blackduck.com/blog/detect-prevent-and-mitigate-buffer-overflow-attacks.html
- https://www.reddit.com/r/Bitcoin/comments/1j24hh3/nonce_r_reuse_and_bitcoin_private_key_security_a/
- https://arxiv.org/html/2504.13737v1
- https://en.bitcoin.it/wiki/Common_Vulnerabilities_and_Exposures
- https://www.cve.org/CVERecord/SearchResults?query=bitcoin
- https://bitcoinops.org/en/topics/cve/
- https://forklog.com/en/critical-vulnerability-found-in-bitcoin-wallet-chips/
- https://royalsocietypublishing.org/doi/10.1098/rsos.180410
- https://nvd.nist.gov/vuln/search/results?form_type=Advanced&results_type=overview&isCpeNameSearch=true&seach_type=all&query=cpe%3A2.3%3Aa%3Abitcoin%3Abitcoin_core%3A24.0%3A-%3A%2A%3A%2A%3A%2A%3A%2A%3A%2A%3A%2A
- https://onlinelibrary.wiley.com/doi/10.1155/2021/6643763
- https://www.first.org/cvss/v4-0/examples
- https://bitcoincore.org/en/security-advisories/
- https://cwe.mitre.org/data/definitions/284.html
- https://www.cve.org/CVERecord/SearchResults?query=blockchain
- https://pmc.ncbi.nlm.nih.gov/articles/PMC12394450/
- https://www.cvedetails.com/vulnerability-list/vendor_id-2044/product_id-100715/version_id-1209695/Matrix-Javascript-Sdk-12.1.0.html
- https://github.com/advisories/GHSA-xwcq-pm8m-c4vf
- https://arxiv.org/pdf/2503.22156.pdf
- https://www.nature.com/articles/s41597-025-04684-8


