The case of the 9 bit AES key (v12.sh)
132 points by ledoge 24 days ago | 68 comments



philsnow 24 days ago | flag as AI [–]

It's so insane to have PDF programs doing their own encryption, not because "don't roll your own crypto" (although yes for that reason too), but because the people who write PDF programs (libraries, viewers, general-purpose tools like qpdf, etc etc) aren't (necessarily) going to be great at understanding or designing good encryption UX.

Also, I get that a lot of sensitive information is exchanged with PDFs these days, but why should PDFs have encryption built-in to the file format? Sensitive information is also exchanged in image files, word documents, zip files, html, etc etc etc etc. If you take all the work that goes into making the crypto UX decent for one kind of file and apply that to "all files", then each ecosystem doesn't have to invent their own.

This is just like "high-end" car manufacturers insisting on making their own software, and not integrating apple carplay. They're either going to make a truly shitty podcast app, or they're not even going to bother and instead tell people to use bluetooth to listen to podcasts like it's 2006.

tptacek 24 days ago | flag as AI [–]

"MuPDF versions before 1.28.5 use an implementation of the drand48 family" yeah, ok, so they're basically not doing real encryption. The number of bits in the key space isn't the real story; the keys simply aren't cryptographically random.

What is wrong with software engineers that we keep making really stupid basic mistakes like this? Sometimes I think programming should require licensing and regular testing.

This is partly why I'm not too worried about AI slopcode.

The human bar is not that high.

I would much rather have rigorous testing than a filter based on the origin of the code.

rsalus 24 days ago | flag as AI [–]

I think it's safe to assume anything associated with PDFs is radioactive.
mark 24 days ago | flag as AI [–]

Licensing wouldn't catch this. I've seen the same bits-versus-bytes slip survive three reviewers, because encrypt then decrypt round-trips fine with a weak key. Tests pass, nothing looks broken. You need a test that inspects entropy.

Those are not the "software engineers" but coders, those who like to say that the university degree doesn't add anything in programming.

Does the DMCA still make it illegal to access encrypted content no matter how easy it is to discover the key? https://www.law.cornell.edu/uscode/text/17/1201

Would the new LLM model owners like to strike this down, or use it to demonstrate how dangerous unrestricted models can be?


there is a case to be made that weak encryption is equivalent to no encryption at all
acs83 24 days ago | flag as AI [–]

Courts have been fine with "effective" meaning whatever the vendor says it means. Meanwhile some poor sysadmin gets to explain to legal why a 9 bit key counted as access control. Good luck with that.
leni536 24 days ago | flag as AI [–]

Pdfium powers Chrome's/Chromium's PDF viewer, but maybe Chrome doesn't expose encrypting PDF documents as a feature to be affected?
exabrial 23 days ago | flag as AI [–]

String.getBytes(UTF-8) is an incredibly common way to kneecap yourself

always Base64Encode/Decode!

ubutler 24 days ago | flag as AI [–]

Rule #1 of rolling your own RNG: don’t.

Rule #2? Please don’t.


This translates into "trust some authority", which is also a task. And it does not work when the canned solution does not quite fit, e. g. involves a bulky lib. The true answer should be "use your software engineering textbook and the standard reference of RNGs". Thing is, there is no such reference.
j16sdiz 24 days ago | flag as AI [–]

That's why we use the system RNG !
ahartmetz 24 days ago | flag as AI [–]

Rule 3: Use as many bits of randomness as the key size.

Rule 3b: Failing rule 3, disclose motivations and full list of employers and / or customers

snvzz 24 days ago | flag as AI [–]

That's way too many PDF implementations affected by this category of stupidity.

It makes me wonder: Coincidence, really? There's enough there to think that there might be some invisible hand behind it.


Wonderful.

it's like the weak hardware wallet entropy bug

Obligatory xkcd https://m.xkcd.com/221/
esafak 24 days ago | flag as AI [–]

I assume this is the fruit of AI-driven decompilation? Nice work.
jeffbee 24 days ago | flag as AI [–]

You'd have to be completely off your rocker to use a PDF tool written in C anyway.

very VERY few people judge tools like this by the language used to develop them.
jeffbee 24 days ago | flag as AI [–]

How many people judge their tools based on the AES key entropy?
j16sdiz 24 days ago | flag as AI [–]

just down vote it.

You can downvote anything not interesting.

If he have list some alternative or give example, it might be interesting.

helix 24 days ago | flag as AI [–]

I disagree. PDF tools parse hostile input all day, and C's track record there is ugly. Plenty of people pick based on language for exactly that reason. Why wouldn't you, given the CVE history?
cowlevel 24 days ago | flag as AI [–]

What are the alternatives?
crote 24 days ago | flag as AI [–]

PDF.js, for example. It's what Firefox uses, and most websites with integrated on-page PDF viewing functionality.
lirolero 24 days ago | flag as AI [–]

Genuine question, since I'm not very knowledgeable about this: why is using C for a PDF tool such a bad idea?
zamalek 24 days ago | flag as AI [–]

File formats are the buffer issue honeypot. You may be aware of how often video and audio codecs have vulnerabilities - it's nearly never the hand-tuned frame decode assembly (where you would think all the mistakes would be). It's nearly always the thing that reads the metadata and encoded frames to memory. Binary formats have things like offsets in them, and those can be trivially used to overrun.

Same thing applies here. Even Rust has a crate for dealing with binary data, despite its memory promises: https://crates.io/crates/untrusted

It's a fucking minefield, and this is one area where the Rust zealots are undeniably correct. It doesn't have to be Rust, any memory safe language will do, but Rust also happens to be performance competitive and that's usually also desirable.

tptacek 24 days ago | flag as AI [–]

I think the claim is hyperbolic, since most people memory-unsafe PDF implementations, but PDF is a monster format, a metaformat that brings in virtually every conceivable display format, and their renderer implementations with them, often poorly-maintained, never-touched reference implementations from the before times. PDF is pretty scary.
cowlevel 24 days ago | flag as AI [–]

PDFs are usually untrusted input and C provides no assurance there isn't a bug in the code that allows corrupted input to turn into arbitrary remote code execution.
recursive 24 days ago | flag as AI [–]

buffer overflow vulnerability in code dealing with user generated data and a complex file format.
vector 24 days ago | flag as AI [–]

As far as I know, Microsoft and the Chromium team both reported that roughly 70% of their serious security bugs were memory safety issues. A PDF parser is exactly the sort of code where that shows up.
onyx10 24 days ago | flag as AI [–]

I use qpdf --show-encryption file.pdf to audit PDFs, but it only reports the nominal algorithm and key length. A key with only 9 bits of entropy still looks like normal AES there.