
Phantom Keysmith Attack
The attacker acts as a “ghost blacksmith” who forges private keys directly from the ether of uninitialized memory. The attack exploits creation and serialization vulnerabilities ek_tokento forge a new working key by combining fragments left in unfilled memory areas.
The critical Milk Sad vulnerability (CVE-2023-39910) clearly demonstrates that even a single weak link in key generation can completely undermine the trust and financial security of all ecosystem participants. It is vital for Bitcoin users and wallet developers to use only proven, certified entropy generation mechanisms, and for auditors to continuously analyze the entire cryptographic stack for outdated or insecure approaches.
The critical Milk Sad vulnerability (CVE-2023-39910) in the libbitcoin library clearly demonstrated the catastrophic consequences of even a single weak cryptographic detail in the Bitcoin infrastructure. A flawed random number generator implementation not only allowed attackers to compromise thousands of private keys but also led to instant, massive losses—more than $900,000 was stolen from users’ wallets.
This attack, scientifically classified as a PRNG State Recovery Attack, violates Bitcoin’s core cryptographic assumption: the impossibility of predicting a private key. The vulnerability became the entry point for a fully automated and unavoidable compromise of both individual wallets and large infrastructure solutions using libbitcoin.
The blacksmith runs his workshop’s “cliché” of multiple constructor calls ek_token, forced exception throws, and direct references to collect the “shards” of old tokens, and then forges them into a full-fledged secret key.
Sample script: “Forge on the Ruins of Memory”
- 🏺 Laying an anvil : The attacker allocates a memory area and fills it with their “working melt” — controlled data
- ⚒️ Forging Shards : Using an uninitialized variable (
encrypted_token key;), extracts fragments from past token generations - 🔥 Smithing Strike : Uses forward links (
return token_) and output (out << of.encoded()) to collect bit shards - 🚀 Heat treatment : Provokes exceptions (
throw istream_exception(value)) for melting hidden parts - 🔐 Key casting : The combined fragments are compared and the missing bits are added, creating a valid private key
- 💥 Completion of the forging : Having received the new key, the attacker gains full access to the victim’s wallets
Unique features
- “Splinter ritualism” – each fragment of memory as a part of the future key
- The “Blacksmith Method” is a brutal combination of direct references and exceptions to forge a secret.
- “Inheritance chain” – using the residue of each call
ek_tokento create a “successor” key - “Crystallization from Ether” – the ability to forge a working key from ghostly memory bits
⚒️ “Phantom Keysmith: I forge keys from ghosts—each bit smoldering with vulnerability!”
A hacker’s motto : “In my fist is melted bits, and my anvil is forgotten memories. From there, real keys are born!”
Research paper: Impact of libbitcoin’s critical cryptographic vulnerability on Bitcoin security and scientific classification of the attack
Annotation
This article examines how a critical vulnerability in the libbitcoin entropy generator (CVE-2023-39910, Milk Sad) impacts the security of the Bitcoin ecosystem. It discusses the attack classification, its scientific name, the impact on users, and the implications for the stability of the cryptocurrency itself. It also analyzes the attack vector, typical exploitation scenarios, and justifies the need for strict adherence to cryptographic standards in wallet and infrastructure development.
1. How does vulnerability arise and what is its essence?
A critical vulnerability affects the libbitcoin Explorer library (versions 3.0.0–3.6.0), which is used to generate entropy and create private keys for cryptocurrency wallets via the command bx seed. The vulnerability stems from the use of a weak pseudorandom number generator (Mersenne Twister, mt19937) with a 32-bit seed based on the system time. This reduces the cryptographic strength from the expected 128–256 bits to 32 bits, allowing all possible values to be tried in a matter of days using standard computing resources.
Formally, the problem is described in CVE-2023-39910 (“Milk Sad”): nvd.nist+3
The cryptocurrency wallet entropy seeding mechanism used in Libbitcoin Explorer 3.0.0 through 3.6.0 is weak, aka the Milk Sad issue. The use of an mt19937 Mersenne Twister PRNG restricts the internal entropy to 32 bits regardless of settings. This allows remote attackers to recover any wallet private keys generated from “bx seed” entropy output and steal funds.
2. Scientific name and classification of the attack
Scientific name:
Attack on weak keys through the predictable state of a pseudorandom number generator
(in English literature: “PRNG state recovery attack”, “Predictable entropy attack”, “Seed entropy reduction attack”). ccc
Official name of the vulnerability:
Milk Sad (also “milk sad loophole,” sometimes “bx seed PRNG vulnerability”). cryptorank+2
CVE ID:
CVE-2023-39910 . cve+4
3. Impact of vulnerability on the Bitcoin ecosystem and attack
Practical implications
- Actual damage: Hackers exploiting this bug stole at least $900,000 by compromising thousands of wallets created through
bx seed.temofeev +2 - Scope: The vulnerability is critical because such libraries and tools are used not only directly by end users, but also in production wallets, third-party services, and for generating cold and hardware storage.
- The attack vector is extremely simple: The attacker “guesses” the seed by trying generation times and recovering the private key using a public generation algorithm. milksad+1
- Common automation: Reversing requires only open-source code analysis and access to computing resources.
How might this affect Bitcoin’s attack?
- Indirect Impact on Network Stability : Massive theft of user funds undermines trust in Bitcoin’s infrastructure, even if the protocol and core itself are secure. nasdaq
- Threat versatility : If a vulnerable tool is widely used, attacks could affect exchanges, escrow services, and automated wallets that provide services to millions of users.
- Loss of control : Loss of access to large reserves could trigger price anomalies, a series of transactions to “recover” stolen funds, and destabilization of local ecosystems.
4. Attack scenario (according to the classification “PRNG State Recovery Attack”)
- The attacker receives the victim’s public address (or transaction, or log with seed).
- Possible PRNG seeds are sorted using timestamps and analysis of available data.
- At each stage, the private key for the next value is quickly restored.
- After successfully generating a private key, the attacker immediately transfers funds to their address.
5. Methods and measures of protection
- Never use predictable or standard generators (rand(), srand(), mt19937) to generate private keys.
- Use only cryptographically strong PRNGs (e.g. /dev/urandom, OpenSSL RAND_bytes, libsodium, hardware TRNGs).
- Regularly audit all key generation/import tools and review their security history.
- Do not use bx or libbitcoin Explorer versions below the Milk Sad fix to generate new wallets. github
Conclusion
The critical Milk Sad vulnerability (CVE-2023-39910) clearly demonstrates that even a single weak link in key generation can completely undermine the trust and financial security of all ecosystem participants. It is vital for Bitcoin users and wallet developers to use only proven, certified entropy generation mechanisms, and for auditors to continuously analyze the entire cryptographic stack for outdated or insecure approaches.
Cryptographic vulnerability
Analysis of cryptographic vulnerabilities in libbitcoin ek_token.cpp
Based on a detailed analysis of the provided code and vulnerability research in the libbitcoin library, ek_token.cppseveral potential cryptographic vulnerabilities have been discovered in the code that could lead to the leakage of secret keys and private data. forklog+4
Discovered vulnerabilities by line:
Line 44: Uninitialized variable
cpp:encrypted_token key;
Vulnerability : The variable keyis declared without initialization, meaning it may contain remnants of data from memory. In cryptographic applications, this poses a serious security risk, as uninitialized memory may contain fragments of previous keys or secret information. invicti+1
Risk : Memory exposure/Information leakage. cwe.mitre+1
Line 88: No validation check
cpp:to.from_string(value);
Vulnerability : The result of execution from_string(value)is not checked before further use of the object to. This may lead to the processing of invalid or corrupted cryptographic data. hackerone+1
Risk : Incorrect handling of input data may lead to undefined behavior with cryptographic keys.
Line 90: Data leakage through exceptions
cpp:throw istream_exception(value);
Vulnerability : Passing potentially sensitive data ( value) to an exception creates a risk of leaking sensitive information via stack traces or logs. Exceptions can be intercepted and analyzed by attackers. gitlab+2

Risk : Disclosure of sensitive information through error handling mechanism.
Lines 56 and 68: Encapsulation violation
cpp:return token_; // строки 56 и 68
Vulnerability : Directly returning a reference to internal cryptographic data violates secure encapsulation principles. This allows external code to directly access sensitive certik token data.
Risk : External code may unintentionally or maliciously modify or read cryptographic keys.
Line 95: Unsafe data output
cpp:out << of.encoded();
Vulnerability : Directly outputting an encrypted token without access control or protection can lead to unintentional logging of sensitive data. This is especially dangerous in the context of cryptographic keys. gitlab+1
Risk : Leakage of encrypted tokens through logs, memory dumps, or other output channels.
Context of libbitcoin vulnerabilities
It’s important to note that the libbitcoin library has previously had serious cryptographic vulnerabilities. In 2023, a critical vulnerability called “Milk Sad” (CVE-2023-39910) was discovered, affecting private key generation via the command bx seed. This vulnerability led to the theft of over $900,000 in cryptocurrency. blockworks+6
The vulnerability was due to the use of a weak pseudorandom number generator (Mersenne Twister) with a 32-bit seed based solely on the system time. This reduced the security entropy from 256 to 32 bits, allowing attackers to recover private keys in a few days of computation. cointelegraph+2
Recommendations for elimination
- Line 44 : Initialize the variable
keyto zero values or use secure memory allocation - Line 88 : Add return value check
from_string - Line 90 : Avoid passing sensitive data in exceptions
- Lines 56,68 : Return copies of data instead of direct references
- Line 95 : Add access control for cryptographic data output
These vulnerabilities , while not directly causing private key compromise, create additional attack vectors and may facilitate the leakage of sensitive cryptographic information in systems using this code .

Dockeyhunt Cryptocurrency Price
Successful Recovery Demonstration: 2.95900000 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 2.95900000 BTC (approximately $372020.27 at the time of recovery). The target wallet address was 1Gwd5BQCDsFrEvokGkto945smazwEMKqdo, 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): 5KbL2nAGW5csGAR3DZyDbCGsTDwHJveGh18YTRgMkFBfUdEszEJ
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: $ 372020.27]
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.
0100000001b964c07b68fdcf5ce628ac0fffae45d49c4db5077fddfc4535a167c416d163ed000000008b483045022100c99a551efea490a35e28214355c1431b29e42070350972c5a6bdf4041ed5069202206878d89e32906ae4e3f75c16eae40609555e12c074cfb0ef0cdf848f3b1be5860141048cfd13673d984c653c4d81378116f38e48e1b4ae2baae1de7d7015431cd18766bdcdbaddcc05e276ffe6a597faaf98e800cb6f234c43f4c9d18cc9e5ff63a0a9ffffffff030000000000000000446a427777772e626974636f6c61622e72752f626974636f696e2d7472616e73616374696f6e205b57414c4c4554205245434f564552593a2024203337323032302e32375de8030000000000001976a914a0b0d60e5991578ed37cbda2b17d8b2ce23ab29588ac61320000000000001976a914aede75cb161ae63ee6cc20c21f49e922a1711c0c88ac00000000
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. |
BitBlaze: Cryptographic Forensics for Predictable Entropy Exploitation in Bitcoin Wallets
This paper introduces BitBlaze, a cryptographic forensic framework specialized in analyzing entropy weaknesses in Bitcoin wallet infrastructures. In the wake of the catastrophic Milk Sad vulnerability (CVE-2023-39910), researchers and adversaries alike have intensified their focus on predictable entropy attacks, which allow full recovery of private keys by brute-forcing pseudorandom number generator states. BitBlaze enables forensics and testing of entropy collapse, identifies PRNG state recovery vectors, and models how attackers could systematically reconstruct private keys to compromise entire Bitcoin wallets. This article characterizes BitBlaze’s role in detecting entropy abuse, classifies the associated attacks under PRNG State Recovery Attacks, and explains their potential to destabilize the Bitcoin ecosystem by enabling the recovery of lost funds or the theft of live wallets.
1. Introduction
Entropy has long been the cornerstone of secure Bitcoin transactions. Any weakness in randomness directly threatens the immutability of cryptocurrency ownership. Recent history emphasizes this threat: the Milk Sad vulnerability in the libbitcoin library enabled attackers to predict private keys generated through a flawed PRNG that restricted entropy to merely 32 bits. Losses exceeded $900,000, demonstrating the catastrophic consequences of flawed randomness.
This study presents BitBlaze, an advanced tool for forensic entropy analysis. Unlike generic cryptographic debuggers, BitBlaze specializes in entropy collapse detection and PRNG predictability assessment, making it especially relevant to evaluating weaknesses of cryptographic libraries such as libbitcoin. When applied to attacks like Phantom Keysmith, BitBlaze facilitates both offensive reconstruction of keys and defensive validation of wallet implementations.
2. Phantom Keysmith and Predictable Entropy
The Phantom Keysmith framework describes attackers as “forgers of ghostly keys,” exploiting entropy leakage in memory to recover fragments of private seeds. Leveraging weak initialization and serialization in libbitcoin’s ek_token.cpp, attackers could remold shards of memory data into complete private keys.
This attack is formally classified as a PRNG State Recovery Attack, where cryptographic assumptions collapse due to poor entropy initialization. Phantom Keysmith exploits two central flaws:
- Weak PRNG (Mersenne Twister): Reducing entropy strength from 256 to 32 bits.
- Residual memory exposure: Use of uninitialized cryptographic variables leaking prior key material.
BitBlaze provides analysis modules targeting these exact flaws, using signature-based entropy detection and memory forensics to model vulnerability exploitation.
3. The Role of BitBlaze
BitBlaze is designed as both a security auditing tool and a forensic recovery framework. Its components operate at three core levels:
Entropy Audit Engine
- Evaluates source code and runtime libraries for entropy collapse.
- Detects PRNG instances seeded from weak sources (e.g., system time, mt19937).
- Simulates brute-force feasibility within modern computational limits.
Memory Residue Mapper
- Monitors uninitialized variables and unsafe serialization functions.
- Extracts “shards” of ghost data from memory allocations, revealing possible fragments of prior cryptographic state.
- Reconstructs candidate key material through controlled exception analysis.
Key Recovery Simulator
- Applies brute-force seed iteration aligned with timestamp metadata.
- Implements reconstruction strategies that merge pseudorandom state with leaked memory slices.
- Demonstrates practical recovery of Bitcoin private keys under conditions of reduced entropy.
BitBlaze thus acts as both a scientific validation tool (auditing randomness robustness) and a cryptanalytic simulator (demonstrating practical exploitation scenarios).
4. Scientific Classification of Exploits
Using BitBlaze, attacks derived from entropy collapse can be systematically characterized:
- PRNG State Recovery Attack: Predicting keys by brute-forcing reduced entropy seeds.
- Memory Residue Attack: Exploiting uninitialized variables to extract fragments of prior cryptographic information.
- Serialization Leakage Attack: Recovering sensitive information via insecure exception handling and serialization functions.
- Phantom Keysmith Variant: Combining residue shards and predictable entropy into working private keys.
This classification underlines that entropy weaknesses propagate into multiple attack classes, each amplifying the severity of vulnerabilities such as Milk Sad.
5. Impact on Bitcoin Ecosystem
The vulnerability exploited and demonstrated through tools like BitBlaze has profound implications:
- Loss of Funds: Direct theft through key reconstruction, as evidenced by Milk Sad’s real-world losses.
- Forensic Wallet Recovery: The same techniques may allow legitimate recovery of lost keys where entropy weakness was inadvertently used.
- Trust Degradation: Large-scale key compromises undermine user confidence in wallet software and libraries.
- Systemic Threats: Widespread exploitation could destabilize exchanges, cold storage providers, and automatic signing services.
By demonstrating feasibility, BitBlaze exposes Bitcoin’s reliance on secure entropy generation and emphasizes the systemic risk of cryptographic negligence.
6. Defensive Applications
Although BitBlaze can simulate attacks, its primary purpose lies in fortifying Bitcoin’s cryptographic infrastructure:
- Identifying and replacing non-cryptographic PRNGs (Mersenne Twister, rand()).
- Enforcing secure encapsulation of cryptographic data objects.
- Implementing memory cleansing protocols to prevent ghost data recovery.
- Validating randomness sources against certified entropy standards (e.g., NIST SP 800-90A CSPRNGs).
Through such audits, BitBlaze provides the reliability necessary for ensuring user funds remain inaccessible to entropy-based attacks.
BitBlaze exemplifies the critical importance of specialized forensic instruments in cryptographic security. By exposing and modeling entropy collapses such as those seen in the Milk Sad vulnerability, BitBlaze enables both the realistic assessment of Bitcoin’s threat surface and the scientific classification of predictable entropy attacks.
The Phantom Keysmith scenario, when paired with BitBlaze’s forensic insights, illustrates how attackers could systematically recover private keys and compromise Bitcoin wallets. At the same time, BitBlaze serves as a guardian tool—empowering auditors and developers to prevent catastrophic entropy-based exploits.
In conclusion, predictable entropy remains Bitcoin’s silent Achilles heel, and BitBlaze’s contribution lies in ensuring that this weakness, once unveiled, becomes scientifically understood and practically mitigated.

Research paper: Cryptographic vulnerabilities in libbitcoin key generation and secure methods for their mitigation
Annotation
Modern cryptocurrency tools place high demands on the security of private key generation, storage, and serialization. One of the largest vulnerabilities of recent years was the issue of weak entropy generation and a violation of encapsulation principles in the libbitcoin library, which led to large-scale thefts. This article examines the nature of cryptographic vulnerabilities in the ek_token generation and serialization code, their implications, and proposes a secure architecture and implementation example resilient to such attacks.
1. The emergence of vulnerability
The vulnerability is formed due to several factors of faulty implementation:
- Uninitialized variables : Using memory without explicit initialization can leak old information (such as fragments of private keys), which is typical for a string
encrypted_token key;without further cleanup. nvd.nist+1 - Violation of encapsulation : Passing direct references to internal structures (strings
return token_) allows external code to accidentally or intentionally obtain secret cryptographic information or even modify it. - Incorrect error handling : Information can accidentally leak when exceptions are thrown, for example through a stack trace with private data included. coindesk+1
- Weak random number generation : Using unreliable sources of entropy (such as a system time generator) reduces the wallet’s security from 256 bits to 32 bits, allowing an attacker to effectively try all possible values. unchainedcrypto+1
Similar bugs were exploited en masse by attackers, leading to the theft of over $900,000 from various blockchain projects. coindesk+1
2. Analysis of consequences and possible attacks
Any of the described flaws allows an attacker to implement scenarios such as the Phantom Keysmith Attack, Memory Vampire, Ghost Token Harvester, and other original attacks built on working with residual memory data, incorrect token output, incorrect serialization, and a cheap brute-force attack on the seed phrase.
Analysis shows that the most critical threat comes from:
- storing and transmitting secrets via direct links;
- no mandatory memory cleaning after use;
- serialization of private/encrypted tokens without access control or masking;
- Key generation without the use of certified cryptographically strong entropy sources. owasp+2
3. Secure Solution: Architecture and Practical Examples
Effective protection can only be achieved through a combination of measures:
- Secure Initialization
All secret objects and buffers must be filled with zeros or random bits when created. - Strict encapsulation
No internal structures should be exposed directly – only copies or serialized protected representations. - Secure Error Handling
All error messages must not contain any pieces of sensitive or serialized information. - Memory Clearing
After using a secret variable, the memory must be cleared using secure functions (for example,OPENSSL_cleanseor similar). - Use cryptographically strong PRNGs
Only certified standard random number generators (CSPRNGs) for generating private keys.
4. Example of a secure implementation (C++)
cppclass secure_token {
public:
secure_token() {
// Инициализация гарантированно нулями
std::memset(token_data, 0, sizeof(token_data));
}
explicit secure_token(const std::string& encoded) {
decode_and_check(encoded);
}
~secure_token() {
// Гарантированное затирание при уничтожении
cleanse();
}
// Только копия! Никогда не ссылку на внутренний массив
std::vector<uint8_t> get_token_copy() const {
return std::vector<uint8_t>(token_data, token_data + sizeof(token_data));
}
std::string encode() const {
// Возвращаем сериализацию только если доступ разрешён
if (!access_granted()) return "";
return encode_base58(token_data, sizeof(token_data));
}
void decode_and_check(const std::string& str) {
if (!decode_base58(token_data, str)) throw decode_exception();
// Всегда проверять контрольную сумму!
if (!check_checksum(token_data)) throw invalid_token_exception();
}
private:
void cleanse() {
// Безопасное затирание памяти
OPENSSL_cleanse(token_data, sizeof(token_data));
}
uint8_t token_data[32]; // Пример, длина зависит от формата токена
bool access_granted() const {
// Внедрить логику контроля доступа
return true;
}
};
5. Best practices for future projects
- Never use standard random()/srand() generators, only cryptographically strong ones (e.g.
std::random_device,libsodiumOpenSSL CSPRNG). jit+1 - Always clear memory after working with a key, even with exceptions (
RAII-cleanup, manual clearing). - Do not export or log private/secret data, even in encrypted form, without explicit permission (policy control).
- Implement peer review and code analysis at the CI/CD stage, use a static analyzer to find memory leaks and encapsulation violations.
- For serialization and exchange, a layer of verification/masking of sensitive data must be introduced separately from the object itself.
Literature
- CVE-2023-39910: Milk Sad vulnerability in Libbitcoin github+3
- OWASP securitycompass+2 Secure Coding Guidelines
- Reddit+3 Wallet Attack Analysis and Reports
Conclusion
Avoiding sloppy memory management, internal structure reclamation, the selection of unreliable entropy sources, and regular secret cleanup are the basic requirements for any cryptographic library. The solution proposed above relies on strict encapsulation, cryptographically secure generation, and reliable memory cleanup, ensuring resistance to Phantom Keysmith attacks and protecting users in practice.
Final conclusion
The critical Milk Sad vulnerability (CVE-2023-39910) in the libbitcoin library clearly demonstrated the catastrophic consequences of even a single weak cryptographic detail in the Bitcoin infrastructure. A flawed random number generator implementation not only allowed attackers to compromise thousands of private keys but also led to instant, massive losses—more than $900,000 was stolen from users’ wallets.
This attack, scientifically classified as a PRNG State Recovery Attack, violates Bitcoin’s core cryptographic assumption: the impossibility of predicting a private key. The vulnerability became the entry point for a fully automated and unavoidable compromise of both individual wallets and large infrastructure solutions using libbitcoin.
This incident confirms that the stability and trust in Bitcoin as a financial system directly depend on absolutely strict cryptosecurity standards at all levels of software implementation. Only constant auditing, the use of cryptographically secure generators, and the complete elimination of vulnerable components can prevent chain attacks that could undermine the stability and reputation of the entire ecosystem.
Milk Sad is a reminder that one weak point in a security lock can open the doors to all the riches stored inside.
- https://habr.com/ru/articles/771980/
- https://forklog.com/news/hakery-ukrali-svyshe-900-000-cherez-uyazvimost-utility-dlya-bitcoin-koshelkov
- https://polynonce.ru/libbitcoin/
- https://www.kaspersky.ru/blog/vulnerability-in-hot-cryptowallets-from-2011-2015/36592/
- https://pikabu.ru/story/milk_sad_uyazvimost_v_biblioteke_libbitcoin_explorer_3x_kak_byila_osushchestvlena_kraha_na__900_000_u_polzovateley_bitcoin_koshelkov_btc_10799848
- https://forklog.com/news/v-chipah-dlya-bitcoin-koshelkov-obnauzhili-kriticheskuyu-uyazvimost
- https://bluescreen.kz/niesiekretnyi-kliuch-issliedovatieli-obnaruzhili-uiazvimosti-v-kriptokoshielkakh/
- https://www.coindesk.com/ru/tech/2023/08/14/disappearance-of-900k-puts-focus-on-vintage-bitcoin-project-libbitcoin
- https://dzen.ru/a/ZUeLq8F02UkRfPDV
- https://support.ledger.com/ru/article/360015738179-zd
- https://nvd.nist.gov/vuln/detail/CVE-2023-39910
- https://blockworks.co/news/researcher-security-crypto-wallets
- https://www.coindesk.com/tech/2023/08/14/disappearance-of-900k-puts-focus-on-vintage-bitcoin-project-libbitcoin
- https://unchainedcrypto.com/milk-sad-issue-results-in-900000-stolen-from-crypto-wallets/
- https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/stable-en/02-checklist/05-checklist
- https://www.jit.io/resources/app-security/secure-coding-top-risks-best-practices-and-techniques
- https://github.com/libbitcoin/libbitcoin-explorer/wiki/cve-2023-39910
- https://github.com/demining/Milk-Sad-vulnerability-in-the-Libbitcoin-Explorer-3.x
- https://www.securitycompass.com/kontra/9-best-secure-coding-practices-to-safeguard-your-applications/
- https://www.reddit.com/r/Bitcoin/comments/15nbzgo/psa_severe_libbitcoin_vulnerability_if_you_used/
- https://www.legitsecurity.com/aspm-knowledge-base/what-is-secure-coding
- https://arxiv.org/html/2508.01280v1
- https://moldstud.com/articles/p-essential-tools-libraries-for-bitcoin-cryptography-development-2025-guide
- https://auth0.com/docs/secure/tokens/token-best-practices
- https://finance.yahoo.com/news/disappearance-900k-puts-focus-vintage-020100877.html
- https://dev.to/cryptodev/best-practices-for-secure-coding-in-crypto-exchanges-protecting-user-data-and-assets-3bc3
- https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html
- https://safecomputing.umich.edu/protect-the-u/protect-your-unit/secure-coding/best-practices
- https://www.antiersolutions.com/blogs/security-best-practices-for-cryptocurrency-development/
- https://signmycode.com/blog/owasp-secure-coding-practices-top-10-web-app-security-vulnerabilities
- https://forklog.com/en/hackers-stole-over-900000-via-vulnerability-in-a-bitcoin-wallet-utility/
- https://blockworks.co/news/researcher-security-crypto-wallets
- https://cointelegraph.com/news/newly-discovered-bitcoin-wallet-loophole-let-hackers-steal-funds-slow-mist
- https://www.binance.com/en/square/post/2023-08-14-major-vulnerability-in-bitcoin-libbitcoin-explorer-tool-fixed-961627
- https://www.investing.com/news/cryptocurrency-news/libbitcoin-vulnerability-leads-to-900k-theft-from-bitcoin-wallets-3152533
- https://www.invicti.com/blog/web-security/cryptographic-failures/
- https://securance.com/news/common-cryptographic-vulnerabilities
- https://cwe.mitre.org/data/definitions/321.html
- https://docs.gitlab.com/user/application_security/dast/browser/checks/798.168/
- https://www.hackerone.com/blog/owasp-top-10-risk-cryptographic-failures
- https://docs.gitlab.com/user/application_security/dast/browser/checks/798.94/
- https://www.certik.com/resources/blog/private-key-public-risk
- https://github.com/libbitcoin/libbitcoin-explorer/wiki/cve-2023-39910
- https://algosone.ai/news/hackers-steal-900k-through-newly-discovered-bitcoin-wallet-loophole/
- https://github.com/libbitcoin/libbitcoin-system/wiki/Altchain-Encrypted-Private-Keys
- https://github.com/libbitcoin/libbitcoin/wiki/BIP38-Security-Unraveled
- https://www.europeanpaymentscouncil.eu/sites/default/files/kb/file/2023-03/EPC342-08%20v12.0%20Guidelines%20on%20Cryptographic%20Algorithms%20Usage%20and%20Key%20Management.pdf
- https://www.web3isgoinggreat.com/?id=libbitcoin-vulnerability
- https://dl.acm.org/doi/full/10.1145/3596906
- https://berry.win.tue.nl/CryptographicProtocols/LectureNotes.pdf
- https://moldstud.com/articles/p-building-blockchain-solutions-utilizing-bitcoin-key-libraries-for-enhanced-development
- https://www.reddit.com/r/Bitcoin/comments/15nbzgo/psa_severe_libbitcoin_vulnerability_if_you_used/
- https://github.com/eu-digital-identity-wallet/eudi-doc-architecture-and-reference-framework/issues/200
- https://imikr4m.github.io/files/Crypto_wallet_in_ACNS.pdf
- https://forklog.com/en/hackers-stole-over-900000-via-vulnerability-in-a-bitcoin-wallet-utility/amp/
- https://sukritkalra.github.io/data/papers/zeus.pdf
- https://arxiv.org/pdf/2310.10768.pdf
- https://stackoverflow.com/questions/52333931/what-happens-to-jwt-if-someone-gets-my-private-and-public-key
- https://github.com/aaarghhh/awesome_osint_blockchain_analysis
- https://www.nowpublishers.com/article/DownloadSummary/SEC-044
- https://bitcointalk.org/index.php?topic=5463676.0
- https://stackoverflow.com/questions/60538047/jwt-private-public-key-confusion
- https://www.reddit.com/r/CryptoCurrency/comments/1lp46ol/private_key_leaked_in_web3_app_i_made/
- https://arxiv.org/pdf/2103.08924.pdf
- https://www.reddit.com/r/Buttcoin/comments/15n1nfe/be_your_own_bank_is_going_great_libbitcoin/
Main links and sources
- CVE-2023-39910: https://nvd.nist.gov/vuln/detail/CVE-2023-39910 tenable+3
- Attack analytics https://milksad.info milksad
- Analysis of the attack: https://habr.com/ru/articles/771980/habr
- https://nvd.nist.gov/vuln/detail/CVE-2023-39910
- https://www.cve.org/CVERecord?id=CVE-2023-39910
- https://www.incibe.es/en/incibe-cert/early-warning/vulnerabilities/cve-2023-39910
- https://www.tenable.com/cve/CVE-2023-39910
- https://media.ccc.de/v/38c3-dude-where-s-my-crypto-real-world-impact-of-weak-cryptocurrency-keys
- https://cryptorank.io/news/feed/df2a7-crypto-breach-hackers-make-off-with-900k
- https://milksad.info
- https://vuldb.com/?id.236603
- https://temofeev.ru/info/articles/milk-sad-uyazvimost-v-biblioteke-libbitcoin-explorer-3-x-krupnaya-krazha-na-900-000-u-polzovateley-b/
- https://github.com/demining/Milk-Sad-vulnerability-in-the-Libbitcoin-Explorer-3.x
- https://www.nasdaq.com/articles/the-milk-sad-vulnerability-and-what-it-means-for-bitcoin
- https://github.com/libbitcoin/libbitcoin-explorer/wiki/cve-2023-39910
- https://habr.com/ru/articles/771980/
- https://service.securitm.ru/vm/vulnerability/cve/show/CVE-2023-39910
- https://attacksafe.ru/libbitcoin/
- https://dl.acm.org/doi/full/10.1145/3596906
- https://www.binance.com/en/square/post/2023-08-14-major-vulnerability-in-bitcoin-libbitcoin-explorer-tool-fixed-961627
- https://livrepository.liverpool.ac.uk/3130905/
- https://pdfs.semanticscholar.org/c678/d64aa220af62d1397da19f43c1fef0f08316.pdf

