r/ProgrammerHumor • • Oct 23 '26

Meme privateKey

Post image
26k Upvotes

239 comments sorted by

View all comments

Show parent comment

30

u/GRex2595 Oct 23 '26

So are the public keys fixed-length? Because if this was RSA, I believe you would have to have a pretty short public key to get that as your private key.

111

u/SweatyPlayerOne Oct 23 '26

Yes, in this case (P-384) weโ€™re talking about a 384-bit private key and a 384-bit public key. The 384-bit private key is supposed to be randomly generated by the client and then the 384-bit public key is generated based on the private key. The incident in question was literally the number 4 being used as the 384-bit private key:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100

85

u/fury420 Oct 23 '26

and not just the number 4, there were a bunch of keys that were just 1 to 3 digit numbers.

Almost like someone misunderstood what 384-bit meant and just used numbers from 1-384

45

u/Saedeas Oct 23 '26

They're all below 255. I think they just truncated everything but one byte.

15

u/Mechakoopa Oct 23 '26

They only randomised the first byte of their byte array.

8

u/bloodfist Oct 23 '26

I might have misunderstood but I believe that after a series of 4s, there came 5, 6, 7, etc. Some bug caused it to overflow, get stuck on 4, and then start iterating from there. Something like that.

8

u/flojoho Oct 23 '26

must've been unlucky RNG

24

u/immortal_lurker Oct 23 '26

Nope. This was incompetence, they generated the key wrong. I don't know how. But it was.

Think of it this way.

Suppose the key was a proper key, and someone was guessing 100 digit numbers in no particular pattern. On the 4th try, they get it right. In that scenario, is there anything at all that would convince you they didn't know the key beforehand?

11

u/beatlemaniac007 Oct 23 '26

The entire boiled down version is that someone used testing artifacts in production by mistake. The real keys and the test keys were similarly named and someone didn't pay attention and fucked up. The string of events that led to it was a comedy of errors, but it wasn't some weird math...it was just using test stuff in production by mistake.

1

u/Silent-Suspect1062 Oct 24 '26

To make it worse they generated the crl using the correct key and later some one noticed the mismatch and changed the crl to fit.

16

u/dedservice Oct 23 '26

They generated a key between 1 and 384 instead of 1 and 2384

27

u/immortal_lurker Oct 23 '26

It looks a bit like they generated between 1 and 256, because there are 8 known bad keys below 256. It could just be coincidence that no keys are between 256 and 384, but my gut says 256 was the accidental upper bound.

Of course, from a security perspective, every number less than a billion might as well be 2.

10

u/atanasius Oct 23 '26 edited Oct 23 '26

64-bit keys are crackable with a little effort. The baby-step giant-step algorithm has square-root complexity, so the bit-length is effectively halved.

7

u/visor841 Oct 23 '26

IIRC these were test keys (still generated wrong) that were unknowingly pushed to prod.

7

u/evanldixon Oct 23 '26

Yes, because they were test keys they weren't subject to the typical security tests. Wait....

4

u/GRex2595 Oct 23 '26

That's a funny-looking key.

4

u/Paul_Robert_ Oct 23 '26

Well the public key is represented as its x-y coordinates modulo p, where p is prime number that's 384 bits long. The generator point coordinates are also 384 bits long each, so even when you multiply by a small number like 4, the result looks like a proper public key.

edit: oops forgot to mention that they are fixed length ๐Ÿ˜…

5

u/GRex2595 Oct 23 '26

The private key should have been super obvious, though. I'm trying to figure out how bad tou have to mess up to get 4 and not notice.

3

u/platinummyr Oct 23 '26

You have to not be paying attention. But once the public key is made, it will look random so you won't be able to tell easily

2

u/GRex2595 Oct 23 '26

But it's more than just not paying attention, right? Like you have to be making serious mistakes repeatedly to miss something this bad.

4

u/platinummyr Oct 23 '26

Yes absolutely. You have to be doing things non standard or home grown. The basic open source tools for creating keys wouldn't let you just do this, so they must have been doing something funny. But once the first mistake happens it is negligence to not notice and end up releasing it as the real public keys

3

u/SuperFLEB Oct 24 '26

Last I checked, it was that they didn't care when they were generating it. It was a test cert that got loose, so when they generated it, "4" looked stupid but that was okay. After they generated it, the "4" wasn't visible.

1

u/GRex2595 Oct 24 '26

Somewhere there is something responsible for ensuring that these keys are cryptographically secure. Maybe you can't actually see the 4 as a person looking at the cert, but something should be checking that the keys aren't being generated in any way that a 4 could randomly show up unnoticed and compromise the security. Somebody had to mess up bad for there to be no checks against these types of mistakes.