security: disable allowBackup and add backup exclusion rules for sensitive data protection#3689
security: disable allowBackup and add backup exclusion rules for sensitive data protection#3689Dhakshin2007 wants to merge 17 commits intogoogle:masterfrom
Conversation
- Set android:allowBackup="false" to prevent sensitive user data (Firebase auth tokens, survey responses, GPS data) from being extracted via adb backup or cloud backup on compromised devices. - Add android:fullBackupContent and android:dataExtractionRules attributes pointing to new XML resource files (added in follow-up commits) to give fine-grained control over what gets backed up on Android 12+ (API 31+) and older versions respectively. - Add android:exported="false" to SettingsActivity which previously had no explicit exported attribute, defaulting to exported=true on devices running Android < 12 when targetSdk < 31, allowing any app on the device to start the Settings screen.
Adds fullBackupContent rules (Android 11 and below) to exclude sharedpref, database, file, and external storage from adb and cloud backup. This prevents extraction of Firebase auth tokens, survey responses, and GPS coordinates from compromised devices.
…tion Adds dataExtractionRules (Android 12+/API 31+) to exclude all app data domains from both cloud backup and device-to-device transfer. Prevents extraction of Firebase auth tokens, survey data, and GPS coordinates on modern Android devices. Completes the backup security hardening started in the previous commit alongside backup_rules.xml (Android 11 and below).
andreia-ferreira
left a comment
There was a problem hiding this comment.
thanks for addressing this! There are still a couple of minor issues (see comments below). Running ./gradlew checkCode locally should help ensure everything is formatted correctly before pushing changes
Co-authored-by: Andreia Ferreira <51242456+andreia-ferreira@users.noreply.github.com>
…iewer feedback Formatted the application tag attributes for better readability.
|
Thanks for the detailed review @andreia-ferreira! I've addressed all the feedback:
Let me know if there's anything else to fix! |
…eckstyle RegexpHeader Updated copyright year from 2024 to 2026.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3689 +/- ##
============================================
+ Coverage 67.95% 67.96% +0.01%
- Complexity 1633 1634 +1
============================================
Files 369 369
Lines 9267 9267
Branches 1184 1184
============================================
+ Hits 6297 6298 +1
+ Misses 2322 2321 -1
Partials 648 648 🚀 New features to boost your workflow:
|
andreia-ferreira
left a comment
There was a problem hiding this comment.
the emulator tests are failing due to a missing Google Maps API key. The MAPS_API_KEY needs to be configured in your fork's repository secrets for CI to pass
…ation with other application attributes
…cation attributes
|
Fixed the indentation issue — all three new attributes ( |
|
@andreia-ferreira Thanks for the feedback! I wanted to clarify the This is by design to prevent malicious PRs from extracting sensitive credentials. When a PR originates from a fork, GitHub Actions only has access to the PR author's fork secrets, not the upstream repository's secrets. To resolve this, the The security and functionality changes in this PR are complete and tested locally — the CI failure is solely due to the missing upstream secret, not any code issues. Would it be possible for a maintainer to add the |
The key is already configured on this repository's secrets. But indeed GitHub Actions doesn't expose repo secrets to workflows triggered from forks. Since the workflow runs in the base repository's context, adding the key on your side wouldn't have helped either, I didn't realize that earlier, apologies for the confusion! I'll open a follow-up issue to address this so fork PRs aren't blocked by this check going forward. Since this is a low-impact change, I believe it's safe to override the check and merge on our side. I don't have the permissions for that though. @shobhitagarwal1612 would you be able to help with the merge? |
|
Hi @andreia-ferreira, this PR is now in a clean mergeable state:
The fix is production-ready and safe to merge directly. This addresses a real security concern (Firebase tokens, GPS data, survey responses being backed up to cloud/adb without user consent). Please consider merging it directly it's a low-risk, high-impact fix that benefits all users. Would appreciate it if you could re-review when you get a chance. Happy to make any additional adjustments needed. |
Problem
The app currently has
android:allowBackup="true"inAndroidManifest.xmlwith no backup exclusion rules defined. This means all app data is automatically included in Android cloud backup and adb backup, including:An attacker with physical access to the device, or a malicious app on a rooted device, could extract this data via:
Additionally,
SettingsActivityhad no explicitandroid:exportedattribute, defaulting toexported=trueon pre-Android-12 devices with older targetSdk, allowing any app on the device to launch it directly.Solution
This PR makes the following changes:
1.
app/src/main/AndroidManifest.xmlandroid:allowBackup="false"to prevent unrestricted backupandroid:fullBackupContent="@xml/backup_rules"(Android ≤ 11)android:dataExtractionRules="@xml/data_extraction_rules"(Android 12+)android:exported="false"toSettingsActivity2.
app/src/main/res/xml/backup_rules.xml(new file)sharedpref,database,file, andexternaldomains from adb/cloud backup for Android 11 and below3.
app/src/main/res/xml/data_extraction_rules.xml(new file)cloud-backupanddevice-transferfor Android 12+ (API 31+)Testing
adb backupno longer extracts app data after this changeFileProviderconfiguration infile_paths.xmlReferences