Security: Prevent ADB Data Extraction and Encrypt Room Database (SQLCipher)#121
Open
zebauman wants to merge 1 commit into
Open
Security: Prevent ADB Data Extraction and Encrypt Room Database (SQLCipher)#121zebauman wants to merge 1 commit into
zebauman wants to merge 1 commit into
Conversation
- Disabled `android:allowBackup` in AndroidManifest.xml to prevent unauthorized data extraction via ADB. - Configured granular backup rules (`backup_rules.xml` and `data_extraction_rules.xml`) to explicitly exclude the database directory from system-level backups. - Integrated `net.sqlcipher.database` (SQLCipher) into the Room database module (`TaskDatabase.kt`) to encrypt data at rest. - Applied SupportFactory to `Room.databaseBuilder` to ensure user tasks are protected against physical extraction and local privilege escalation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the Vulnerability
While auditing the application, I discovered a compound security vulnerability regarding insecure local data storage. Previously,
android:allowBackupwas enabled by default without explicit exclusion rules. This allowed an attacker with physical access to legacy Android devices (or root access on modern devices) to extract the application's entire sandbox. Because the Room database was utilizing the default SQLite implementation, highly sensitive user tasks were being stored in plaintext and could be read using any SQLite browser.Since the application already features a robust custom JSON export/import backup system, system-level ADB backups are largely redundant and introduce an unnecessary attack surface.
Changes Proposed in this PR:
android:allowBackup="false"in theAndroidManifest.xmlto close the perimeter against ADB extraction tools.backup_rules.xmlanddata_extraction_rules.xmlto explicitly exclude the database domain, ensuring that even if system backups are re-enabled in the future, the secure database is never exported to the cloud or via device-to-device transfer.SQLiteDatabase.loadLibs(context)and passed aSupportFactoryinto the Room database builder inTaskDatabase.kt.Testing Performed:
adb backupnow yields an empty archive for the app's sandbox.local_dbfile is now encrypted ciphertext and cannot be read without the passphrase.