Android系统无限重启漏洞
2022年,一次偶然的机会,我发现了一个会导致Android系统无限重启致使设备完全不可用的高危漏洞,遂提交给了Google。当年11月的AOSP补丁对此进行了修复,本文是我提交漏洞报告的原文,现公开,待整理。具体可以在Android Security Bulletin—November 2022中搜索CVE-2022-20414了解更多。
最后有幸上了Google官方的致谢名单:Android 安全性致谢 2022,也算是为这破碎的世界做了一点贡献吧。
Report description
In a few words describe your bug. This will help you search for it later.
The “snoozeNotification” method of NotificationListenerService causes Android system to crash and cyclic reboot.
Bug location
Which product or website have you found a vulnerability in?
Android
The problem
Please describe the technical details of the vulnerability
Starting from Android 10, there is a change about AlarmManagerService
and we can check the commit in AOSP: Adding a per-uid cap on concurrent alarms. A Google engineer added a piece of code to AlarmManagerService
:
1 | void setImpl(...) { |
For any package, if the current number of alarms exceeds 500, an UnsupportedOperationException
will be thrown and cause the process to crash, even if it is a system process.
In general, we do not have permission to set alarm for Android system processes. But let’s take a look at another piece of code that can be implemented by any third-party application:
1 | class TestCrashService : NotificationListenerService() { |
We can import android.service.notification.NotificationListenerService
and implement a subclass. A pending alarm is set by AlarmManager
when snoozeNotification
method is called.
You can run adb shell dumpsys alarm
to find the alarm like this:
1 | RTC_WAKEUP #164: Alarm{6975754 type 0 origWhen 1684207980006 whenElapsed 30672085209 android} |
If there are so many notifications being snoozing, an equivalent amount of pending alarms will be attached to the system process android
. It’s very dangerous because an exception is waiting for you before reaching the maximum limit.
Finally, the system crashes and is likely to fall into a loop of reboots. That’s where the vulnerability lies.
Please briefly explain who can exploit the vulnerability, and what they gain when doing so
I have to say that this is a very serious system vulnerability. For any application that implements NotificationListenerService
, as long as users allow notification access, it may cause Android system processes to crash, further causing the device to get stuck in a reboot loop and become unavailable.
We can find many apps designed to manage notifications on Play Store. They may use snoozeNotification
method to delay or eliminate notifications. If notifications are so many and snoozing duration is not short, there will be a risk of causing Android system to crash once the number of pending alarms reaches the limit.
In other words, someone with bad intentions has way to use this vulnerability to develop malicious applications that can blackmail others. For the average user, it is difficult to recover from this reboot loop.
Upload file
You can add a file to your report to provide additional information on the vulnerability. Max file size is 50MB.
……
The cause
Please specify the steps to reproduce the issue, including sample code where appropriate. Please be as detailed as possible.
Any application can cause a system crash in just two steps. The sample code has been included in a complete Android Studio project attatched below.
Step 1: Please allow notification access for the app. Then the implementation of NotificationListenerService
can be running.
1 | private fun startNotificationAccessSetting(context: Context) = try { |
And the subclass is simple like this:
1 | class TestCrashService : NotificationListenerService() { |
Step 2: Post a large number of notifications over 500 (MAX_ALARMS_PER_UID
).
1 | private fun step2() { |
Daily use will not have so many notifications appear at once, but day by day, this is chronic death for your Android device.
Specify the build fingerprint from the device used to reproduce the issue. The issue should reproduce on a recent build (within the last 30 days).
run adb shell getprop ro.build.fingerprint and adb shell cat /proc/version for kernel vulnerabilities
All devices based on Android 10+ (i.e. 10~13) have this vulnerability.
Provide a Proof of Concept, complete Android Studio project, source code including an Android.bp file, or similar artifacts.
You can also include a malformed media file, or a video walkthrough for UX issues.
……
Provide crash artifacts including stack trace (if available).
The crash can cause system zyote to die:
1 | 2022-05-27 16:35:11.453 1451-1451/system_process W/AlarmManager: Maximum limit of concurrent alarms 500 reached for uid: 1000, callingPackage: android |
HWASan output (if available)
……
Does anyone else know about this vulnerability?
- No, this vulnerability is private
- Yes, this vulnerability is public or known to third parties
How would you like to be publicly acknowledged for your report?
If your report is successful we will acknowledge you using this information in the next release.
It’s my pleasure.
What to expect
- You will receive an email confirming we have received your report
- The report will be sorted and added to the queue of reports
- A member of the team will review your report and determine if it is a valid
- During this stage it is common for us to contact you with questions about your report
- The report is then triaged and the details of the bug are supplied to the relevant team
- Depending on the bug we may take between 7 and 14 days to determine the bug’s severity
- If successful we will contact you to inform you of your reward
Comments
I have some suggestions as solutions:
- Hide the
snoozeNotification
method for app developers. - Alarms cannot be set for system processes by non-system processes.
- Don’t throw an exception for system processes when reaching the maximum limit of alarms, then we can delete the alarm with the longest duration before set a new alarm.
Assigned to as...@google.com.
Thank you for submitting this report. We’ve filed an internal report for the Android engineering team to investigate further (specified by the Android ID label). Please follow coordinated disclosure practices, such as keeping this report confidential until we have had time to assess your issue, and if necessary, release an update for Android devices.
PLEASE TAKE THE FOLLOWING ACTIONS NOW, if you have not already:
- Sign the Google Contributor License Agreement (1).
- In a comment below, let us know how you would like to be acknowledged (2) for discovering this potential vulnerability (including company affiliation, if any).
- Provide a PoC that reproduces against a recent Android build (not more than 30 days old).
The typical lifecycle for a confirmed security vulnerability is as follows:
- Initial severity rating assessment (subject to change after review by component owners) (3)
- Development of an update
- Assignment of CVE
- Shared under NDA, as part of coordinated disclosure, to Android partners for remediation
- Release in a public Android security bulletin
- Android Security Rewards payment (if applicable)
Most of these steps will typically be communicated in the sidebar. Please note that we may not reply to requests for status updates or information, however we will continue our typical assessment and remediation efforts. This issue will be updated with information once the reported issue is publicly fixed, if not prior.
Thank you,
Android Security Team
(1) Contributor license agreement: https://cla.developers.google.com/clas
(2) Android Security Acknowledgements: https://source.android.com/security/overview/acknowledgements
(3) Android severity guidelines: https://source.android.com/security/overview/updates-resources.html
Thank you for your reply. ACTIONS DONE:
- I have signed the CLA for only myself.
- If my work can help improve AOSP, it’s an honor for me to be acknowledged. I want my information to be displayed like this: Sylvester Yao (姚圣禹, blog.ysy950803.top)
- The PoC is an Android Studio Project including source code and APK. Please download the attachment.
Hello,
Thank you for the additional information as well as your acknowledgement. We will be following our standard investigation and remediation process with this report and ask for your continued confidentiality while we work on this issue.
Thank you,
Android Security Team
Hello,
The Android security team has conducted an initial severity assessment on this report. Based on our published severity assessment matrix (1) it was rated as High severity. This issue has been assigned to the appropriate team for remediation, and we’re targeting a fix for release in an upcoming Android Security Bulletin. We will provide an update on remediation status as it becomes available. We ask for your continued confidentiality as we proceed with our standard investigation and remediation process.
Thank you,
Android Security Team
(1) Severity Matrix: https://source.android.com/security/overview/updates-resources#severity
Thanks for your efforts!
I will continue to follow this issue and support you in any way I can.
Hello! How is the progress?
Hello,
Thank you for following up! This issue has been fixed and is targeted for release in an upcoming Android Security Bulletin. It will be reviewed for both a CVE and reward eligibility under Android Security Rewards Program rules closer to that time (1). Further details will be provided here when available.
Thank you,
Android Security Team
(1) https://www.google.com/about/appsecurity/android-rewards/
Congratulations! The rewards committee decided to reward you USD $5,000 for reporting this High severity vulnerability. We are paying for the bug report and proof of concept.
To collect the reward, if you haven’t already, please complete the Android Contributor License Agreement for Individuals, so we can use your test code:
https://cla.developers.google.com/clas
You will receive an email with details on the next steps to collect the reward.
Thank you for your contributions to the safety and security of the Android ecosystem.
Best Regards,
Android Security Team
Thank you for your hard work, I am honored to contribute to the Google ecosystem.
Hello,
We will be releasing a patch for this issue in an upcoming bulletin. It will first be released to partners, then to the public the following month.
If you haven’t already, please complete the Google Contributor License Agreement for Individuals, so we can use your patch and test code (1).
We’d also like to recognize your contribution on our acknowledgements page (2). The acknowledgement information we have on record is “Sylvester Yao (姚圣禹, blog.ysy950803.top)”. Please let us know if it has changed.
We may also make this bug publicly accessible when the fix is submitted to AOSP. Please let us know if you would like to keep the bug private instead.
Your CVE ID is CVE-2022-20414.
Thanks,
Android Security Team
(1) https://cla.developers.google.com/clas
(2) https://source.android.com/security/overview/acknowledgements
Thanks for your work. Where can I see the fix code?
Hello,
This is targeted to be released in the November bulletin. Thank you for your continued engagement with the Android VRP!
Best,
Android Security Team