It's so insane to have PDF programs doing their own encryption, <i>not</i> 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.<p>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.<p>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 <i>truly shitty</i> 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.
> but why should PDFs have encryption built-in to the file format?<p>Because very few 'end user' people know how to use en/decryption. So it's much easier to send them a familiar file and say 'enter this password' than to have them searching the web to work out which arguments to pass to openssl. In a command line? What's that?<p>I received an AES-encrypted file recently but neither gnupg nor openssl could determine what mode and keysettings the sender had used, so it was just a useless lump of data. Very secure though...
Usually the desire is for some of the metadata processing to be reusable between the encrypted and non encrypted formats ("like a regular file, just this data is encrypted"). This is also why eg. Zip files are encrypted per entry, not globally.<p>Since the kind of data people want available may differ for each file format, here we are.
> but why should PDFs have encryption built-in to the file format?<p>So you could open encrypted documents on iOS and Android.
S/MIME?
"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.
We direly need to split things into a licensed engineering field which is necessary for working on security- and reliability-critical systems, and a generic unlicensed software developer field where people can screw around with their 1000 dependency JS frontends to their hearts' content. The two should not be conflated and yet so easily are.
Certification do exist for engineers, and various industries and governments impose their own certification programs on platforms and software before they’re authorised for use.<p>Each with varying degrees of trust. The outcome is never perfect, but that’s not their purpose.
Credentialism is not a solution, it will just get gamed too. Indian diploma mills and mega IT consultancies pump out thousands of "qualified" engineers every year.<p>Every hiring manager worth their salt has caught at least one completely incompetent applicant with a CV full of certifications.
One of the problems with cryptography implementations is that a bad one will be indistinguishable from a good one on the surface level. Totally broken crypto will superficially look and work as if it it works, and most people won't look deeply. This has been commented upon for years.
This is partly why I'm not too worried about AI slopcode.<p>The human bar is not that high.<p>I would much rather have rigorous testing than a filter based on the origin of the code.
What's your method for implementing rigorous testing while using AI?
Testing doesn't even need to be that rigorous for humans, it's easy to spot someone who is lying about the depth of their experience with a 15 minute conversation.<p>For AI this will be impossible, however.<p>If you're talking about testing of code, well "tests can only prove the presence of bugs, not their absence"
I think it's safe to assume anything associated with PDFs is radioactive.
Those are not the "software engineers" but coders, those who like to say that the university degree doesn't add anything in programming.
University degrees are not the difference between an engineer and a developer, universities have churned out millions of people who don't care about programming and have no idea what they're doing, who are just following the script with as little effort as possible because they were told it was the easiest way to make a lot of money.
You can get through a Computer Science degree with just a few thousand lines of code if you focus on theory courses.
a small wonder the wunderkinds of computer science were at all capable given their lack of computer science degrees
one and the same
Does the DMCA still make it illegal to access encrypted content no matter how easy it is to discover the key? <a href="https://www.law.cornell.edu/uscode/text/17/1201" rel="nofollow">https://www.law.cornell.edu/uscode/text/17/1201</a><p>Would the new LLM model owners like to strike this down, or use it to demonstrate how dangerous unrestricted models can be?
Pdfium powers Chrome's/Chromium's PDF viewer, but maybe Chrome doesn't expose encrypting PDF documents as a feature to be affected?
String.getBytes(UTF-8) is an incredibly common way to kneecap yourself<p>always Base64Encode/Decode!
Rule #1 of rolling your own RNG: don’t.<p>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.
> Thing is, there is no such reference.<p>man encrypt works. info /encrypt works too.
Handbook of Applied Cryptography is a good reference for implementing classic cryptographic algorythms.
That's why we use the system RNG !
Be careful to use the cryptographic one, not rand(3)<p>And if you're a sysadmin, be extremely careful when generating keys in VMs or embedded devices. They tend to overestimate their entropy sources - it's possible that every clone of a VM generates the same keys. In some cases (<i>cough</i> ECDSA) generating the same key <i>and nonce</i> to sign two different messages is catastrophic - it immediately leaks the private key.
good point about VMs. if you run some VPS your provider could just link in a shitty rng into the thing and not give access to the correct hardware rng. U'd really need to dig into that to find out :/.<p>-object rng-random,id=objrng0,filename=/dev/null<p>or maybe just a file that contains 4 :O
btw, the idea that the system rng isnt good enough, or "runs out" or whatever, is no longer true on pretty much every modern, widely used os.<p>btw... im sure there's some legacy rng in windows or some shit that isnt good. read the docs but if it's the blessed system rng, you're probably fine!<p>although... i suppose if this is news to you (the person reading this), then you probably shouldn't be implementing whatever you are that really requires prng. ask a friend for help. im not trying to be a jerk, i just want to make sure you dont hurt yourself!
Rule 3: Use as many bits of randomness as the key size.<p>Rule 3b: Failing rule 3, disclose motivations and full list of employers and / or customers
That's way too many PDF implementations affected by this category of stupidity.<p>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 <a href="https://m.xkcd.com/221/" rel="nofollow">https://m.xkcd.com/221/</a>
I assume this is the fruit of AI-driven decompilation? Nice work.
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.
How many people judge their tools based on the AES key entropy?
just down vote it.<p>You can downvote anything not interesting.<p>If he have list some alternative or give example, it might be interesting.
What are the alternatives?
Genuine question, since I'm not very knowledgeable about this: why is using C for a PDF tool such a bad idea?
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.<p>Same thing applies here. Even Rust has a crate for dealing with binary data, despite its memory promises: <a href="https://crates.io/crates/untrusted" rel="nofollow">https://crates.io/crates/untrusted</a><p>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.
The technology you want for this sort of work is WUFFS, for Wrangling Untrusted File Formats Safely.<p>Rust is a general purpose programming language, which is great if your problem might be something never imagined before, but this literally isn't our first rodeo, we have wrangled lots of file formats before, we should use a language purpose-built to do that safely.
I think the claim is hyperbolic, since most people memory-unsafe PDF implementations, but PDF is a <i>monster</i> 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.
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.
buffer overflow vulnerability in code dealing with user generated data and a complex file format.