Remix.run Logo
▲ lirolero 2 hours ago

Genuine question, since I'm not very knowledgeable about this: why is using C for a PDF tool such a bad idea?

▲zamalek 10 minutes ago | parent | next [-]

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 an hour ago | parent | prev | next [-]

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 15 minutes ago | parent | prev | next [-]

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 an hour ago | parent | prev [-]

buffer overflow vulnerability in code dealing with user generated data and a complex file format.