iOS 14.6 device hacked with a zero-click iMessage exploit to install Pegasus
twitter.com
twitter.com
Oh that's bad.
There has not been a single known bug granting persistent loading across a reboot since iOS 9.
In this case however, It wouldn't have been sufficient as the virus will reinstall quickly through the command center. If not data for a tracked device show up after a set timeout, the command center will resend a corrupted iMessage to reinfect.
In all case apply security update asap and regularly, they imply reboot and patch as much exploit as possible.
Can you explain what you mean? Can you clone/simulate an Apple device?
I am not sure rewriting iMessage in rust would be the answer, but it would be a start. Another start would be to refuse to sell iPhones to Israel as long as they do this.
The key to user satisfaction isn't security, it's consistent marketing reminders of "security".
Apple users here are often forced into the ecosystem due to iOS or safari dev, but the majority of Apple users care more about the name of the iPhone than performance. This is the nature of Veblen goods.
On the business end, sure.
But https://support.apple.com/en-us/HT201222#:~:text=the%20previ...
The assumption has to be that Apple quietly fixes minimum a hundred times more security bugs in their products, than the ones the occasional Project Zero blog post highlights.
For example, Java is also memory-safe, but Java doesn't have first-class array slices.
What part of scanning through some immutable array of bytes to-be-parsed would be so definitively better in Rust?
Any sensibly written parser code would result in the compiler optimizing away all reference count operations. Only the most naive ARC implementations mutate the count for every reference pass implied by the source.
So again... why would it be a sensible choice to use Rust at Apple, where they created and use Swift heavily? Where the problem is that they're using some old unsafe parsing library instead of one written in a safer language?
We know that they are because they've posted job descriptions for Rust-specific jobs.
Unfortunately it means there are always performance cliffs: you make some change to your code that looks innocuous and suddenly your performance collapses (e.g. because a function is now too big to be automatically inlined, so certain optimizations don't work anymore) --- and you don't understand why.
In this vein, both Swift and Rust performance will succumb to any number of their IL-level (and LLVM's IR-level) optimizations being disabled by some seemingly orthogonal change to the source code.
Either way, I hope Apple (and others) can squash this entire category of bugs soon!
Consider any long-lived complex library. Count the bugs fixed since initial release. That’s your baseline — you can expect that order of magnitude of bugs in the initial release of your rewrite. Perhaps a new language will eliminate some classes of bugs, so maybe you can cut that number in half or even to a quarter. But you need to come to terms with that number. Now add on the number of bugs due to compatibility. Image formats generally are not tightly spec’ed, meaning the de facto standard libraries become the de facto standard — that is, the library being rewritten.
Rewrites are a long road that starts off one step forward and three steps back. It could sill be worth it, depending on the case. But an effort to “rewrite in rust” that doesn’t account for this will fail.
My point was that the test suite you start with for your rewrite will be (or at least should be) a lot better than the test suite you had when you started writing the original code.
The spec will likely be better too. Also, you can learn a lot from the previous iteration.
These effects, plus the benefits of the new language, have the potential to reduce the bug count dramatically. Maybe even by an order of magnitude.
Having said that, you're certainly right that there are some steps back and the net cost or benefit is likely highly context-dependent.
It would be great to have more data on projects that have done this, to help people estimate the costs and benefits in their context.
Writing image decoders for several formats is hard but it's not so hard that a trillion dollar company can't write a good one.
Anyway, Apple's safe language is Swift, which they are clearly pushing and using more of as time goes by.
But also missing the point that you can't implement a subclass or what have you in rust, and if every interface you have is C then you have an exercise in mass unsafe code.
> doesn't have a path to interact with any language other than C
> so new code in existing libraries may not be feasibly written in rust
Not sure exactly what you mean here.
...This blog post discussed three improvements in iOS 14 affecting iMessage security: the BlastDoor service, resliding of the shared cache, and exponential throttling. Overall, these changes are probably very close to the best that could’ve been done given the need for backwards compatibility, and they should have a significant impact on the security of iMessage and the platform as a whole.
https://googleprojectzero.blogspot.com/2021/01/a-look-at-ime...
"It also indicates that Apple has a MAJOR blinking red five-alarm-fire problem with iMessage security that their BlastDoor Framework (introduced in iOS 14 to make zero-click exploitation more difficult) ain't solving."
And:
"BlastDoor is a great step, to be sure, but it's pretty lame to just slap sandboxing on iMessage and hope for the best. How about: "don't automatically run extremely complex and buggy parsing on data that strangers push to your phone?!"
Only run the known dodgy parsing code on stuff coming from people in your contact list, not just on any random image that comes in.
On incoming message, check one thing and one thing only: is the sender in the contact list? If YES...
+ Run the message through BlastDoor and continue as normal.
If NOT…
- Stop all non-essential parsing immediately.
- Continue with a flow similar to modern e-mail clients (To increase your privacy, we have blocked some elements of this message).
- Only continue normal message parsing if the user explicitly consents.I remain highly skeptical of any messaging app or communication chat program, email client that lets people "embed" arbitrary content in it.
Will that be the future on client devices as well given kernels are just too complex to secure perfectly?
Isn't inheritance to create hierarchy enough? why?
Node
SubNode1 SubNode2
SubNode1.1 SubNode2.1However, I suspect parsers for big objects like images tend to have more vulnerabilities because developers try to avoid copying data, for performance reasons. Many memory-safe languages have their own performance issues, or make it hard to avoid copying bulk data, so those languages aren't a great fit.
This makes Rust a particularly good choice for writing parsers: Rust is pretty strong at supporting complex data sharing patterns while remaining memory-safe.
Don’t load them into memory, parse them as a stream byte-by-byte in accordance with the standard for the codec, check every offset before seeking, and reject images that don’t conform to the standard.
And of course, a ton of fuzzing to accompany it.
Also, maybe I'm wrong, but when I read "image parsing" I think that actually means "image decoding".
In environments where you’re prioritizing performance I’d still argue streams are likely your best bet when the size of the file to be parsed is not a constant. You wouldn’t want to load 50 large files into ram on a server environment let alone a phone.
If your input buffer is a bunch of tiny 10 KB files and you trust them? Sure, load them into memory and access their indices on the stack. Make sure you reuse the buffer to avoid unnecessary allocations.
If you want parallel processing with zero-allocations then streams with an array pool for their backing buffer are the best bet.
Not loading arbitrary files into memory will always be safer than doing so.
As for decoding - I believe the functions for validating if an array of bytes is an image should be far removed from the decoding and presentation of those bytes to the frame buffer. You don’t need to decode a JPG to validate that a file is a JPG. It either conforms to the standard or it doesn’t; the pixel data is irrelevant.
The goal is never just security.
E.g. for a Web browser like Firefox the priority has to be to be as fast or faster than the competition, THEN be secure. That's just the reality of what users care about. If the goal was just security we'd all have been using HotJava for the last 24 years.
The goal for Rust was performance plus safety. That's pretty hard to pull off.
> You wouldn’t want to load 50 large files into ram on a server environment let alone a phone.
mmap() works pretty well here.
> As for decoding - I believe the functions for validating if an array of bytes is an image should be far removed from the decoding and presentation of those bytes to the frame buffer. You don’t need to decode a JPG to validate that a file is a JPG. It either conforms to the standard or it doesn’t; the pixel data is irrelevant.
Yeah but in a browser for example you never want to just "validate" an image file, you want to decode it, and separating validation from decoding is just asking for trouble. That is the meaning of "parse, don't validate".
It’s still probably going to be wrong for a complex grammar, even if it’s not going to literally crash. Bratus et al did a survey of PDF parsers a few years ago and iirc all the popular ones were wrong in ways that don’t necessarily correspond to memory errors (like infinite looping).
> This makes Rust a particularly good choice for writing parsers
In particular, Rust has ADTs, which is the main feature I advocate for this.
Broadly, because by necessity you're dealing with untrusted inputs in a relatively complex format. The complexity leaves room for bugs in how you handle the input and the user supplied data provides an easy way to feed malicious inputs in.
Sure its easy to write a fast, standards compliant parser (assuming its not a format like .psd or a word document), but it will choke on the multitude of dodgy versions of files out there, causing complaints
_most_ users only care about the picture/sound/video/other viewing correctly, with security a distant second. (they expect it to be secure) so pressure is on to make the parse work with everything.
At an ancient job, we did a lot of scraping content from HTML as the de facto input source. Each content provider had to have custom code written, and it was as bad as you would expect. XML came about, and its largest advantage was that invalid input was broken, and must be rejected as such.
The JPEG core format is complicated, but JPEGs in circulation today are simply nightmarish. They can include XMP, EXIF, and ICC data, plus a good dozen of other extensions that may actually affect how the JPEG is displayed. For example, knowing if a JPEG contains CMYK data depends on an Adobe extension with is about twenty years old. These extensions are in use today in images published in the web. So, just to display an image, one needs a parser for the image format, a parser for ICC, a parser for XMP, a parser for that obscure Adobe extension from twenty years ago, and so on. Often, each of them has its own library and represents decades of developer time. It's a lot of space for bugs and exploits.
1. Exploitation inherently relies on malicious input data.
2. In computer systems, any input data (especially in human-facing systems) is not logically useful to the software until parsed.
3. Thus, a parser is the first software element which systematically interacts with the input data. It is the prime exploitation target.
That, + parsing complex data is just kind of hard to get right. If iMessage was UTF-8 only, this would not be an issue I'm sure.
Because VIP users include people who run big-tech. Ask Bezos if it's worth fixing bugs that only target VIPs.
Or is there also a Pegasus V2, V3, etc that plays catchup with OS's security patches?
It's been around with zero-click exploits for years, and apparently even now, after their big iMessage "security" rewrite with iOS 14. Very likely that they have other entrypoints as well though.
[1] https://www.wired.co.uk/article/jeff-bezos-phone-hack-mbs-sa...
It is NSO running these operations. They are directly implicated in whatever their malware ends up doing.
Is it not clear that at least Apple must be involved in this too? Who else is?
I've been there done that. It's how we pretty much kept Wii homebrew available consistently throughout the console's life. We had the next exploit ready before Nintendo patched the current one.
Apple isn't involved. NSO are just good at their job.
The whole operation is incredibly sophisticated—this report [0] by Amnesty International is a great read. They also constantly upgrade their infrastructure—for example, they have at least -four- major versions of their C&C infrastructure, which they dub the "Pegasus Anonymizing Transmission Network". :(
[0]: https://www.amnesty.org/en/latest/research/2021/07/forensic-...
Is there any evidence for that because my perception is it has become much harder to exploit systems.
Any sufficiently funded group will find the zero days they need to exploit the users they want. It's not even a question of if they will find it, or when they will find it. They will find it and they will use it for unethical means.
This whole situation is hopeless until we go back to the basics and build systems from the ground-up with security in mind rather than trying to slap band-aids on architectures that were developed when computer security didn't even exist as a serious concept.
So no what Rapid7 is saying doesn't mean it's getting worse. Also they sell offensive penetration testing software, they have an interest in making your believe it's getting worse.
Is it too expensive in terms of performance, or time spent digging through the guts of ancient code? Is there some inherent property of the low level functions that require unsafe code?
For example, it has been established that it's illegal to export munition or strategic resources to designated Hate/Terrorist groups.
BlastDoor is a great step, to be sure, but it's pretty lame to just slap sandboxing on iMessage and hope for the best. How about: "don't automatically run extremely complex and buggy parsing on data that strangers push to your phone?!"(I do think they should be more cautious though. For example, under no circumstances should Apple Mail ever auto-extract an attached zip file from a stranger.)
(It's just as likely they have nothing to do with it, I'm just getting out in front of the eventual iMessage leak that Tim Apple gave the plan a thumbs up emoji)
Please tell me this daemon isn't named after what I think it's named after.
https://www.amnesty.org/en/latest/research/2021/07/forensic-...
I guess human rights don't line up with corporate values.
https://arkadiyt.com/2021/07/25/scanning-your-iphone-for-nso...
Maybe they should have enabled secure deletion: https://www.sqlite.org/pragma.html#pragma_secure_delete
https://www.amnesty.org/en/latest/research/2021/07/forensic-...
Although now that the cat is out of the bag, I'm sure some groups are working to reproduce it for mass-infection. Especially since this looks wormable.
Avoid using videoconferences except for journalism.
Better if you use a custom build ROM for Android from the sources and then flash your phone.
Even better: get a little netbook, the most compatible with OpenBSD. Encrypt your whole SSD with bioctl and use pledge(4) and unveil(4)ed browsers.
Use text browsers as much as you can, with a good hosts file. If you need JS, choose some browser such as vimb where you can set 3rd party cookies and JS ondemand with a switch.
Use Links+ (links -g for graphics) with Tor (the proxy settings has a Tor checkbox, set 127.0.0.1:9050 for Socks4a proxies AND MARK that checkbox). Go to the Links+ settings and save them from the menu. In order to do the same for i2pd, run Links+ with different setting on the command line to override the saved Tor settings. Basically you need to set all proxied conns through 127.0.0.1:4444.
If you trust your partner, use Email+GPG over I2PD (i2pd is the daemon). Alpine/Mutt + GPG is difficult, but Claws-Mail has some PGP settings and it's lightweight enough. OFC if you learnt to use s-nail+fdm+smtpd over I2PD (doable), then that's ok.