Ok Google! bypass ‘flag_secure’

Google Assistant on Android 9 can bypass the screen-capture protection provided by Android’s FLAG_SECURE.

Vulnerability Details:

FLAG_SECURE is a window level flag in Android ecosystem that allows mobile apps to safeguard their content from a screenshot capture. Application needs to enable it by specifying the WindowManager.LayoutParams#FLAG_SECURE for the windows/screens, it doesn’t want to be recorded.

We observed that Google Assistant on Pixel devices, was able to capture screenshots even when screens were protected with FLAG_SECURE.

This is also important to know that MediaProjectionAPI in Android, allows an app to capture screenshots programmatically. Any rogue app using this API and with proper permissions would have been able to capture screen of the device when other apps are in-use.

NightWatch CyberSecurity has written a detailed post on FLAG_SECURE and MediaProjectionAPI. Google has some sample code on Github on how to use this API in capturing device screen in real time.

Testing Steps:

1. Install the Google Search app (https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox). Enable assistant.
2. Go to the settings for Google Search and enable screenshots under “General”. Also enable “Use Screen Context” option under “Google Assistant”, “Phone”
3. Open Chrome in incognito mode, press Power + Volume Down. Note that screenshots won’t work.
4. Now tap the home button and hold, and say “take screenshot” or “share screenshot” and google assistant will take screenshot bypassing the ‘flag_secure’ restrictions.

This was tested on Pixel 2 and Pixel 3 devices running Android 9.

03/12/2019 – Reported the finding through Google VRP
03/14/2019 – Google confirms the finding. Also tells us that it is a duplicate of an already tracked bug.
03/14/2019 – Asked when it will be patched and at what point we can disclose it publicly.
03/19/2019 – Received below response. Google recommended to check the status of the fix time to time.
04/30/2019 – I reached out to Google to know about the status of the fix and shared a draft write-up. No response from Google.
06/20/2019 – Asked again. No response.
08/30/2019 – Asked for a status update. No response.
04/14/2020 – Noticed that this finding was fixed in Android’s September 2019 bulletin and CVE-2019-2103 was assigned to this issue. I shared a modified write-up with Google and asked if CVE-2019-2103 is for the same vulnerability. I did not receive any response.
05/01/2020 – Published this blog post.

This was jointly discovered by Pankaj Upadhyay and NightWatch CyberSecurity.