fix: an export password of "0" is a password - #863
Merged
Conversation
Whether the admin had supplied a password to encrypt an export with was decided by
empty(), in four places. empty('0') is true, so a password of exactly "0" was treated
everywhere as no password at all:
- appendNode() wrote every category, client, tag and account into the file in the clear.
- appendHash() signed the integrity hash with sha1(passwordSalt) instead of the password.
- XmlVerify::verify() then read the file back as unencrypted and agreed with it, so the
self-check that runs immediately after the export reported success.
- The web form's "passwords do not match" check was skipped, so the value was never even
compared against the one typed to confirm it.
The result is an export the admin believes is encrypted, containing every account's
name, login, URL and notes, sitting in a file they will reasonably then email or copy
somewhere — with nothing anywhere reporting that the password was dropped.
The question being asked is "did the admin supply a password", and null and the empty
string are the two answers that mean no — an unencrypted export is a supported thing to
ask for. That is now settled once at each entry point, so the decisions below it compare
against null rather than each re-deciding what counts as absent.
Checked by putting empty() back: the export written with "0" is no longer encrypted and
the new test fails. The companion test, that an empty password still writes in the clear,
is there so that a fix which simply encrypted unconditionally would not satisfy it.
The two new tests also needed PHPUnit\Framework\Attributes\Test importing into that file
— it was not there, the rest of the class uses the test-prefixed naming, and without it
`#[Test]` does not resolve and both new methods were collected as nothing at all. They
ran green that way before the import was added.
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.
Whether the admin had supplied a password to encrypt an export with was decided by
empty(), in four places. empty('0') is true, so a password of exactly "0" was treated
everywhere as no password at all:
self-check that runs immediately after the export reported success.
compared against the one typed to confirm it.
The result is an export the admin believes is encrypted, containing every account's
name, login, URL and notes, sitting in a file they will reasonably then email or copy
somewhere — with nothing anywhere reporting that the password was dropped.
The question being asked is "did the admin supply a password", and null and the empty
string are the two answers that mean no — an unencrypted export is a supported thing to
ask for. That is now settled once at each entry point, so the decisions below it compare
against null rather than each re-deciding what counts as absent.
Checked by putting empty() back: the export written with "0" is no longer encrypted and
the new test fails. The companion test, that an empty password still writes in the clear,
is there so that a fix which simply encrypted unconditionally would not satisfy it.
The two new tests also needed PHPUnit\Framework\Attributes\Test importing into that file
— it was not there, the rest of the class uses the test-prefixed naming, and without it
#[Test]does not resolve and both new methods were collected as nothing at all. Theyran green that way before the import was added.