Skip to content

Bug 2007416 - wipe individual logins on DecryptionErrors #7343

Open
bendk wants to merge 2 commits intomozilla:mainfrom
bendk:push-myztqrztlsuu
Open

Bug 2007416 - wipe individual logins on DecryptionErrors #7343
bendk wants to merge 2 commits intomozilla:mainfrom
bendk:push-myztqrztlsuu

Conversation

@bendk
Copy link
Copy Markdown
Contributor

@bendk bendk commented Apr 28, 2026

First commit is prep work, without much changes.
Second commit is the actual change.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

bendk added 2 commits April 28, 2026 11:23
Reworked how we handle `EncryptorDecryptor`:

* Don't pass `EncryptorDecryptor` to database functions, this is
  redundant because the DB has it's own enc_dec arc.
* Make `EncryptorDecryptor::decrypt_login` input a `LoginDb`.  This
  enables a future change where we wipe the login on decryption
  failures.

Most of this is just a pure refactor.  The one real change is that we
need to lock the store to get a `LoginDb` a bit more in the sync engine
code.
Also:
  * Set sync_status in `LoginsDb::touch()`
  * Handle missing row for LAST_SYNC_META_KEY in `get_last_sync()`
@bendk bendk force-pushed the push-myztqrztlsuu branch from 6c5a0c6 to e8513bf Compare April 28, 2026 16:41
named_params! {
":now_millis": now_ms,
":guid": id,
":sync_status": SyncStatus::Changed as u8,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

touch() now also updates the sync_status column. I needed this to make the tests pass, but it seems like the code should have always done that to me. Maybe we were just not using this method enough to notice?

Ok(Some(ServerTimestamp(millis)))
Ok(db
.get_meta::<i64>(schema::LAST_SYNC_META_KEY)?
.map(ServerTimestamp))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This also needed changes to make the tests pass, because it seemed like the old code was not correct. Before this would panic if there was no metadata for LAST_SYNC_META_KEY, now it returns None.

self.execute("DELETE FROM loginsM WHERE guid=?", [guid])?;
// Delete the LAST_SYNC_META_KEY so that we resync the logins data next time
self.delete_meta(schema::LAST_SYNC_META_KEY)?;
tx.commit()?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's lots of incidental changes in this PR, but this is the main change.

@bendk bendk requested a review from mhammond April 28, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant