Skip to content

Bugfix Prevent a possible database corruption when checking encryption status#1228

Merged
meladRaouf merged 1 commit into
release/2025.2.0-draftfrom
bugfix/avoid-db-corruption
Jun 17, 2025
Merged

Bugfix Prevent a possible database corruption when checking encryption status#1228
meladRaouf merged 1 commit into
release/2025.2.0-draftfrom
bugfix/avoid-db-corruption

Conversation

@meladRaouf
Copy link
Copy Markdown
Collaborator

@meladRaouf meladRaouf commented Jun 16, 2025

JIRA ticket
Will be released in: 2025.2.0

Root cause analysis (for bugfixes only)

First known affected version: 2025.2.0

Using SQLiteDatabase.openDatabase() without a passphrase on an encrypted Room database caused SQLite to treat the DB as corrupted, triggering an automatic wipe during internal diagnostics.

Corruption reported by sqlite on database: /data/user/0/com.simprints.id/databases/db-subjects
DB wipe detected: package=com.simprints.id reason=corruption
...
at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1206)
at com.simprints.infra.enrolment.records.repository.local.RoomEnrolmentRecordLocalDataSource.isDBEncrypted(SourceFile:3)

Fix

  • Removed unsafe direct DB access via SQLiteDatabase.openDatabase().

Testing guidance

Open the migration section in the troubleshooting screen when the active database is Room.

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

@cla-bot cla-bot Bot added the ... label Jun 16, 2025
@meladRaouf meladRaouf changed the base branch from main to release/2025.2.0-draft June 16, 2025 20:13
@sonarqubecloud
Copy link
Copy Markdown

@meladRaouf meladRaouf requested review from a team, BurningAXE, TristramN, alex-vt, alexandr-simprints, luhmirin-s and ybourgery and removed request for a team June 17, 2025 04:53
val dbPath = database.openHelper.readableDatabase.path
val dbSize = getTotalRoomDbSizeBytes(dbPath!!)
val isDBEncrypted = isDBEncrypted(dbPath)
val isDBEncrypted = DB_ENCRYPTION
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely a simpler option :D

@meladRaouf meladRaouf merged commit 74d5eeb into release/2025.2.0-draft Jun 17, 2025
12 checks passed
@meladRaouf meladRaouf deleted the bugfix/avoid-db-corruption branch June 17, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants