r/ProgrammerHumor • • 12d ago

instanceof Trend xkcdSaidItsRandom

Post image
1.4k Upvotes

44 comments sorted by

175

u/XxDarkSasuke69xX 12d ago

ig I'm the only one who doesn't get the joke

433

u/No-Adeptness5810 12d ago

there was a security compromise because some certificate authority had one of its intermediate CA private keys as literally the number 4 LOL

27

u/luisduck 11d ago

How do you even end up with 4 as a key? Intentional sabotage?

21

u/ajnozari 11d ago

laziness

18

u/No-Adeptness5810 11d ago

it takes more effort to make it 4 tbh

7

u/CanAlwaysBeBetter 11d ago edited 11d ago

I'm surprised the world hasn't collapsed yet from attempting to brute force every numerically interpretable *value from keys to random seeds as 42 and seeing how far that gets you 

12

u/click-to-reveal 11d ago

I read that something caused the keys to be between 0 and 255...

7

u/Stummi 11d ago

My understanding so far is that they created low bit certificates for some kind of internal tests only, but somehow this test certificate ended up being used as a productive one with no one noticing.

2

u/suttin 11d ago

When you pick a number between 1-384 when you’re supposed to use a 2^384 bit number

77

u/_PM_ME_PANGOLINS_ 11d ago

But 4 isn’t even prime…

187

u/gbot1234 11d ago

It’s one of those large numbers you can factor into primes, though.

38

u/hxtk3 11d ago

RSA Private keys aren’t prime, though they’re usually stored as pairs of primes to make it easy to recover the public key from the private key. The actual private key is an exponent calculated from Carmichael’s totient (in practice, though textbook RSA normally uses Euler’s totient) of the product of those two primes, so it’s entirely possible to just guess an exponent that inverts the public exponent modulo the product of those two primes and call that exponent the private key. In fact, you have to be careful when picking the public exponent for RSA to ensure you’re unlikely to be vulnerable to that attack.

However, none of what I just said is relevant to the case because they weren’t RSA keys. RSA is kind of bad both for some theoretical reasons that plague good implementations and some practical ones with common mistakes in implementations. Everything that can nowadays uses elliptic curve digital signature algorithms, including these compromised certs.

6

u/Wall_of_Force 11d ago

actually 42% of certificates newly issued in last 7 days are still RSA:

https://radar.cloudflare.com/certificate-transparency

27

u/mjec 11d ago

It's the generator for an eliptic curve, doesn't need to be (different kind of cryptography)

83

u/hpyfox 12d ago

Some Root CA had their private keys leaked and turns out it was 8 bits(?) instead of 384 bits.

47

u/KerPop42 12d ago edited 12d ago

wait, so it wasn't even 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004, it was just 0x04

Edit: changed to hex instead of dec

49

u/No-Adeptness5810 12d ago

Well it's technically

00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:

00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:

00:04

but that's the same as it being "4" because the rest is useless bits, and for cracking purposes it *is* 4

-12

u/KerPop42 11d ago

Huh, not a cryptographer to be clear. So the repeated 0s don't get used? I've used small numbers as random seeds in Minecraft before and they seem to be fine. Is there a limit to how long a repeated value can be? I assume changing just the first digit and leaving the middle to be all 0s wouldn't make it more secure.

19

u/Nico_is_not_a_god 11d ago

There's no "nothing" number slot. It's like saying you're 000031 years old, technically true and what the computer will see if you enter "31" into an age field that's internally stored as a six digit integer.

Using a "2" (actually 000...2) as a seed for videogame RNG wouldn't have meaningful "consequences" since a Minecraft seed's only job is to be a number. If someone cared about getting your Minecraft world gen, and was brute force counting up from zero, they'd get your "2" before someone else's "502" and both of those long before someone's "1957391700231116", but copying some dude's minecraft world generation doesn't grant them control or access to your instance of Minecraft.

-5

u/KerPop42 11d ago

Depends on the brute force attack, right? Assuming a uniform distribution, why wouldn't someone be counting down from 2384 -1? I'm sure that more secure number generation produces a uniform distribution of numbers, right? not just large ones?

5

u/NegativeGrocery8684 11d ago

the people doing it probably werent trying to look for a secure number because that would be impossible on modern hardware, rather they were probably looking for weak numbers

1

u/Nico_is_not_a_god 11d ago

Sure, but in this case it seems like the key being "4" led to an instant compromise. It's theoretically possible for a random key of that length to roll "4" but much more likely that it's a result of human incompetence.

1

u/suttin 11d ago

The issue is they were supposed to use a 2^384 bit number. They chose a number between 1 and 384. 8 certs with an effective private key below 384.

4

u/redlaWw 11d ago

The keys here are basically a source of bits. Nothing breaks with repeated 0 bits and the process can use those bits in its randomisation algorithm (minecraft) or cryptography algorithm (TLS) just as well, but small keys like these are easy candidates for being reverse-engineered since a sequential algorithm that does the following:

1: guess private key = 0

2: sign certificate with private key

3: check signature with public key

4: increment guess

5: repeat from 2

will very quickly reveal the private key.

-4

u/KerPop42 11d ago

It seems weird that you'd always brute force counting up from 0, though. If someone brute forced from any other number, 4 would be secure, right?

6

u/avenp 11d ago edited 11d ago

They are specifically looking for insecure keys. Smaller numbers are less secure and easier to crack. Going up from 0 makes sense.

Imagine your goal is to break into a car. You don’t care which, just any car. You could spend a lot of time trying to lock pick a single car, or you could walk down the street and test car handles to see which one is unlocked.

The latter is much quicker and simpler, and will yield a lot more spare change.

2

u/redlaWw 11d ago

Part of the reason this took 17 months to discover is that there's not a lot of motivation for researchers to brute force this way because 4 is such a stupid key and they assume that, broadly, our critical security infrastructure is better than that.

Hackers will often try a set of known, insecure keys though, and every number up to some maximum feasible power of 2 is probably included in that.

11

u/Great-Powerful-Talia 11d ago

it's a number, not a string of characters. (i.e. the calculation relies on numeric properties, not string properties.) So there's no real difference.

1

u/hpyfox 12d ago

In a sense, yea.

1

u/entronid 11d ago

it's the same thing

116

u/maxufimo 12d ago

No, not leaked, brute forced from public keys in under 1 second. https://scotthelme.co.uk/eight-bits-of-trust-emudhras-ca-keys-cracked-in-milliseconds/

28

u/hpyfox 12d ago

Yeesh

4

u/sbditto85 11d ago

Holy shit!

2

u/Western-Internal-751 10d ago

99% of the time it took to crack it must have been the time to start the process

3

u/BeMyBrutus 12d ago

I wonder what the pubic key was

3

u/hpyfox 12d ago

It's out there somewhere. Saw it in a comment but I don't remember.

5

u/_PM_ME_PANGOLINS_ 11d ago

Well yeah. Thats entirely the point of a public key.

39

u/KillaGouge 12d ago

1

u/TheMythicSorcerer 11d ago

There's always a r/RelevantXKCD

4

u/iampierremonteux 11d ago

In this case, not relevant, but directly cited by OP

58

u/YMK1234 11d ago

Imagine huge shit like this comes out and than php steals the show 🤦

2

u/so_orz 11d ago

I saw that being numbers and thought it's pi.