News for hackers. Stuff that matters.
Re:Remote code execution affecting most iOS/macOS apps by legulere on Saturday April 08, 2017 @11:04AM (#14067242)
Media file parsers seem to get hurt regularly [1] and can get targeted easily. Maybe we should rethink something there.

[1] 210 CVEs containing JPEG https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=JPEG, 158 CVEs containing GIF, 127 CVEs containing PNG, and this covers just the common web picture formats.

Re:Remote code execution affecting most iOS/macOS apps by TazeTSchnitzel on Saturday April 08, 2017 @11:29AM (#14067383)
I think that's why Mozilla is replacing Firefox's parser for video (IIRC?) files with one written in Rust.
Re:Remote code execution affecting most iOS/macOS apps by i80and on Saturday April 08, 2017 @11:32AM (#14067397)
MP4 parser, specifically; it landed in 41: https://bugzilla.mozilla.org/show_bug.cgi?id=1175322
Re:Remote code execution affecting most iOS/macOS apps by shurcooL on Saturday April 08, 2017 @11:22AM (#14067342)
One choice people sometimes have is the language to implement parsers in.

Among other languages, I think Go is fantastic language for parsers. Great basic types to work with, no need to typedef uint64 long long, easy to parallelize parsing logic and use up multiple cores. Race detector and other static analysis will help verify there's no easy to spot issues, and good code review for the rest. Built in testing facilities make it trivial to create tests anyone can run and reproduce.

Finally, if you're still worried about a programmer error leading to a panic, can use recover at the top level to ensure that it would get caught. The HTTP server does that for user handlers, so that a panic in a user-written handler fails that single HTTP request, rather than taking down entire server. But need to do this in all goroutines that are at risk, not just the main one.

I would feel so much more comfortable and confident implementing or reviewing code for parsers in Go than C/C++. Because Go is so short on features and highly explicit, it's just so much easier to read the code and be fully confident it does the right thing, and nothing else.

Re:Remote code execution affecting most iOS/macOS apps by dom0 on Saturday April 08, 2017 @01:38PM (#14067997)
> Among other languages, I think Go is fantastic language for parsers.

While that may be true in a self-contained environment, a library simply can't drag an invasive runtime around: no one will use a format whose only implementation has that requirement (e.g. imagine libjpeg was written in Go - no one would bother with it).

So for general purpose libraries, like these mentioned by GP, there are much fewer options. One can try to write safe C (ideally using analyzers and only a subset of C), but we know how that usually turns out. One can try to write safe C++, which can be easier, but usually kinda isn't [because a lot of code is older than five years; I'd wager most C++ code is much older than both Go and Rust]. At this point in this HN comment we pretty much narrowed it down to Rust or perhaps D.

Re:Remote code execution affecting most iOS/macOS apps by matthewaveryusa on Saturday April 08, 2017 @01:33PM (#14067980)
It's unfair to compare a 2017 re-write in Go vs. C++ that's festered for 20 years. If you want to do apples-to-apples Go vs. C++, first you'll need to compare it to well written C++11 (no need to crop C in this.) C++ without raw pointers and references is pretty safe, just like Go with the unsafe package can be, well, unsafe.
Re:Remote code execution affecting most iOS/macOS apps by shurcooL on Saturday April 08, 2017 @04:08PM (#14068739)
I wasn't comparing with a 20-year-old existing C++. I was comparing how I felt about doing an implementation or code review of a parser in 2017 in both languages.