13 comments

  • philsnow1 day ago
    It&#x27;s so insane to have PDF programs doing their own encryption, <i>not</i> because &quot;don&#x27;t roll your own crypto&quot; (although yes for that reason too), but because the people who write PDF programs (libraries, viewers, general-purpose tools like qpdf, etc etc) aren&#x27;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 &quot;all files&quot;, then each ecosystem doesn&#x27;t have to invent their own.<p>This is just like &quot;high-end&quot; car manufacturers insisting on making their own software, and not integrating apple carplay. They&#x27;re either going to make a <i>truly shitty</i> podcast app, or they&#x27;re not even going to bother and instead tell people to use bluetooth to listen to podcasts like it&#x27;s 2006.
    • dingaling22 hours ago
      &gt; but why should PDFs have encryption built-in to the file format?<p>Because very few &#x27;end user&#x27; people know how to use en&#x2F;decryption. So it&#x27;s much easier to send them a familiar file and say &#x27;enter this password&#x27; than to have them searching the web to work out which arguments to pass to openssl. In a command line? What&#x27;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...
      • 17186274402 hours ago
        This should simply be an option in the context menu of the file manager. (And is on my Linux machine)
    • lmz22 hours ago
      Usually the desire is for some of the metadata processing to be reusable between the encrypted and non encrypted formats (&quot;like a regular file, just this data is encrypted&quot;). 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.
    • otabdeveloper416 hours ago
      &gt; but why should PDFs have encryption built-in to the file format?<p>So you could open encrypted documents on iOS and Android.
    • GoblinSlayer22 hours ago
      S&#x2F;MIME?
      • Avamander14 hours ago
        CDOC2, there are also other similar widely used encrypted container formats.
  • tptacek1 day ago
    &quot;MuPDF versions before 1.28.5 use an implementation of the drand48 family&quot; yeah, ok, so they&#x27;re basically not doing real encryption. The number of bits in the key space isn&#x27;t the real story; the keys simply aren&#x27;t cryptographically random.
    • somat1 day ago
      You could do what openbsd did and tie all the traditional weak psudorandom interfaces into a cryptographically secure one. it will still match the drand48() interface. I still don&#x27;t think I would use them for secure things but now rand() is actually random. <a href="http:&#x2F;&#x2F;man.openbsd.org&#x2F;drand48" rel="nofollow">http:&#x2F;&#x2F;man.openbsd.org&#x2F;drand48</a><p>Another pet peeve is when people use the rand() when they want hash() but I will leave that rant for another day.
      • hansvm1 day ago
        I&#x27;m interested in that rant (at $WORK we adopted hash() for almost everything, and I&#x27;m curious to hear other perspectives).
        • somat17 hours ago
          In my mind rand() (and friends) and hash(thing) (and friends) are almost the same function, with a very similar set of features required, the main difference is that rand() is non-deterministic and hash() is deterministic.<p>They are so close that people can and often do build rand() as &quot;internal state s = hash(s) return s&quot; (or similar). then other people, wanting that deterministic hash() behavior thus accidentally exposed, build entire worlds(literally) out of rand().<p>Another problem with this is that the rand() internals are opaque and unknown and can change without violating the spec. hash(), because it is supposed to be deterministic, usually has an exposed stable algorithm.<p>A specific example. At one job I found they were storing long term customer order archives encrypted where the key was a hash of the date, this in itself is a little suspicious but the archives were offline and physically locked up on site, so not too bad. The real wtf was that the encryption was done on a win98 machine with a perl script that was basically &quot;seed(date); key = rand(); encrypt(data, key)&quot;. expecting to regenerate the key if they ever wanted to look at the data. When I saw that I went &quot;I don&#x27;t know much about perl, but that does not feel stable&quot; and did a few checks. Sure enough the behavior of rand() could change depending on the operating system or even version. making the keys highly dependent on that exact win98 machine with that exact version of perl, I think they ended up using that machine to generate and store all used keys in a database so other machines could decrypt the archives.
          • lo0dot012 hours ago
            Encrypted with a key that is a date can be broken by iterating likely dates. Did they add the time up to milliseconds into it or just the date? Not sure if it matters
      • aidenn01 day ago
        Per the manpage you linked, openbsd&#x27;s behavior does not match the drand48() interface, since the drand48() interface requires determinism.
  • NelsonMinar1 day ago
    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&#x27; content. The two should not be conflated and yet so easily are.
      • greggsy1 day ago
        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.
        • nyargh23 hours ago
          Credentialism is not a solution, it will just get gamed too. Indian diploma mills and mega IT consultancies pump out thousands of &quot;qualified&quot; engineers every year.<p>Every hiring manager worth their salt has caught at least one completely incompetent applicant with a CV full of certifications.
          • GoblinSlayer19 hours ago
            Maybe certifications are different? A certified Electron engineer might just read the tutorial how to spend zero effort on apps.
    • asveikau23 hours ago
      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&#x27;t look deeply. This has been commented upon for years.
    • LeoPanthera1 day ago
      This is partly why I&#x27;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.
      • hansvm1 day ago
        What&#x27;s your method for implementing rigorous testing while using AI?
      • nyargh23 hours ago
        Testing doesn&#x27;t even need to be that rigorous for humans, it&#x27;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&#x27;re talking about testing of code, well &quot;tests can only prove the presence of bugs, not their absence&quot;
    • rsalus1 day ago
      I think it&#x27;s safe to assume anything associated with PDFs is radioactive.
    • HackerThemAll1 day ago
      Those are not the &quot;software engineers&quot; but coders, those who like to say that the university degree doesn&#x27;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&#x27;t care about programming and have no idea what they&#x27;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.
      • adrianN1 day ago
        You can get through a Computer Science degree with just a few thousand lines of code if you focus on theory courses.
      • thin_carapace1 day ago
        a small wonder the wunderkinds of computer science were at all capable given their lack of computer science degrees
      • gsich1 day ago
        one and the same
  • jburgess7771 day ago
    Does the DMCA still make it illegal to access encrypted content no matter how easy it is to discover the key? <a href="https:&#x2F;&#x2F;www.law.cornell.edu&#x2F;uscode&#x2F;text&#x2F;17&#x2F;1201" rel="nofollow">https:&#x2F;&#x2F;www.law.cornell.edu&#x2F;uscode&#x2F;text&#x2F;17&#x2F;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?
    • nextaccountic1 day ago
      there is a case to be made that weak encryption is equivalent to no encryption at all
  • leni53622 hours ago
    Pdfium powers Chrome&#x27;s&#x2F;Chromium&#x27;s PDF viewer, but maybe Chrome doesn&#x27;t expose encrypting PDF documents as a feature to be affected?
  • exabrial9 hours ago
    String.getBytes(UTF-8) is an incredibly common way to kneecap yourself<p>always Base64Encode&#x2F;Decode!
  • ubutler1 day ago
    Rule #1 of rolling your own RNG: don’t.<p>Rule #2? Please don’t.
    • Mikhail_Edoshin21 hours ago
      This translates into &quot;trust some authority&quot;, 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 &quot;use your software engineering textbook and the standard reference of RNGs&quot;. Thing is, there is no such reference.
      • 17186274402 hours ago
        &gt; Thing is, there is no such reference.<p>man encrypt works. info &#x2F;encrypt works too.
      • mik199820 hours ago
        Handbook of Applied Cryptography is a good reference for implementing classic cryptographic algorythms.
    • j16sdiz1 day ago
      That&#x27;s why we use the system RNG !
      • cowlevel1 day ago
        Be careful to use the cryptographic one, not rand(3)<p>And if you&#x27;re a sysadmin, be extremely careful when generating keys in VMs or embedded devices. They tend to overestimate their entropy sources - it&#x27;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.
        • saidnooneever1 day ago
          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&#x27;d really need to dig into that to find out :&#x2F;.<p>-object rng-random,id=objrng0,filename=&#x2F;dev&#x2F;null<p>or maybe just a file that contains 4 :O
      • flanz_101 day ago
        btw, the idea that the system rng isnt good enough, or &quot;runs out&quot; or whatever, is no longer true on pretty much every modern, widely used os.<p>btw... im sure there&#x27;s some legacy rng in windows or some shit that isnt good. read the docs but if it&#x27;s the blessed system rng, you&#x27;re probably fine!<p>although... i suppose if this is news to you (the person reading this), then you probably shouldn&#x27;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!
    • ahartmetz1 day ago
      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 &#x2F; or customers
      • timerol1 day ago
        Rule 3c: At least as many bits. Bits tend to not be as random as you think they are
  • snvzz1 day ago
    That&#x27;s way too many PDF implementations affected by this category of stupidity.<p>It makes me wonder: Coincidence, really? There&#x27;s enough there to think that there might be some invisible hand behind it.
  • Wonderful.
  • paulpauper1 day ago
    it&#x27;s like the weak hardware wallet entropy bug
  • RobotToaster1 day ago
    Obligatory xkcd <a href="https:&#x2F;&#x2F;m.xkcd.com&#x2F;221&#x2F;" rel="nofollow">https:&#x2F;&#x2F;m.xkcd.com&#x2F;221&#x2F;</a>
  • esafak1 day ago
    I assume this is the fruit of AI-driven decompilation? Nice work.
  • jeffbee1 day ago
    You&#x27;d have to be completely off your rocker to use a PDF tool written in C anyway.
    • advisedwang1 day ago
      very VERY few people judge tools like this by the language used to develop them.
      • jeffbee1 day ago
        How many people judge their tools based on the AES key entropy?
        • OptionX1 day ago
          A lot actually.<p>You&#x27;re confusing just assuming by default its enough for purpose rather than not caring at all.
      • j16sdiz1 day ago
        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.
    • cowlevel1 day ago
      What are the alternatives?
      • crote1 day ago
        PDF.js, for example. It&#x27;s what Firefox uses, and most websites with integrated on-page PDF viewing functionality.
    • lirolero1 day ago
      Genuine question, since I&#x27;m not very knowledgeable about this: why is using C for a PDF tool such a bad idea?
      • zamalek1 day ago
        File formats are the buffer issue honeypot. You may be aware of how often video and audio codecs have vulnerabilities - it&#x27;s nearly never the hand-tuned frame decode assembly (where you would think all the mistakes would be). It&#x27;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:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;untrusted" rel="nofollow">https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;untrusted</a><p>It&#x27;s a fucking minefield, and this is one area where the Rust zealots are undeniably correct. It doesn&#x27;t have to be Rust, any memory safe language will do, but Rust also happens to be performance competitive and that&#x27;s usually also desirable.
        • tialaramex1 day ago
          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&#x27;t our first rodeo, we have wrangled lots of file formats before, we should use a language purpose-built to do that safely.
          • zamalek1 day ago
            &gt; Rust is a general purpose programming language<p>I don&#x27;t understand how I hit the anti-Rust tripwire here:<p>&gt; My comment: any memory safe language will do
            • tialaramex1 day ago
              Not an anti-Rust tripwire. Just that WUFFS is the appropriate technology.<p>I like 4th edition D&amp;D but if you&#x27;re trying to make a story about nuanced inter-personal conflict in which there&#x27;s no actual violence it&#x27;s just not the right roleplaying system and so I&#x27;m not going to agree with your choice to recommend 4eD&amp;D as the system for the story &quot;Love and Jealousy in the Elven Forest&quot;<p>I&#x27;ve written a whole bunch of Rust, and hardly any WUFFS - but, I wasn&#x27;t writing code for Wrangling Untrusted File Formats and that&#x27;s very much what you&#x27;re doing in a PDF parser.
              • jeffbee1 day ago
                I am a big fan of WUFFS but some recent developments by people assisted by AIs writing format parsers in other languages has made me question whether it will be maintained or forgotten.
      • tptacek1 day ago
        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.
        • DonHopkins9 hours ago
          Plus the PDF file name extension has been co-opted as a censorship-safe shorthand for Donald Trump and the Epstein Class he&#x27;s protecting. Adobe must be totally pissed off about that.<p>You&#x27;re right, PDFs are horrible scary monsters who you should never trust.
      • cowlevel1 day ago
        PDFs are usually untrusted input and C provides no assurance there isn&#x27;t a bug in the code that allows corrupted input to turn into arbitrary remote code execution.
        • F3nd01 day ago
          Other than Ada&#x2F;SPARK, which languages can guarantee this won’t happen?
          • tialaramex1 day ago
            This trivially can&#x27;t happen in WUFFS. Forget RCE, WUFFS can&#x27;t even do a traditional Hello World program because (1) you can&#x27;t do I&#x2F;O in WUFFS and (2) the language doesn&#x27;t have strings.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;wuffs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;wuffs</a>
          • cowlevel1 day ago
            Very few languages can prevent you writing something like &quot;if(text == &quot;shibboleth&quot;) rootshell();&quot; but most languages don&#x27;t make it trivial to write accidentally.
          • mahemm10 hours ago
            Pretty much any memory managed language? Java, Go, Rust, Python, pretty much anything other than C&#x2F;C++ these days is memory safe for security purposes.
      • recursive1 day ago
        buffer overflow vulnerability in code dealing with user generated data and a complex file format.