mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-04-05 20:31:58 +02:00
Database corruption "database disk image is malformed" due to duplicate primary keys – possibly caused by incorrect system time on a new device #97
Closed
opened 2026-04-05 20:30:04 +02:00 by MrUnknownDE
·
0 comments
No Branch/Tag Specified
main
cached-config-operations
test_dylint
1.35.4
1.35.3
1.35.2
1.35.1
1.35.0
1.34.3
1.34.2
1.34.1
1.34.0
1.33.2
1.33.1
1.33.0
1.32.7
1.32.6
1.32.5
1.32.4
1.32.3
1.32.2
1.32.1
1.32.0
1.31.0
1.30.5
1.30.4
1.30.3
1.30.2
1.30.1
1.30.0
1.29.2
1.29.1
1.29.0
1.28.1
1.28.0
1.27.0
1.26.0
1.25.2
1.25.1
1.25.0
1.24.0
1.23.1
1.23.0
1.22.2
1.22.1
1.22.0
1.21.0
1.20.0
1.19.0
1.18.0
1.17.0
1.16.3
1.16.2
1.16.1
1.16.0
1.15.1
1.15.0
1.14.2
1.14.1
1.14
1.13.1
1.13.0
1.12.0
1.11.0
1.10.0
1.9.1
1.9.0
1.8.0
1.7.0
1.6.1
1.6.0
1.5.0
1.4.0
1.3.0
1.2.0
1.1.0
1.0.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.0
Labels
Clear labels
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
SSO
Third party
Third party
Third party
Third party
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
good first issue
help wanted
low priority
low priority
low priority
low priority
question
question
Milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
MrUnknownDE
Clear assignees
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github/vaultwarden#97
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TaoRone on 2/22/2026
Prerequisites
Vaultwarden Support String
I'm running a self-hosted Bitwarden instance (Vaultwarden) and recently encountered a database corruption error: database disk image is malformed. After investigation, I suspect the root cause might be related to a new device having an incorrect system time (NTP not synchronized, clock set to the past) during synchronization, leading to duplicate entries with the same UUID.
Has anyone encountered a similar issue? Could an incorrect client time really trigger this kind of duplicate primary key insertion?
What would be the safest way to repair the database (e.g., removing duplicate entries based on the most recent revision date)?
Are there any safeguards that could be implemented in Bitwarden/Vaultwarden to prevent such corruption, such as validating client timestamps or using stronger conflict resolution?
Any guidance or insights would be greatly appreciated. Thank you!
Vaultwarden Build Version
v1.33
Deployment method
Official Container Image
Custom deployment method
No response
Reverse Proxy
nginx1.26
Host/Server Operating System
Linux
Operating System Version
No response
Clients
Browser Extension
Client Version
No response
Steps To Reproduce
I used sqlite3 to dump the database and look for issues:
text
sqlite3 db.sqlite3 ".dump" > backup.sql
sqlite3 fix.db < backup.sql
During this process, I found several pairs of rows sharing the same UUID but with different encrypted data and revision timestamps.
Here is an example of two conflicting ciphers entries (sensitive data has been redacted):
sql
INSERT INTO ciphers VALUES('d12ddef9-2f41-4d56-b09c-7ed45e95a5df','2023-04-08 04:11:07.581302684','2025-11-30 05:06:03.152207604','7d4b45db-df2e-468d-9767-ed64e18d066b',NULL,1,'2.rotn3twrTfb/3srs0ibR8w==|...','...','...','{"fido2Credentials":[],"password":"...","passwordRevisionDate":"2023-07-21T17:58:53.531Z","totp":null,"uris":[{"match":1,"uri":"...","uriChecksum":"..."}],"username":"..."}','[{"lastUsedDate":"2023-07-21T17:58:53.531Z","password":"..."}]',NULL,0,NULL);
INSERT INTO ciphers VALUES('d12ddef9-2f41-4d56-b09c-7ed45e95a5df','2023-04-08 04:11:07.581302684','2024-05-01 04:25:24.219123814','7d4b45db-df2e-468d-9767-ed64e18d066b',NULL,1,'2.62ScH8llICZtFJ9bsgmjFA==|...','...','...','{"Password":"...","PasswordRevisionDate":"2023-07-21T17:58:53.531Z","Totp":null,"Uris":[{"Match":3,"Uri":"...","UriChecksum":"..."},{"Match":1,"Uri":"...","UriChecksum":"..."}],"Username":"..."}','[{"LastUsedDate":"2023-07-21T17:58:53.531Z","Password":"..."}]',NULL,0,NULL);
Both records have the same UUID (d12ddef9-2f41-4d56-b09c-7ed45e95a5df).
Their encrypted data (e.g., name, data, password history) are completely different.
The revision timestamps are inconsistent: one is in 2025 (future) and the other in 2024 (past), while the creation date is identical.
The JSON structure in the data column also differs in key casing (lowercase vs. uppercase), suggesting they may come from different client versions or corrupted states.
Expected Result
/
Actual Result
A new device with an incorrect system time (e.g., clock set to a date in the past) might have attempted to sync/update entries. This could have caused the server to accept updates with old timestamps, leading to duplicate rows with the same UUID, eventually corrupting the database.
Logs
Screenshots or Videos
No response
Additional Context
No response