NHacker Next on Rails
  • top
  • new
  • best
  • ask
  • show
  • jobs
login
GuidelinesFAQListsAPISecurityLegalApply to YCContact

Hacker News on Rails, powered by React on Rails Pro. Open the source on GitHub by ShakaCode.

Commit 06fc0df

Rendered at 09:05:20 GMT+0000 (Coordinated Universal Time) with Rails + React on Rails RSC.

How I almost found the eMudhra d=4 Private Key (blog.hboeck.de)

359 points by hannob 23h ago | 76 comments

nopurpose 22h ago
Reminded me of a story I read long ago, where inventor of ping was "jealous" (jokingly) that he didn't think of traceroute.
breitling 17h ago
About ~25 years ago in college, a friend was getting harassed on her hotmail email by seemingly someone she knew in real life.

I used tracert to track the mail back to a specific machine at the Mississauga library (in Ontario Canada). Then we called the library and they told us who was logged to that machine at that specific time. Turns out, she knew the guy and the mystery was solved.

srean 15h ago
> Then we called the library and they told us who was logged to that machine at that specific time.

Libraries entertain requests like that even if they do not originate from a law enforcement body ?

necovek 13h ago
25 years ago they said. Internet was very weird, and people were not as fussed about privacy because it was not abused at every point.

So when someone calls you and asks about emails coming from your machine, you might just as well say who it was.

dormento 15h ago
> About ~25 years ago in college

Life was simpler back then.

srean 15h ago
I guess this was prior to 9/11
cwmoore 10h ago
What you intended to say is that it was likely prior to the backlash to the government legislating carte-blanche surveillance after 9/11. Libraries famously refused to hand over patron information in cooperation with the P.A.T.R.I.O.T. Act, but it is still irrelevant in the case of a private response to helping a reported harassment victim, which people tend to want to cooperate with to this day.
ThrowawayTestr 12h ago
9/11 has nothing to do with it.
breitling 11h ago
Yea, it seems strange now, but they did it without a hassle. The whole tracing and calling took under 5 mins
sublinear 12h ago
No. It's plausible-ish stories like the one you're responding to that make HN feel more and more like reddit. Look at all the nostalgiabait replies you're getting.
pixl97 16h ago
I've you've worked in the industry a long time it's likely you've stepped on a lot of really serious bugs or idea without realizing it.

When I was in school we had Netware and if you typed a bunch of garbage over 8 characters on login it would freak out. Turns out you could buffer overflow the login application and control program execution if you typed the correct magic in. I had no idea about buffer overflows so I missed the implication and didn't get to control my school network at root level.

A few years later with an early version of IE back in the dial up days I damaged a link/URL to Microsoft Netmeeting and it came up with a BUFFER OVERFLOW error in Win95. I still had no idea about controlling program execution flow so I likely saved myself getting federally prosecuted after spreading a hack around online when I was still young and dumb.

There was just so much low hanging fruit around. And it's kinda crazy that some of it still shows up to this day.

macintux 6h ago
I remember ~30 years ago stomping around the office and yelling about Netscape's web server product: if it invoked a CGI program, and that program printed to stderr, it would be fed to the web browser.

If you were lucky, the unbuffered error message would hit the browser first and the browser would report a 5xx error, IIRC.

If you were unlucky, in the middle of the webpage you'd see a system error that could, for example, include sensitive information like filesystem paths (or in an extreme case, credentials).

Probably there was some configuration setting that overrode this behavior, but at the time I was so incredulous that this was the default behavior that I didn't look through the documentation.

Quarrel 6h ago
I once wrote a TCP stack for a research OS (we already had an IP stack).

To prove it worked I wrote a simple fingerd (RFC 1288, port 79 - for those that aren't old, we used to be able to `finger quarrel@host.tld` and get back the contents of a `.plan` file), and shared it to our wider international research group.

One of them replied pretty quickly with a webserver serving up some our docs on it. It was a much cooler demo.

I felt like an idiot for not having thought it! (to be fair, this was super early web days)

stackghost 18h ago
Traceroute is a weird tool. In all my years it’s only helped me a single-digit number of times but it was invaluable when it did so.

The best one was getting to ask Shaw if they’d turned their router off and then back on again.

magneticstain 18h ago
In my experience, I've found it to be most valuable when troubleshooting network issues on a network you don't manage or have any insight into.

For example, I used to work at an MSSP that sold managed IPS devices that customers would put in their network. If there was a connectivity issue to something you know is up, traceroute was typically the first tool in the arsenal.

hdgvhicv 11h ago
On the other hand I use it almost every day
skrebbel 17h ago
Googled it so you don’t have to: Shaw was a Canadian internet provider.
cowlevel 14h ago
I've just seen a video on front-page YouTube about a project I tried 10 years ago and didn't continue with.
fzeindl 23h ago
Would it be feasible to run a crawler that connects to all HTTPS ips on the internet and tries to bruteforce the key with a time budget of a couple of seconds?

Alternatively make browsers brute force keys when connecting via HTTPs, maybe distributing the work by checking a registry of keys that were already tried by some other user with the same browser?

tgsovlerkhgsel 22h ago
Certificate Transparency makes the crawling unnecessary unless you want to look for keys that are not issued by standard CAs that browsers trust.
fzeindl 22h ago
Intermediate certificates are not in the browsers’ trust stores.
schoen 15h ago
Everyone who replied to you is pointing out CCADB, but to give more historical context, before CCADB there was indeed a humongous concern about undisclosed intermediates, some of which were even occasionally delegated to other organizations that did not follow CA industry rules or standards.

It was extremely appropriate to worry about that, and there was a fair amount of chaos there. It's just that the industry subsequently followed through and added transparency to that part of the system, which you may not have noticed because it was comparatively recent in the overall history of the web PKI!

hizlikovboy27 22h ago
"They are publicly available and signed by trusted root certificates (the certificates are logged in CT)" This is exactly why google's paranoidcrypto tool can capture them via CCADB/CT. Because only private,untrusted certificate authorities remain outside of CT.
hannob 22h ago
They're in CCADB, so that's an easy source.
tgsovlerkhgsel 19h ago
The known ones are in CT though AFAIK?
opello 7h ago
It seems a shame to not have a reference to the EFF's SSL Observatory in this comment thread:

https://www.eff.org/observatory

Retr0id 23h ago
Per the article, the Baby Step Giant Step algorithm is more efficient than bruteforce for small keys.
hannob 22h ago
Nah, that's not really the case and not what I wanted to imply.

Computationally, "bruteforce" always wins for a larger number of keys, as you just have to generate all keys once and do a binary lookup in a list. (You can, however, also precompute parts of BSGS.) It's more a tradeoff between how large your blocklist is versus how many keys you want to cover.

Right now, I'm doing keys with 8 bit values via "bruteforce" (aka blocklist). I may switch to BSGS and do 16 bit. Going to 32 bit would, as far as my initial tests go, be too slow. At least for badkeys, where I want to be able to scan a large number of keys fast.

Retr0id 22h ago
Ah, what I meant to say was comparing bruteforce-without-lookup to BSGS-with-precomputation - which I suppose was comparing apples to oranges
nraynaud 21h ago
I’m a complete noob, “Baby Step Giant Step algorithm” is the best algorithm the crack the public key starting by the easiest values first? Wikipedia is a bit unclear.
cowsup 20h ago
Imagine if I have a private key, value 123,123, that produces the output of "hi." You have to go through every number, starting from 0, to compute it and try to figure out what my key is. That means 123,123 attempts before you get in.

A private key value of 1 produces "egg," value 2 produces "salt," value 3 produces "blue." You do this for the first 10 values, and have used up 10 attempts.

You also find that you can reduce [my unknown private key] by [10] and see outputs. So you adjust my key [123,123] by 10 and get [123,113] which produces "igloo," and you keep doing that, going by 10s.

After 12,312 decreases, going by 10s, you get the output "blue." Since you already computed the first ten values, you know that "blue" is key 3.

So, thanks to decreasing by 10, 12,312 times, and getting the value that key 3 gave you, you can calculate that (10*12,312)+3=123,123, my private key, in far fewer computes.

If you have enough memory to calculate 1,000 baby steps before taking your giant steps, you can make your giant steps be 1,000 digits long each, rather than 10 in my example, and so on and so forth, to speed it up even more.

zapkyeskrill 18h ago
Pardon my ignorance but, how do I reduce (your unknown private key) if I don't know what (your private unknown key) is?
cowlevel 14h ago
It's actually increase. The cryptography works because make_publickey(privatekey1+privatekey2) == make_publickey(privatekey1)+make_publickey(privatekey2) (for a weird definition of +) (make_publickey henceforth abbreviated to mpk)

ECC math is pretty much just numbers, but the numbers are jumbled up so all you can do is add (and subtract, I think), you can't multiply or divide. (You can multiply a jumbled number by an actual number like 10, because that's just adding 10 times, but you can't multiply two jumbled numbers) The private keys are actual numbers so you can do whatever you want, the public keys are the equivalent jumbled numbers.

You work out mpk(1000),mpk(2000),mpk(3000),... in advance. You start with someones public key and add mpk(1) repeatedly 1000 times and if it ever matches any of the ones you just computed, then you know the private key. For example if their_publickey+mpk(234) == mpk(2000) then their_publickey == mpk(1766) and since their_publickey==make_publickey(their_privatekey), obviously their_privatekey==1766.

pas 15h ago
that means you can do the attempts by an an increment of 10. (reduce applies to the number of "attempts before you get in")

phrased in a different way: you can do the steps by [10] instead of one by one (if you keep a list of what the key could be for 0 to 9)

the algorithm works by decomposing the [unknown private key] that we want to find into a "remainder" (which you get after dividing by the "giant step" number, in the example 10, but it can be 100, or square root of the number of elements in the cyclic group used for a given key exchange) and a multiplier of how many times the "giant step" number divides the key.

https://en.wikipedia.org/wiki/Baby-step_giant-step

nopurpose 15h ago
I don't follow either. If we don't reduce, then we multiply by ten (giant steps), right? But which baby step we multiply first and how do we know to stop trying that step and change to something else? It seems that we still guess, just not sequentially, but total number of steps to guarantee solution is still the same.
c_engineer56 13h ago
The baby steps are stored in a hash table (F(x), x), then for each giant step the remainder S - F(n) is looked up in the hash table. An elliptic curve allows you to add and subtract points. If S - F(n) is found in the hash table, the private key is n + x. If S - F(n) is not found, n is incremented by the giant step. Instead of 2^256 operations, baby-step giant-step does 2^128 hash table lookups at the cost of space for 2^128 hash table entries. If available memory is smaller than 2^128, for example 2^80, then baby-step giant-step would do 2^176 hash table lookups on a hash table of size 2^80 entries. But the speedup is limited to sqrt(2^256) = 2^128 because it takes at least 2^128 operations to fill the hash table.

An analogy is the O(n) algorithm for Two Sum. Instead of iterating over n^2 pairs (= O(n^2) time) and using O(1) space, a precomputed hash table replaces the inner loop iteration with a hash table lookup, changing the algorithm to O(n) time and O(n) space.

frereubu 22h ago
I can't pretend to understand all of this, but can anyone enlighten me as to what the motivation would be to us such as low number as the ECDSA private key? Was it just a cock-up or is there some benefit in terms of speed etc?
Catloafdev 15h ago
There are no benefits whatsoever. It was just a fuck-up.
Liquid_Fire 22h ago
You can read eMudhra's incident report here, where they cover how it happened: https://bugzilla.mozilla.org/show_bug.cgi?id=2083449#c82

But the tl;dr is, it was a cock-up due to bad processes, a bug in a script and ignoring some red flags later on.

frereubu 22h ago
Thanks!
terom 22h ago
A bug in a one-off Python script running outside of the HSM truncated the ECDSA private key to a single byte.

Handling the unwrapped key material outside of the HSM was apparently in violation of their CPS, but nobody would have noticed if it wasn't for that bug.

I can see why they made the decision to exit the CA business afterwards - that is exactly the kind of thing that you do not do as a CA.

> Contributing Factor 1: Host‑side ceremony script error.

Description: Given that the script was a one off meant for export of key pairs, the approved wrap/unwrap deviation from the normal eMudhra KGC was executed with a custom python key‑handling script created by the PKI Operations team. After the wrapped key was returned, the script read the unwrapped private key’s value out of the module (in host side memory) and re‑created a key object from that host‑side value. For the ECDSA objects, a single line in that read‑back truncated the private value to its leading byte, so the re‑created object held a scalar below 256; this re‑created object (not the originally generated key) was used to produce the CSR and was certified. For the RSA objects, the same pattern did not truncate the key (integrity intact), but during re‑import the key material was handled within the volatile memory of the Python process on the ceremony host. A re‑import performed from host process memory is not consistent with the CPS §6.2.6 and the RSA objects are therefore treated as not meeting that requirement.

pbkompasz 22h ago
Cock-up is the technical term
auguzanellato 13h ago
They actually truncated the keys by accident while moving them between HSMs
cmd123 20h ago
Laziness.
meindnoch 22h ago
Gross incompetence.
N_Lens 22h ago
It was just a cock-up!
davbryn2 22h ago
Somebody trying to be funny https://xkcd.com/221/
cobychapple 23h ago
Still blows my mind how close to the bone this xkcd got too: https://www.xkcd.com/221/
blauditore 22h ago
There's a chance some dev did this as a joke of sorts (referring to the comic) and somehow it landed in prod. So it might not even be a coincidence. But we might never find out.
hannob 22h ago
There were 8 affected keys and only one was d=4, all were single-byte values. Very much looks like a byte-truncated value.
nraynaud 21h ago
That’s also what the post mortem said, they crushed the high-order bytes of “quality” keys.
embedding-shape 21h ago
Yeah, in this particular case I agree. Although "some dev did this as a joke of sorts and somehow it landed in prod" is still true, some years ago I added a get_pseudo_random_number function that returns 4 to at least one application currently running in production, I'm sure I'm not alone :)
8organicbits 20h ago
I've built one as well. Mine is a joke about the lack of uniqueness guarantees in UUIDv8. I don't believe anyone uses mine though.

https://github.com/robalexdev/uuidv8-xkcd-221

rustyhancock 22h ago
Also referenced by fail0verflow when the algebraically recovered the PS3 master private key.

As Sony used the same k for each signature.

https://youtu.be/LP1t_pzxKyE?t=236

mschuster91 20h ago
wasn't something like that also what led to HDCP and AACS being effectively hard-broken?
rustyhancock 19h ago
Something similar I think algebraically derived from multiple faulty keys.

https://www.cypherpunks.ca/~iang/pubs/hdcp-drm01.pdf

throw0101d 21h ago
> https://www.xkcd.com/221/

Also Dilbert:

* https://fridayfun.net/dilbert-2001-10-25

SidLais 15h ago
badkeys already had d=4 on his laptop from the script, and the CCADB certs were already in his regular scan set. the only missing step was adding them to the blocklist. a cronjob would've caught it
ttouch 20h ago
can anyone explain to me why the priv key was not a prime? I thought it was a "requirement" to be a prime - though i guess the actual math don't break without a prime
aaronmdjones 20h ago
You're thinking of RSA, where the RSA public key n is the product of two primes p and q. There is no such requirement for ECDSA.
kaladin-jasnah 9h ago
4 is the product of 2 and 2, so could it still be valid?
aaronmdjones 6m ago
I should have clarified that p and q need to be distinct and quite far apart from each other in value. If they are the same you can simply take the square root of n to find the p and q values that you need to compute the private key.
syncsynchalt 8h ago
ECC keys have nothing to do with primes.

I'm most familiar with Curve25519, where private keys are simply 256-bit random numbers, with five of those bits ignored/overridden, resulting in effectively 251 random bits in a key. P-256 keys are similar.

To get technical: the base point on the curve is then "multiplied" by the private key, resulting in a new point on the curve which is your public key. See curves.xargs.org for more details.

boardendgrain 8h ago
The new floor? d=8
vijay886 8h ago
This is breaking out, awesome
chromejs10 21h ago
How I almost read the article
ufocia 18h ago
A bit self-aggrandizing. Should've been a more humble "How I didn't find the eMudhra d=4 Private Key" as a post mortem, rather than click bait and name dropping.
teiferer 19h ago
Fun read, but it's a quite extensive backstory to an achievement the author didn't actually have?

Feels like a blog post of an elite athlete "How I almost won the Olympics" where they describe the training and the test results and their qualification successes and then how they got a cold the evening before the finals, so, no gold. But almost!!1 (Or maybe more appropriately, before going to the Olympics they decided to focus on their law degree instead so never went. But almost!!1)

smuhakg 17h ago
Well, the author is the maintainer of a tool called "badkeys" designed to scan public keys that have easily recoverable private keys. The fact he didn't find it despite specializing in this exact issue is interesting given how obvious it is in retrospect.
pbhjpbhj 18h ago
Yh, but "fun read" so ...?

Seems like a reasonable hook to talk about the person's 'badkeys' work and clue people in on the whole situation.

SpaceNugget 18h ago
And the "almost" in question is that he almost copied the functionality that he saw in google's "paranoid_crypto" a better tool doing the same sort of thing... So he almost took credit for someone else's scanner results. The whole thing reads pretty out there.
Aachen 5h ago
Stealing, or standing on the shoulders of giants? It would still be Hanno's project that applies the check to the CA keys database, if he had gone through with the simple variant of the implementation

I'm not saying credits would have been amiss, but it's also not far out there at all imo (none of the background info/story). You don't credit Nmap for finding an open telnet server on the Internet, and if you think to mention the tool you used, who's to say they came up with the idea of port scanning? Did they maybe "steal" that from someone? At least in security (that's my day job anyhow), I like to think we all learn from each other, with credits a goal that's secondary to safety (better one copied check than none). I personally wouldn't see adding a good idea as stealing credit, especially if you mention the inspiration source in a place like the commit or change log of a FOSS project, if it had come to pass in the way you describe in the first place

nbulka 19h ago
The question then is how much did you use AI during this time period?
kccqzy 18h ago
Clearly none. If he had used AI, AI would have immediately suggested the baby step giant step algorithm without needing to talk to a human expert (Henninger). And 2025-era AI probably could implement it in a few attempts.