mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-03-25 07:41:20 -05:00
Bug: user can delete itself - will corrupt database #5422
Reference in New Issue
Block 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 @lexusburn on GitHub (Nov 27, 2023).
Subject of the issue
A user had lost his master password and had the option to delete his user account (link in password hin email).
This user got a message, that delete wasn't sucessful.
Delete from admin wasn't successful too.
I've got the this error in the logs:
deleting user FOREIGN KEY constraint failed
Deployment environmentt (Generated via diagnostics page)
Config (Generated via diagnostics page)
Show Running Config
Environment settings which are overridden: DOMAIN, SIGNUPS_ALLOWED, INVITATIONS_ALLOWED, SHOW_PASSWORD_HINT, ADMIN_TOKEN, YUBICO_CLIENT_ID, YUBICO_SECRET_KEY, SMTP_HOST, SMTP_SECURITY, SMTP_PORT, SMTP_FROM, SMTP_USERNAME, SMTP_PASSWORD
Expected behaviour
That the user don't have the option to delete himself.
Or that the option is present, but it works and don't corrupts the (sqlite) database.
@BlackDex commented on GitHub (Nov 27, 2023):
Your database probably was corrupted before the user tried to delete his account already. Also manual attempts on the sqlite file could cause this. Same as for shared storage if that is used that could also cause issues.
@BlackDex commented on GitHub (Nov 27, 2023):
First make a backup of the current database before you do anything else.
I would suggest to check https://sqlite.org/recovery.html#recovery_using_the_recover_command_in_the_cli
You could also try to use the backup feature in the admin interface and then after that copy the backup file and use that as the new main database. That might be enough already.
@BlackDex commented on GitHub (Nov 27, 2023):
I also found this which might helps. https://community.home-assistant.io/t/fix-corrupted-malformed-sqlite-database-home-assistant-v2-db/257502
@lexusburn commented on GitHub (Nov 27, 2023):
Thank you, but i have already a daily backup job running.
The database wasn't corrupt before.
I had restored the backup a few hours before this user had made the action and all was working fine.
I can reproduce the issue:
@BlackDex commented on GitHub (Nov 27, 2023):
How sure are you that the database isn't corrupted, even the backups? Did you checked them with
pragma integrity_check;?Also, what happens if you do not let the user follow the recovery/delete flow? And delete the user directly via the admin Interface. Would be strange if it would work, since both use the same function to do the delete.
Also, i just tested both flows, and both work without an issue.
So this probably is a database issue, either by a strange corruption or manual deletions maybe.
I would still suggest to check the database for integrity.
@BlackDex commented on GitHub (Dec 6, 2023):
Any chance yet to check for integrity?
The only thing deleting a user and causing an error would be an already (manually) incomplete deletion of that user, or a corrupted database.
@BlackDex commented on GitHub (Dec 9, 2023):
Closing this as stale. Please re-open if needed with more details.