
Proof-of-concept tool for recovering EC private keys affected by the October 2026 eMudhra intermediate CA key compromise (CVE-2026-111943, CVE-2026-111944)
Image credit: Forbes India
A proof-of-concept tool for recovering EC private keys affected by the October 2026 eMudhra intermediate CA key compromise (CVE-2026-111943, CVE-2026-111944), in which a flawed key-generation ceremony produced trivially small P-384 private scalars instead of properly random 384-bit values. Where the vulnerable keys are small enough, the private scalar's non-zero bytes are confined to the last byte (or last few bytes) of the 384-bit value, which makes brute-force recovery from the public key alone computationally trivial — a 256-value search per byte, rather than a ~2^384 search.
In October 2026, eMudhra disclosed that eight intermediate Certificate Authority (CA) private keys (six TLS and two code-signing) were compromised due to an April 2025 key-generation script error that produced trivially guessable keys.
See also: emudhra.we-have-a-problem.com
This tool was built to understand and reproduce the mechanics of that disclosed flaw: given a vulnerable certificate's public key, and the knowledge that the corresponding private scalar is a small integer (effectively zero in all but its last byte(s)), recover the private key by exhaustive search and verify it against the certificate's public key.
This is not a general attack on ECDSA/EC private keys. Brute-forcing an EC-384 scalar in the general case is a ~2^384 search and is computationally infeasible. This tool only works because the specific vulnerability class it targets produces scalars that are not uniformly random — they are small integers, meaning almost every byte of the 48-byte secp384r1 scalar is zero. That is what reduces the practical search space to 256 candidates per unknown byte.
If a key was generated correctly (a uniformly random 384-bit scalar), this tool cannot recover it. It only applies to certificates affected by this class of weak key generation, or to test keys you've deliberately constructed to resemble them.
openssl on PATH (the script shells out to openssl ec, openssl pkey, and openssl x509)
openssl is LibreSSL and does not support
-no_public. Install OpenSSL 3 via Homebrew (brew install openssl@3) and point --openssl at
/opt/homebrew/opt/openssl@3/bin/openssl if you need to strip the
public key from a freshly generated key.usage: emuddler.py [-h] [--openssl OPENSSL] [--start START] [--end END]
[--bootstrap] [--curve CURVE] [--outdir OUTDIR] [-q]
[--der private_key.der] [--cert cert.pem]
options:
-h, --help show this help message and exit
--openssl OPENSSL path to the openssl binary (default: openssl)
--start START override scalar start offset in the DER file
--end END override scalar end offset (exclusive)
--bootstrap generate a fresh key pair and use it as the nopub
input
--curve CURVE curve for --bootstrap (default: secp384r1)
--outdir OUTDIR directory for --bootstrap output (default: .)
-q, --quiet suppress per-iteration output; print only the final
result
--der private_key.der
input key in DER, e.g. ecdsa-secp384r1-key-nopub.der
--cert cert.pem cert PEM to compare the recovered public key
against
--der is required unless --bootstrap is given (in which case the
freshly generated -nopub key is used automatically). --cert is
optional: without it, the script parses the DER, reports the scalar
offsets, and exits without doing the brute-force search.
python3 emuddler.py --bootstrap --curve secp384r1
This runs, under the hood:
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:secp384r1 \
-outform DER -out ecdsa-secp384r1-key.der
openssl ec -in ecdsa-secp384r1-key.der -no_public \
-outform DER -out ecdsa-secp384r1-key-nopub.der
producing ecdsa-secp384r1-key.der (full key pair) and
ecdsa-secp384r1-key-nopub.der (private key only, no embedded public
key) in --outdir. For realistic testing of the vulnerable scenario,
manually zero out all but the last byte(s) of the scalar in the -nopub
file before recovery (or use --start/--end to tell the tool which
bytes to treat as unknown).
python3 emuddler.py --der ecdsa-secp384r1-key-nopub.der --cert EM-DV-TLS-CA-G3B.crt.pem
The script:
OCTET STRING
inside the ECPrivateKey SEQUENCE), without assuming a fixed header
length, so it works across different curves and encodings.0x00–0xff in the last byte, writes a candidate DER
key, runs openssl ec -text -noout on it, derives the public key with
openssl ec -pubout, and compares it (base64 body only) against the
public key extracted from --cert via openssl x509 -pubkey -noout.python3 emuddler.py --der ecdsa-secp384r1-key-nopub.der --cert EM-DV-TLS-CA-G3B.crt.pem -q
Suppresses all per-iteration output and prints only:
*** MATCH FOUND: last byte = 9c (hex) / 156 (dec) ***
elapsed time to match: 0.842s
or
No match found across 00..ff.
elapsed time: 21.407s
If the automatic DER parser ever gets the offsets wrong for a given file (e.g. an unusual encoding), or the vulnerable key has more than one non-zero byte, you can force the search range manually:
python3 emuddler.py --der private_key.der --cert cert.pem --start 7 --end 55
--end is exclusive; the byte at --end - 1 is the one that gets
iterated. Searching a wider range (more than one unknown byte) requires
extending the loop in the script to iterate over multiple byte positions
rather than just the last one.
emuddler.py has a small number of pieces:
parse_der(b, pos) — a minimal DER length-field parser. DER lengths
are either "short form" (a single byte under 0x80 giving the length
directly) or "long form" (a byte with the top bit set, whose low 7 bits
say how many following bytes encode the actual length). Returns
(length, new_position) so the caller can keep walking the buffer.find_privkey(b) — locates the private key bytes inside a SEC1
ECPrivateKey DER structure without hardcoding offsets, so it works
across different curves and key sizes. It expects:30 <len> -- outer SEQUENCE
02 01 01 -- INTEGER 1 (version)
04 <len> <scalar> -- OCTET STRING holding the private scalar
(a0 ... curve OID, a1 ... public key — ignored)
It checks the SEQUENCE tag, skips the length, confirms the version
integer is exactly 02 01 01, then reads the tag/length of the
following OCTET STRING and returns (start, end) — the byte range of
the actual scalar (e.g. the 48 bytes for secp384r1).
normalize_pem(pem_text) — strips the -----BEGIN/END----- lines
and all newlines from a PEM block, leaving just the base64 body as one
string, so two PEM public keys can be compared for equality regardless
of line-wrapping.