r/ProgrammerHumor • • Oct 23 '26

Meme randomButNotRandomEnough

Post image
6.3k Upvotes

100 comments sorted by

1.6k

u/tiny_simulacrum Oct 23 '26 • Bravo

Don't worry, eMudhra learned their lesson. Now they run it between 1384 and 2384 .

406

u/AmanBabuHemant Oct 23 '26

they are now exiting from certificate issue business

168

u/ballheadknuckle Oct 23 '26

That business is a chain of trust at the core, and trust they have none.

84

u/razor_train Oct 23 '26

Well trust is a 4 letter word.   ...err, wait... 

14

u/Pedry-dev Oct 24 '26

None also has 4

58

u/Blurkid Oct 23 '26

Great solution ! Now people will brute force it from 1384

598

u/eruciform Oct 23 '26 • Bravo
function random() {
  // determined with a fair 2^384 sided die:
  return 4;
}

60

u/TheFrenchSavage Oct 23 '26

It's just more and more unlikely. Possible, but rarer as it goes.

14

u/Comfortable_Ad_6572 Oct 24 '26

Isn't it just as likely as getting any other number though? Like guessing is less likely as the range increases but getting any number should be just as likely as any other number in the range right?

Maybe I'm misunderstanding though, or just missed the joke altogether

9

u/Sibula97 Oct 24 '26

Technically it's just as likely as any other exact number, but you could ask, for example, what is the probability of N out of the 48 bytes being zeros. The mean is around 2, they had 47. The probability of even half of the bytes being zeros is mindbogglingly small.

1

u/LutimoDancer3459 Oct 25 '26

Yeah, just as small as any other combination of 1 and 0

0

u/Sibula97 Oct 25 '26

I'm not talking about a specific key, I'm talking about whole classes of them. If you get a 4 it's practically guaranteed you fucked up and didn't just randomly get a 4. The chance is small enough to not even be worth considering.

1

u/LutimoDancer3459 Oct 25 '26

If you run the algorithm and it spits out several keys in that range, you fucked up. Else, its just you getting "lucky".

1

u/Sibula97 Oct 25 '26

Nah, if you get anything smaller than a quardrillion as you key you should immediately start looking for the bug. The chance of that happening is about 1 in 2.5*10101. Even if you generated a billion keys a second for a billion years, the chance of getting just one key below a quadrillion is around 1 in 1076. It's just never going to happen. Even if you got every expert on Earth to check your code, it's still more likely to be buggy than you actually getting a 4 with a working algorithm.

0

u/LutimoDancer3459 Oct 25 '26

Just as with ANY other number... one in a specific range is just as possible as one in any other similar big range. If you get two or even more... than you should worry. And thats what happened here. 4 alone shouldnt worry you

-1

u/Sibula97 Oct 25 '26

Like I already said, we do 't care about specific numbers, where you'd be right. Numbers aren't equal. A very small key is easy to factor. Nobody cares whether your key is in the range of 1090-10100 or 10100-10110, which are indeed equally likely to the range 1-1010. A single 4 would be extremely worrying for something this critical.

→ More replies

16

u/EuphoricCatface0795 Oct 24 '26

Greetings, fellow xkcd reader

0

u/[deleted] Oct 23 '26

[deleted] — view deleted comment

2

u/SpaceCore0352 Oct 23 '26

If it's a die, the lower limit is 1 and the upper limit is 2384. The off-by-one only comes into it when zero-indexed.

2

u/lonelyroom-eklaghor Oct 23 '26

oh ic ic, thanks for this

I was talking about the meme, but then I realized what was the case

857

u/film_composer Oct 23 '26

Just because you have infinite monkeys eternally typing at typewriters doesn't mean that it must take eons for them to write Shakespeare. One of them could happen to get it right on the first try.

395

u/Forvisk Oct 23 '26

If you have infinite monkey one will definitely write Shakespeare on the first try.

344

u/The_DragonDuck Oct 23 '26

If you have infinite monkeys, an infinite number of monkeys would be writing Shakespeare on their first try

92

u/ggnngg5 Oct 24 '26

If you have infinite monkeys, no number of monkeys would be writing Shakespeare because I took all of your pens

62

u/Proximyst Oct 24 '26

Good thing the infinite monkeys are writing on infinite typewriters, not with pens.

7

u/Bored-TM Oct 24 '26

Who said they were writing physically and not digitally?

4

u/setibeings Oct 24 '26

Me. Those monkeys are on typewriters.

The hard part is filtering out all the garbage.

4

u/Puzzleheaded_Tap1040 Oct 26 '26

The hard part is strapping the to the chairs while not getting mauled. We lost an infinite amount of good man doing that

1

u/Thebenmix11 Oct 28 '26

Took an infinite amount of time too

1

u/LutimoDancer3459 Oct 25 '26

Ai increased hardware prices too much. Nobody can effort infinite pcs/phones/whatever digital medium for them to all write on. So it must be physical writing

13

u/ketosoy Oct 23 '26

If you have infinite moneys, an infinite infinite infinite infinite, malkovich malkovich infinite malkovich malcovich mallovich

9

u/Domy9 Oct 24 '26

Not necessarily. Infinite does not contain everything. There are infinite numbers between one and two, and none of them are 3. Of course this boils down the rule of what range are we defining for it, but monkeys randomly hitting a typewriter is not necessarily in the range of Shakespeare.

The monkey will have some sort of logic while button pushing, like buttons further on the keyboard from it's comfortable hand position will be pushed fewer, every button it pushes will probably be in a closer vicinity to the previous button it pushed, buttons at the centre will be pushed more than the sides, etc.

But of course if you say that the monkey will push buttons truly randomly like a machine and not a thinking creature, then yes there will be Shakespeare.

4

u/Alradas Oct 24 '26

Well, metrics like "probably" or "fewer" don't really matter when speaking of infinity. Even if only one in a billion monkeys even type a second letter, it's still an infinite amount of them that do.

But you are right: Infinite doesn't always have the same parameters. If for example the A key was busted, an infinite number of monkeys still would never type shakespear since it's fundamentally impossible to do that.

We need to assume that each letter could theoretically be typed (no matter how improbable), including non letters and special characters like spaces, commas and so on. Only then can we also assert that in all those infinite tries, an infinite number of them will produce perfect copies of any literature.

1

u/pm_me_your_smth Oct 26 '26

Except that randomly hitting typewriter is in the range of shakespeare. Even if some buttons are less likely to be pressed (as long as it's a non-zero probability), in context of infinity that doesn't matter. So your analogy of number sampling is inaccurate. A more accurate example would be: if you sequentially sample numbers 1 and 2 infinite times, is it possible that at some point you get a very long and exact string of numbers? Yes, it 100% possible.

1

u/Vogete Oct 25 '26

True, he was called Shakespeare.

8

u/Lucario1492 Oct 23 '26

you mean on the 4th try

2

u/personpilot Oct 24 '26

Didn’t they come to the conclusion recently that a monkey typing away forever would just infinitely spew out random garbage forever and never type Shakespeare?

22

u/yezhnuzjhd Oct 24 '26

If it's infinite then Shakespeare will be there. What is more, it will be there an infinite number of times.

225

u/BlueTexBird Oct 23 '26

Wasn't the story that they accidentally ran an RNG from 1 to 384 instead of 1 to 2^384? Lmao

218

u/BlondeJesus Oct 23 '26

Their private keys were between 0-255 and averaged at 127. People suspect they like just took the first byte of the actual key

61

u/Mechakoopa Oct 23 '26

The way the algorithm works you generally have a byte array and randomize each byte. They might have just not used their iterator index or something, they claimed it was a "bad algorithm" and they signed a faulty batch of certificates, but why they were rolling their own certificate generation algorithms is beyond me, the existing ssh libraries already do random properly. The trust in the chain comes from proper handling, not having better random numbers.

119

u/setibeings Oct 23 '26 edited Oct 23 '26 • Popcorn

If we want to be technical, it looks like they either ran a random number generator that returns an 8 bit value, or they somehow truncated a bigger value to just 8 bits. This is evident based on their 7 other keys that have been discovered, all less than 256.

https://arstechnica.com/security/2026/10/the-internet-goes-on-high-alert-after-discovery-of-8-compromised-tls-certs/

Edit: or they were just lazy and wanted private keys they could memorize.

17

u/Saragon4005 Oct 24 '26

Why would you want to memorize a root certificate key????? This is just as insane as the theory that someone was manually typing this into forms.

4

u/setibeings Oct 24 '26

A reasonable person would NOT want to memorize a root certificate. A reasonable person would also not set it to a 3 or 8 bit value.

11

u/GrandAlbatroce Oct 24 '26

Iirc these were test keys that were not supposed to go on production

5

u/LutimoDancer3459 Oct 25 '26

Even then, why would they be so small numbers? Why not ones that look like actual keys?

2

u/setibeings Oct 24 '26

Interesting. Do you have more information about that?

3

u/AlrikBunseheimer Oct 26 '26

Got it from the YouTube channel fireshiptv

1

u/GrandAlbatroce Oct 24 '26

Honestly, I just read it in passing, I dont remember the source

56

u/TuttoDaRifare Oct 23 '26

The probability is low, but not zero

27

u/MojitoBurrito-AE Oct 23 '26

It has the same probability as any other number.

14

u/hxtk3 Oct 23 '26

But there were eight all below 255, which is roughly 1 in a billion googol chance.

9

u/Stickhtot Oct 23 '26

So you're saying there's a chance

2

u/martifero Oct 23 '26

relevant Dilbert

1

u/giga207 Oct 24 '26

But even at 0, something still happens.

29

u/QuantenWitzbold Oct 24 '26

Did anyone mentioned the relevant xkcd-joke yet? https://xkcd.com/221/ 

14

u/Last8Exile Oct 24 '26
int RandomInt()
{
    start:
    var value = Random.Shared.Next();
    if (value != 4)
        goto start;
    return value;
}

9

u/InfluentialFairy Oct 24 '26

sinful recursion, labels should be abolished

3

u/anto2554 Oct 24 '26

Isn't it just a while loop? There aren't new frames being made

3

u/InfluentialFairy Oct 24 '26

It's just very poor practice. Functionally, this example, its "fine".

You will understand when you've seen large functions with dozens of goto statements, the execution step skips around in a way that becomes nearly impossible to follow statically.

It also doesn't help, that everything you can do with goto's, can be done without... in a much nicer and cleaner way.

1

u/Scarlet_Evans Oct 25 '26

goto Edit;

// let's hope it goes to the correct comments 

13

u/frikilinux2 Oct 23 '26

Is there test for eliptic curves?

For RSA you actually start with a one in the most significant digit, generate the rest and test for a bunch of low factors and then several rounds of probabilistic checks.

13

u/hxtk3 Oct 23 '26

ECDSA keys are just random numbers. There are few enough numbers in the key space that don’t work mathematically that you can just use rejection sampling until one works, but if you generate a random 384-bit number it has a very high likelihood of being a valid P-384 private key. Primes are sparse enough that you have to be careful how you generate them.

You could, in principle, run a bunch of statistical tests of randomness on your number and reject if it fails them, such as “it must have 48-52% 0s in its binary representation” but at that point you’re maybe getting a single stronger key but you’re systematically weakening your key generation process by rejecting mathematically valid keys.

1

u/frikilinux2 Oct 24 '26

Nice, one day I should probably try to understand the math of eliptic curves. Or maybe I should study lattices at this point.

1

u/csapka Oct 24 '26

just add the digits together and if it's above like 100 it's okay-ish

1

u/cpt-macp Oct 25 '26 edited Oct 25 '26

Fun Fact :

NIST P-256 which uses ECC was suspected as "sus" and some EU and CN companies don't use it thinking its having a backdoor by NSA ( Lot of tools marks its as "sus" also, lol)

y^2 = x^3-3x+b ( mod p )

b being a constant and NSA didn't explain how they came up with the constant. The seed used to generate the curve parameters was never explained by NSA.

To this date P-256 is widely used on ECDH and ECDSA are most widely used elliptic curve cryptography standard.

13

u/TechcraftHD Oct 24 '26

first mistake was running it from 1 to 2384 and not from 2370 to 2384 or something

13

u/ItsOmniss Oct 24 '26

When you return "i" instead of "key"

11

u/skeld_leifsson Oct 23 '26

Ask a LLM, it will return 17

4

u/colonel_vgp Oct 24 '26

But that 4 is randomly chosen by a dice roll.

3

u/-Redstoneboi- Oct 25 '26

a fair dice roll.

guaranteed to be random.

4

u/Euphorix126 Oct 24 '26

I mean, what are the odds?!

8

u/horenso05 Oct 24 '26

I have been on vacation for the last two weeks... can some explain the resent 4 and PHP memes? There was some vulnerability with 4 as a private key?

29

u/Nexinex782951 Oct 24 '26

Firstly these are two seperate incidents. They happened to be reported within hours of eachother.

The 4 memes comes from a set of (10?) private keys that managed to get into the main branch despite being only for testing. This renders a company which has served 60 million certificates that browsers and other services have trusted as deeply unsecure. Spoofable certificates of that type will be valid up to 2039. These private keys are mostly two digit numbers, and one of them is the number 4.

3

u/Saragon4005 Oct 24 '26

One of the root certificate authorities, you know the ones who vouch for all HTTPS trafic, used the private key of 4. Which by itself is excusable as we do expect it to happen eventually however they were then within moments found to have generated 7 more private keys all under 300

3

u/Honest_Relation4095 Oct 24 '26

4 is a random number.

2

u/Rebellion2297 Oct 24 '26

There is absolutely no way that this was the actual cause, the impossibility of getting a specific random number that many times in a row is the reason that private keys work. There must have been an error in the generator that caused unexpectedly low numbers.

3

u/Random_-account Oct 23 '26

Mine returned SYNTAX ERROR

2

u/Any-Set-1587 Oct 23 '26

isn't it 7?

2

u/balbinator Oct 23 '26

Or is it 6?

1

u/KatanaDelNacht Oct 24 '26

"The closer we are to danger, the farther we are from harm."

1

u/Even_Shallot6345 19d ago

maybe it just returned our api keys

-9

u/Important_Grab3544 Oct 24 '26

Hello, I am a native AI vibe coder, what does 4 mean? I do seven figures a year.

7

u/misteralter Oct 24 '26

1

u/Party_Estimate_6397 Oct 24 '26

That’s extremely relevant even for Randall… future sight?

5

u/ConcerningChicken Oct 24 '26

A Servic for Certificates created extremely weak certificates (think of it like a password wich is "esad83647hsgs73847..." but they just did "4" wich is easily to be found out which creates a big issue because if you can find out a certificate you can to pretend to be the holder of this certificate.

6

u/nikel23 Oct 24 '26

you'd think he understood what certificate even means. Just let him ask AI to explain since it doesn't even matter whether he understood it or not