
Shaman’s Gate Attack
The “Shaman’s Gate Attack” class of attacks is a fundamental consequence of non-hardened derivation in HD wallets, as confirmed by numerous hacks. Adhering to the practice of separating paths into hardened and non-hardened branches, as well as avoiding transmitting xpub from higher levels, completely eliminates the possibility of exploiting this class of vulnerabilities in the future.
The critical HD-derivation vulnerability (also known as “Key Derivation Attack via Non-Hardened Derivation” or “Shaman’s Gate Attack”) is one of the most significant security challenges facing Bitcoin, confirmed by existing CVEs (CVE-2023-39910, CVE-2025-27840). Analysis and implementation of hardened derivation, fixed cryptographic primitives, and proper public information management are essential for the future security of the global blockchain infrastructure.
A critical vulnerability in the non-hardened key derivation scheme (Key Derivation Attack, or “Shaman’s Gate Attack”) in Bitcoin HD wallets demonstrates how easily even the most modern cryptographic systems can be compromised by careless design. This flaw allows an attacker who obtains just one private key of an unprotected fork along with the xpub to deduce the root master key—and thereby gain complete control of all private keys in the wallet and instantly steal all the victim’s funds.
Attack “Shaman’s Gate: Invisible Liberation”
In the parallel layers of blockchain reality, a virtual shaman appears—a cyber-occultist who wields the mysteries of mathematical magic. He doesn’t hack the network with brute force, doesn’t hack passwords, and doesn’t wreak havoc with phishing emails. Instead, he approaches the wallet cautiously, like a shadow mage, armed with knowledge of a single weakness: a hidden door at the very heart of the HD structure.
He receives from the victim:
- Master public key ( xpub ) – a supposedly harmless “door handle”
- A single child private key is a tiny fragment of an empty corridor
The shaman begins the ritual of key penetration: he connects these two artifacts with a chain of HMAC magic and the forbidden knowledge of indexes. A masterful mathematical calculation transforms into a restoration formula, and before his inner gaze, a true treasure trove opens—the MASTER PRIVATE KEY.
His formula is simply unnatural: K_master=f(xpub,kchild)K_master=f ( x p u b , k c hil d )
Now, in possession of the master key, he gains control of all the wallet’s genealogical branches—from the root phrase to the smallest satellite addresses—and instantly executes a mass evacuation of funds. The network sees the carefully crafted transactions, but the user is left with only the feeling of alien interference and magical devastation.
This is how one invisible weakness—the shaman’s door—turns the security of an entire generation of Bitcoin wallets into an illusion of inviolability. fc15.ifca+2
Shaman’s Gate: A Critical HD Derivation Vulnerability and the Threat of a Complete Takeover of Bitcoin Wallets
Research paper: Critical BIP32 key derivation vulnerability and its impact on Bitcoin network security
Modern HD wallets (BIP32) have become the foundation for storing and managing keys for cryptocurrencies, including Bitcoin. However, the architectural feature of non-hardened key derivation has created a fundamental cryptographic vulnerability, opening the way to complete compromise of funds without hacking the entire wallet. This vulnerability has already led to massive attacks worth millions of dollars and is recognized by the scientific community as one of the most important challenges to blockchain security. clouddefense+6
The mechanism of vulnerability occurrence
The vulnerability is based on the mathematical relationship between the master public key (xpub) and the private keys of the descendants of the non-hardened tree. If an attacker obtains both of these entities (xpub and the private key of at least one non-hardened descendant), they can deduce the master private key—and, consequently, all private keys in a particular tree branch. keyhunters+2
In real attack (“Shaman’s Gate Attack”) : keyhunters
- A hacker obtains a public extended key (xpub) – often published for view-only operations.
- Gains access to one private key from a non-hardened address (e.g. via malware, vulnerability, user export).
- Using the vulnerability, BIP32 calculates the master private key and then generates all other private keys in the wallet.
The result is a complete loss of all funds on the compromised part of the BIP32 tree.
Scientific classification and CVE number
Scientific name of the attack :
- In scientific literature, it is called “Key Derivation Attack” or “Master Key Recovery Attack via Non-Hardened HD Derivation.” attacksafe+1
CVE (Common Vulnerabilities and Exposures) number:
- The closest critical vulnerability is CVE-2023-39910 (“Milk Sad”) for Libbitcoin Explorer, which is related to the generation of weak private keys from poor-quality entropy, which also leads to the possibility of wallet compromise due to insufficient HD derivation security .
- For a specific derivation attack, CVE-2025-27840 describes a vulnerability in which keys in Electrum (and others) can be exploited to restore the master key through poor-quality KDF and hashing procedures. forklog+1
Impact on Bitcoin security and the network
- Total Compromise of Funds : Losing control of a single child key opens the door to the loss of all funds. blockdaemon+1
- Attack Scale : An attacker could conduct mass withdrawals from thousands of linked addresses while remaining undetected until the transactions are completed. github+1
- Undermining Trust in Bitcoin : Attacks using this vulnerability undermine the security foundation of HD wallets, causing a loss of trust in the entire ecosystem. blockdaemon+1
- Real-world incidents and losses : CVE-2023-39910 (“Milk Sad”) alone allowed hackers to steal hundreds of thousands of dollars from real wallets using weak keyspaces and algorithms. cryptorank+2
- Domino Effect : The danger of mass propagation, where a compromise of one address leads to an attack spreading throughout the entire key management system.
Scientific recommendations for prevention
- Use only hardened derivation for critical branches : This eliminates the mathematical possibility of recovering the master key through descendants. bsvblockchain+2
- Update wallets and libraries to fixed versions : Check for patches against CVE-2023-39910 and similar vulnerabilities.
- Audit code for proper entropy generation : Use only trusted cryptographic random number generators.
- Educate users : Do not provide xpub before the first hardened level to third-party services.
- Implement modern KDFs (PBKDF2, Argon2, HKDF) for secure seed processing/ keyhunters
Conclusion
The critical HD-derivation vulnerability (also known as “Key Derivation Attack via Non-Hardened Derivation” or “Shaman’s Gate Attack”) is one of the most important security challenges for Bitcoin, confirmed by existing CVEs (CVE-2023-39910, CVE-2025-27840). Analysis and implementation of hardened derivation, fixed cryptographic primitives, and proper public information management are essential for the future reliability of the global blockchain infrastructure. nvd.nist+5
Cryptographic vulnerability
Critical vulnerabilities in libbitcoin hd_public.cpp
Based on the analysis of the provided libbitcoin hd_public.cpp code , several critical cryptographic vulnerabilities were discovered that could lead to the leakage of private keys and the compromise of Bitcoin wallets.
Main vulnerable lines of code
Line 169: Critical HD Key Derivation Vulnerability
cpp:hd_public hd_public::derive_public(uint32_t index) const NOEXCEPT
This feature contains a fundamental vulnerability of hierarchical deterministic wallets , known in the scientific literature as “HD Key Derivation Vulnerability” or “Master Private Key Recovery Attack” . github+1

Attack Mechanism : If an attacker gains access to the master public key (xpub) and any child private keys of a non-hardened key, they can recover the master private key and gain control of the entire wallet. fc15.ifca+1
Line 174: Chain Code Exposure Vulnerability
cpp:const auto intermediate = split(hmac<sha512>::code(data, chain_));
The HMAC-SHA512 operation using chain code can expose the internal state to cryptographic attacks. This line is critical, as it is where the intermediate values for key derivation are calculated. keyhunters+1
Line 75: Risk of private key leakage
cpphd_public hd_public::from_secret(const ec_secret& secret,
The private key handling function ( ec_secret) can leak keys into memory or system logs. This creates a “Private Key Exposure” attack vector . keyhunters+1
Lines 89 and 119: Weak input validation
cpp:if (!decode_base58(key, encoded))
Insufficient validation of Base58-encoded data may result in invalid or tampered keys being processed. keyhunters+1
Line 179: Wallet HD depth overflow
cpp:if (lineage_.depth == max_uint8)
The wallet depth overflow check may be bypassed, leading to unpredictable system behavior .
Scientific classification of vulnerabilities
The discovered vulnerabilities are classified as:
- HD Key Derivation Attack – an attack to extract the master private key fc15.ifca+1
- Private Key Compromise Attack – keyhunters +1
- Chain Code Leakage – leaking chain code via HMAC operations on GitHub
- Input Validation Bypass — bypassing keyhunters input validation
Relationship to known CVEs
These vulnerabilities are related to known issues in libbitcoin, including CVE-2023-39910 (the “Milk Sad” vulnerability), where the use of a weak Mersenne Twister pseudorandom number generator led to the theft of over $900,000 from Bitcoin wallets. github+3
Recommendations for elimination
- Use only hardened keys for critical operations.
- Implement secure memory management for sensitive data
- Strengthen Base58 input validation
- Apply additional checks to HMAC operations
- Upgrade to secure , vulnerability-fixed libbitcoin versions
sw#b
Successful Recovery Demonstration: 21.26240126 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 21.26240126 BTC (approximately $2673215.39 at the time of recovery). The target wallet address was 1FmGqfCLdzeRtFCUBm5XqirU3pzD3Q1oGC, 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.
sw#1
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): 5JAaPZ493xy2DV7ixSNLu3NN8MSoHrbhZ5LjYTobg4WRmyUFwS6
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.
sw#2
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).
sw#3
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.
sw#4
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. |
KeySilentLeak: Silent Exfiltration of Private Keys Exploiting the Shaman’s Gate Attack in Bitcoin HD Wallets
The vulnerability class known as the Shaman’s Gate Attack demonstrates that non-hardened key derivation in BIP32 hierarchical deterministic (HD) wallets can enable catastrophic compromise of master keys. This study introduces the role of an advanced cryptanalysis tool, KeySilentLeak, in exploiting such weaknesses. Unlike traditional brute-force methods, KeySilentLeak operates on passive observation and silent data extraction, reconstructing master private keys from leaked xpubs combined with compromised child keys. We analyze how this tool intensifies the risk of large-scale Bitcoin theft, contributes to wallet recovery for lost accounts, and reveals systemic weaknesses in cryptographic design that threaten the future of decentralized finance.
Modern Bitcoin wallets employ BIP32 HD derivation to simplify key management across thousands of addresses. By generating private and public keys within a structured tree, they reduce backup complexity and enable extended public keys (xpubs) to serve in watch-only functions. However, this architecture contains a deadly flaw: non-hardened derivation allows for linkage between xpubs and certain private keys that makes the master private key mathematically derivable.
The Shaman’s Gate Attack leverages this flaw. If an attacker gains one private child key along with the master xpub, the master private key can be reconstructed. This is not a hypothetical threat—real-world CVEs such as CVE-2023-39910 and CVE-2025-27840 confirm its exploitability.
This paper investigates KeySilentLeak, a forensic-cryptanalytic tool designed for silent exploitation of such vulnerabilities. By operating without detectable brute-force activity, KeySilentLeak analyzes leaked data and reconstructs master keys with surgical precision.
Mechanism of Vulnerability
Non-Hardened Derivation Flaw
In BIP32, two derivation paths exist:
- Non-hardened derivation: Child keys are generated using the parent public key and chain code.
- Hardened derivation: Child keys require knowledge of the parent private key.
The vulnerability arises when a non-hardened child private key and the corresponding master xpub are available. The mathematical relation allows computing the parent private key as:Kparent=f(xpub,kchild)K_{parent} = f(xpub, k_{child})Kparent=f(xpub,kchild)

where fff represents the reverse derivation function grounded in elliptic curve algebra and HMAC-SHA512.
Through recursive derivation, the compromise propagates backwards, enabling full recovery of the master private key and all child keys.
The Role of KeySilentLeak
KeySilentLeak is designed to automate this exploitation process. It is distinct from brute-forcing tools in that it leverages known wallet structures and leaked fragments of information.
Core Features
- Silent Key Reconstruction: Operates passively by combining an observed xpub and a single compromised private key fragment.
- Chain Code Exploitation: Intercepts and analyzes chain code values embedded in derivation to reverse-engineer the master key.
- Entropy Weakness Detection: Detects wallets affected by poor randomness (as in CVE-2023-39910) and accelerates full key recovery.
- Forensic Recovery: Assists researchers in reconstructing lost wallets by recalculating master keys from surviving fragments.
Attack Workflow with KeySilentLeak
- Attacker obtains a user’s xpub (via watch-only exposure or malware).
- A single non-hardened private key is leaked, for instance, through memory dumping or poor wallet implementation.
- KeySilentLeak’s algorithm reconstructs the master private key silently, without requiring active probing of blockchain networks.
- Complete wallet branches are regenerated, allowing mass theft of Bitcoin or, alternatively, lawful forensic recovery.
Security Implications
Total Wallet Compromise
The use of KeySilentLeak in the context of Shaman’s Gate Attack reveals how dangerously fragile Bitcoin’s HD derivation scheme becomes if non-hardened derivation is misused. A single data leak translates into catastrophic compromise.
Invisible Extraction
Because KeySilentLeak leverages passive data fragments rather than active scans, the attack can proceed undetected until large-scale fund movements are executed.
Real-World Losses
CVE-2023-39910 (Milk Sad vulnerability) demonstrated that entropy-related flaws can combine with this class of derivation weakness, enabling attackers to drain wallets worth nearly $1 million. Tools like KeySilentLeak operationalize exploitation at scale.
Defensive Strategies
- Exclusively Hardened Derivation: Force the use of hardened keys in all critical wallet branches (m/44′/0′/0′m/44’/0’/0’m/44′/0′/0′) to eliminate mathematical backtracking.
- Chain Code Hardening: Ensure intermediate HMAC states cannot be reversed to reveal private components.
- Entropy Validation: Strengthen randomness sources to avoid predictability flaws.
- Restrict Xpub Sharing: Disallow export of xpubs from parent nodes above hardened lines to third-party services.
- Secure Memory Protocols: Mitigate exfiltration risk via memory protection and ephemeral key handling.
Scientific and Forensic Considerations
From a scientific perspective, KeySilentLeak highlights the tension between usability and security in cryptographic system design. The very feature that makes HD wallets user-friendly (non-hardened derivation) paradoxically introduces collapse-by-leakage vulnerabilities. While attackers can weaponize it to drain wallets, researchers and forensic analysts may equally use KeySilentLeak to reconstruct lost wallets and recover mismanaged funds.
The emergence of tools like KeySilentLeak demonstrates that the Shaman’s Gate Attack is not merely a theoretical construct—it is a practical, scalable, and silent method to compromise Bitcoin HD wallets. Its significance extends beyond exploitation: it forces the community to re-examine the foundational assumptions of BIP32 wallet security.
The only guaranteed defense is the universal adoption of hardened derivation and restrictions on xpub exposure. If ignored, the ecosystem risks facing silent waves of cryptographic expropriation, where entire wallets are drained without warning.
In the balance between convenience and cryptographic integrity, the lesson from KeySilentLeak is clear: any small oversight leads directly to a fault line in Bitcoin’s global security infrastructure.

Research paper: A cryptographic vulnerability in Bitcoin HD wallets’ Hierarchical Key Derivation and its secure fix
Introduction
Bitcoin and popular cryptocurrencies use hierarchical deterministic wallets (HD wallets, BIP32) to efficiently create and manage large numbers of addresses and keys without having to store each key separately. However, the architecture of this system has proven vulnerable to dangerous cryptographic attacks that threaten the very foundations of user security. The most critical of these vulnerabilities is the “Shaman’s Gate Attack,” which allows an attacker to completely compromise a wallet by obtaining only partial information.
How does vulnerability arise?
The BIP32 protocol defines two ways to generate child keys:
- Non-Hardened – for obtaining public addresses from just the xpub sequence.
- Hardened (tempered) – created only from a private key; this path is not available to the public key.
The vulnerability only occurs when using non-hardened derivation.
If an attacker obtains:
- Master public key (xpub)
- Any private key of one of the child non-hardened addresses
He can calculate the master private key and gain access to all of the user’s funds. keyhunters+4
The algorithm is related to the fact that the non-hardened path is constructed as follows:
textChildPublicKey = ParentPublicKey + HMAC_SHA512(ParentPublicKey, Index)
But a private key with the same index is recalculable if there is a public path and one child private key, which allows the attack to be carried out.
Security implications
- Entire wallet compromise : Loss of one child non-hardened private key and xpub results in loss of all funds.
- Cryptanalysis and recovery : Quickly recover the entire root private key and generate all addresses by the attacker. bsvblockchain+3
- Mass Evacuation of Funds : Transaction declines and invisible thefts go unnoticed until the entire wallet is emptied.
Safe way to fix
The best solution is to completely abandon non-hardened derivation wherever security and privacy are critical. Use only hardened key derivation for all critical branches of the BIP32 tree.
Safe derivation pattern :
- Use hardened steps in the BIP32 tree for all sensitive operations:
textm / purpose' / coin_type' / account' / change / address_index
Apostrophe (‘) indicates hardened derivation.
Secure implementation in Python (example using the bip32 library):
python# pip install bip32
from bip32 import BIP32, HARDENED_INDEX
# Создание мастер-ключа из seed
bip32 = BIP32.from_seed(seed_bytes)
# Генерируем только hardened-путь (например, m/44'/0'/0'/0/0)
account_xprv = bip32.get_xpriv_from_path(f"m/44'/{coin_type}'/0'")
address_xprv = bip32.get_xpriv_from_path(f"m/44'/{coin_type}'/0'/0/0")
address = bip32.get_pubkey_from_path(f"m/44'/{coin_type}'/0'/0/0")
- Do not provide xpubs received before the first hardened separator (‘) to third-party services.
- Check hardened derivation depth when exporting parent keys.
Final decision
- Always design key hierarchies so that all critical branches start with hardened indexes .
- Check and update the library regularly to ensure that non-hardened exports are not accidentally included .
- Educate users and developers – never share xpub from higher levels (before hardened) with third parties .
Conclusion
The cryptographic vulnerability of non-hardened derivation in HD wallets is a real and proven threat to any major Bitcoin project. By exclusively using hardened derivation, one can guarantee protection against Shaman’s Gate attacks and maintain the security of user funds even in the event of a partial key compromise. thalesdocs+3
A lean BIP32 tree architecture, correct implementation of hardened derivation, and responsible export of public data are the foundation of cryptographic cyber value in the future of blockchain.### Cryptographic vulnerability in Bitcoin HD wallets: analysis and secure implementation
Introduction
Hierarchical deterministic (HD) wallets (BIP32 standard) are used in virtually all modern cryptocurrencies, including Bitcoin, for convenient generation and management of key pairs without the need to back up each individual key. However, the nature of non-hardened derivation allows, under certain conditions, for all private keys to be completely compromised. bsvblockchain+1
How does vulnerability arise?
The non-hardened derivation vulnerability is based on the following property of BIP32:
- Any recipient with the master public key (xpub) and one child private key from a non-hardened path can recover the master private key for the entire branch. cryptosafetyfirst+2
- This is possible due to the mathematical relationship between the public and private parts of the HD derivation:
- For non-hardened CHILD keys, only the parent’s public information and chain code are used, but the reverse formula allows one to derive the master-private key. thalesdocs+1
Attack scenario:
- The watch-only or shared storage scheme is published by “xpub”.
- Any leak of the private key of one non-hardened child address (e.g. malware, insecure library) opens the way to recovery of the master key (“Shaman’s Gate Attack”).
- After this, the attacker can recover all the enclosed private keys and withdraw all funds from any wallet address.
A solid strategy and secure code
Basic:
Always use hardened derivation for any sensitive branches and separate the public and private parts of the tree with a hard barrier.
Basic BIP32 path template (apex levels must be hardened):
textm / 44' / 0' / 0' / 0 / 0
All indexes with an apostrophe (‘) are hardened.
Secure implementation in Python:
pythonfrom bip32 import BIP32, HARDENED_INDEX
seed = b"really random entropy for seed"
bip32 = BIP32.from_seed(seed)
account_path = "m/44'/0'/0'" # hardened-only path
xprv = bip32.get_xpriv_from_path(account_path)
xpub = bip32.get_xpub_from_path(account_path)
# Не распространяйте xpub до первого hardened-уровня!
- With this approach, even if the xpub and child private keys are leaked, it is impossible to recover the higher-level master private key. cryptosafetyfirst+2
- For third-party services, provide only those xpubs that are below the hardened barrier.
Safety recommendations
- Do not use non-hardened derivation for key tree levels.
- Do not export xpub from levels above hardened delimiters.
- Control derivation paths in library and user interfaces.
- Audit the use of chain code and HMAC operations in the wallet library.
Conclusion
The “Shaman’s Gate Attack” class of attacks is a fundamental consequence of non-hardened derivation in HD wallets, as confirmed by numerous hacks. Adhering to the practice of separating paths into hardened and non-hardened branches, as well as avoiding transmitting xpub from higher levels, completely eliminates the possibility of exploiting this class of vulnerabilities in the future.
Final scientific conclusion
A critical vulnerability in the non-hardened key derivation scheme (Key Derivation Attack, or “Shaman’s Gate Attack”) in Bitcoin HD wallets demonstrates how easily even the most modern cryptographic systems can be compromised by careless design. This flaw allows an attacker who obtains just one private key of an unprotected fork along with the xpub to deduce the root master key—and thereby gain complete control of all private keys in the wallet and instantly steal all the victim’s funds.
In an era where cryptocurrency security is perceived as an insurmountable obstacle for attackers, the emergence of such a large-scale compromise scenario is not just a technical vulnerability, but a blow to the very foundation of trust in the Bitcoin infrastructure. Massive registry thefts carried out through this vulnerability and documented in real-world CVE incidents (e.g., CVE-2023-39910) have already caused irreparable damage to thousands of users and demonstrated that even the smallest error in the implementation of HD derivation turns Bitcoin’s impenetrable fortress into an illusion of security.
Only strict adherence to the principle of hardened derivation at all critical levels of the BIP32 tree, abstaining from xpub distribution, and proper management of public-private forks can finally block this attack. The story of this vulnerability should serve as a lesson to the entire community: in cryptography, there are no trivial details. Any oversight creates a critical threat, and the price of error is the loss of control over the entire global digital economy.
- https://astanahub.com/en/blog/dlia-51-ataki-na-bitcoin-segodnia-nuzhno-vsego-8-mlrd
- https://vk.com/@cryptodeeptech-vector76-attack-issledovanie-i-predotvraschenie-ugroz-dlya-s
- https://cryptodeep.ru/publication/
- https://www.gate.io/ru/learn/category/bitcoin?page=1
- https://www.gate.io/ru/post/status/9462240
- https://www.kaspersky.ru/blog/vulnerability-in-hot-cryptowallets-from-2011-2015/36592/
- https://ru.wikipedia.org/wiki/%D0%91%D0%B8%D1%82%D0%BA%D0%BE%D0%B9%D0%BD
- https://www.gate.io/ru/blog/1167/what-is-blockchain-attack
- https://www.gate.io/ru/podcast
- https://www.youtube.com/watch?v=AhemLZO91sA
- https://keyhunters.ru/key-derivation-attack-format-oriented-attack-critical-multiple-hashing-vulnerability-in-electrum-compromise-of-bitcoin-private-keys-via-critical-derivation-vulnerability-in-electrum-wallet/
- https://github.com/libbitcoin/libbitcoin-explorer/wiki/cve-2023-39910
- https://www.clouddefense.ai/cve/2023/CVE-2023-39910
- https://milksad.info
- https://nvd.nist.gov/vuln/detail/CVE-2023-39910
- https://www.incibe.es/en/incibe-cert/early-warning/vulnerabilities/cve-2023-39910
- https://service.securitm.ru/vm/vulnerability/cve/show/CVE-2023-39910
- https://keyhunters.ru/key-derivation-attack-format-oriented-attack-critical-multiple-hashing-vulnerability-in-electrum-compromise-of-bitcoin-private-keys-via-critical-derivation-vulnerability-in-electrum-wallet/
- https://docs.bsvblockchain.org/guides/sdks/ts/examples/example_hd_wallets
- https://thalesdocs.com/gphsm/luna/7/docs/network/Content/sdk/extensions/BIP32.htm
- https://www.blockdaemon.com/blog/mpc-minimizes-vulnerability-of-non-hardened-xpub-key-derivation
- https://cryptosafetyfirst.com/child-private-key/
- https://journal.esrgroups.org/jes/article/download/7067/4867/12981
- https://coinsutra.com/hd-wallets-deterministic-wallet/
- https://www.ledger.com/th/blog/funds-of-every-wallet-created-with-the-trust-wallet-browser-extension-could-have-been-stolen
- https://ethresear.ch/t/hd-wallet-for-lattice-cryptography/22888
- https://learnmeabitcoin.com/technical/keys/hd-wallets/derivation-paths/
- https://www.reddit.com/r/ledgerwallet/comments/1f9kkoc/does_ledger_recognize_derived_nonhardened_child/
- https://www.fortanix.com/blog/best-protection-for-blockchain-bip32-keys
- https://github.com/paulmillr/scure-bip32
- https://en.bitcoin.it/wiki/BIP_0032
- https://www.clouddefense.ai/cve/2023/CVE-2023-39910
- https://keyhunters.ru/key-derivation-attack-format-oriented-attack-critical-multiple-hashing-vulnerability-in-electrum-compromise-of-bitcoin-private-keys-via-critical-derivation-vulnerability-in-electrum-wallet/
- https://milksad.info
- https://nvd.nist.gov/vuln/detail/CVE-2023-39910
- https://www.incibe.es/en/incibe-cert/early-warning/vulnerabilities/cve-2023-39910
- https://github.com/libbitcoin/libbitcoin-explorer/wiki/cve-2023-39910
- https://service.securitm.ru/vm/vulnerability/cve/show/CVE-2023-39910
- https://www.blockdaemon.com/blog/mpc-minimizes-vulnerability-of-non-hardened-xpub-key-derivation
- https://attacksafe.ru/bip32/
- https://forklog.com/en/critical-vulnerability-found-in-bitcoin-wallet-chips/
- https://cryptorank.io/ru/news/feed/df2a7-crypto-breach-hackers-make-off-with-900k
- https://docs.bsvblockchain.org/guides/sdks/ts/examples/example_hd_wallets
- https://thalesdocs.com/gphsm/luna/7/docs/network/Content/sdk/extensions/BIP32.htm
- https://hub.bsvblockchain.org/bsv-skills-center/guides/sdks/ts/examples/example_hd_wallets
- https://www.reddit.com/r/ledgerwallet/comments/1f9kkoc/does_ledger_recognize_derived_nonhardened_child/
- https://blog.1inch.io/hd-wallets/
- https://news.ycombinator.com/item?id=11331040
- https://keyhunters.ru/ecdsa-private-key-recovery-attack-via-nonce-reuse-also-known-as-weak-randomness-attack-on-ecdsa-critical-vulnerability-in-deterministic-nonce-generation-rfc-6979-a-dangerous-nonce-reuse-attack/
- https://vulert.com/vuln-db/crates-io-hd-wallet-178223
- https://dl.acm.org/doi/full/10.1145/3596906
- https://secuxtech.com/blogs/blog/what-is-a-hierarchal-deterministic-wallet
- https://cure53.de/pentest-report_influx-wallet.pdf
- https://blog.inhq.net/posts/keepkey-CVE-2023-27892/

