Acropalypse: a vulnerability in Google's screenshot editing tool
twitter.com
twitter.com
From https://twitter.com/David3141593/status/1636979466860744704
Also: you [can] do a basic check with tools like exiftool - it will report "Warning: [minor] Trailer data after PNG IEND chunk" on vulnerable images.
From: https://twitter.com/David3141593/status/1636981307891671041
There were no unit tests written for the original implementation, but they did update the tests for the refactored function [1], and the tests clearly show different behaviour from the original implementation [2].
My best guess would be that the code wasn't reviewed.
[1] https://cs.android.com/android/_/android/platform/frameworks...
[2] https://cs.android.com/android/_/android/platform/frameworks...
They should be doing a “mktemp; write; sync; rename”, which atomically and durably replaces the file in most linux file systems.
There might also be an exploitable race where you overwrite the file in place while it is being parsed, leading to undefined behavior in applications attempting to read the file.
Hyperbole like this is unhelpful. The reporter didn't think of it as a security bug, and the discussion in the bug itself is about API compatibility and documentation concerns.
Pretending in hindsight that we're all too smart to have ever missed this isn't helping software quality for anyone, and good postmortem analysis doesn't throw around words like "unforgivable".
Also, in practice, you and I and everyone here are absolutely dumb enough to do this. Hubris is another terrible postmortem technique.
My takeaway would be that they should have security-brained people screening "non-security" bugs, to check for potential security relevance.
Here's an example: the original change was a compatibility regression. Clearly there should have been a test of the original code somewhere that opened a file with "w" and validated that it was truncated per the documentation. And there wasn't. So one recommendation might be an audit of unit tests to verify that there's a process for getting from documented behavior to validated behavior.
And importantly, there's no need to "doubt" or "forgive" to do that.
Changing the behaviour of a file mode from truncate to not-truncate is a questionable decision because these are very explicit options a developer would carefully select, and therefore would not expect to see a change in behaviour to something already covered by a different option.
I work in finance and I can confidently say it would be at the top of my mind that this kind of change would result in leaking data or corrupting data because I regularly explicitly choose truncation to avoid exactly that when I generate new reports.
It's also ironic that you complain about hyperbole then accuse people of "pretending to be smart". You don't need to be smart to see this as a security issue, you just need some real world development experience.
Looking at the commit which changed this behavior: https://cs.android.com/android/_/android/platform/frameworks...
it seems like it was a refactoring gone wrong, and not a conscious decision to change the behaviour.
I'm surprised this wasn't picked up during code review. Also surprised no unit tests for the original implementation, just the new one - if you're going to refactor something, add tests for the original implementation if there aren't any already.
[1] https://cs.android.com/android/_/android/platform/frameworks...
[2] https://cs.android.com/android/_/android/platform/frameworks...
Yeah I always do the same and I'm happy to see I'm not the only one. And a CVE like these shows that we're the ones "not seeing things".
1. Using the cropping tool given when taking the screenshot (using the Markup tool in any other way does not work for me)
2. You have to crop at least 2 sides
Also, I'm not able to recover the rest of the image once it is put through Discord.
Ah, one commenter offered this:
"It looks like when the edits make the PNG smaller it saves the original number of bytes, overflowing its own buffer and leaving a bunch of unintended IDAT chunks to find :). Did you talk to Google about this before taking to twitter though?"
https://twitter.com/Bottersnike237/status/163689272301266534...
This thread provides a good overview and some sample images https://mastodon.delroth.net/@delroth/110043776803548821