Require accounts to still read the same after a master password change - #734
Merged
Conversation
The command's tests covered what it refuses and that a failed rotation rolls back as one transaction. What nothing asserted is the thing the operation exists for: that after a successful rotation the accounts are still readable, and read back as the passwords they held before. A rotation that quietly mangled one would have passed every test in that file. A user would have found it months later, with nothing to go back to. Two accounts and a history entry are stored with known, different passwords, encrypted for real under the current master password; each is read back and checked before the rotation, so a bad fixture cannot be mistaken for a good result. Then the rotation runs, and each is read back again under the new master password and required to be the same plaintext — not merely something that decrypts. The old master password no longer validates and the new one does. The fixture reads and writes go through SQL rather than the account service: the service scopes its results to the signed-in user and the CLI container has none, while the rotation itself has no such filter — so this is the path that actually exercises it.
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.
The gap
UpdateMasterPasswordCommandTestcovered what the command refuses, and that a failed rotation rolls back as one transaction (#707). What nothing asserted is the thing the operation exists for:A rotation that quietly mangled a password would have passed every test in that file. It would be found by a user, months later, with nothing to go back to. In a password manager that is the worst outcome available.
What the test establishes
mPassHashstamped so the rotation does not skip it).One thing worth knowing
The fixture reads and writes go through SQL rather than
AccountService: the service scopes its results to the signed-in user, and the CLI container never logs one in, while the rotation itself carries no such filter. Going through the service would have tested the filter, not the rotation. That is written down in the test.Not covered
Custom fields are rotated in the same transaction and are not asserted here — the command's own output calls out accounts and history, and that is what this covers.
Testing
Integration: 14 green in the class, over two runs, no lock contamination.