Skip to content

FXCM-2279/2280/2282: Secure-fields blob for card numbers, v6 migration, store-owned string crypto - #7576

Open
theidkamp wants to merge 4 commits into
mozilla:db-cryptofrom
theidkamp:fxcm-2280-migration
Open

theidkamp wants to merge 4 commits into
mozilla:db-cryptofrom
theidkamp:fxcm-2280-migration

Conversation

@theidkamp

@theidkamp theidkamp commented Sep 2, 2026

Copy link
Copy Markdown

Blocked on #7542

Stacked on #7573

Description

What

This PR combines three related changes:

  1. FXCM-2279: Centralize card encryption in SecureCreditCardFields
    Similar to SecureLoginFields, SecureCreditCardFields now handles its own serialization and encryption/decryption. Cards are stored as a serialized blob ({"cc_number":"…"}), with optional cc_cvv.
    Decryption supports both the new blob and the legacy plain card-number format.

  2. FXCM-2280: Migrate existing card data from v5 → v6
    On first DB open, existing card numbers are rewritten to the new blob format on all platforms. The schema version also serves as the format version, so no additional migration flag or metrics are needed.
    Scrubbed or unreadable rows are left unchanged, and Sync metadata is untouched, so the migration itself does not trigger uploads.

  3. FXCM-2282: Remove decrypt_string / encrypt_string APIs

Breaking API changes

  • Key-based encrypt_string(key, …) / decrypt_string(key, …) removed. use store.encrypt_string(…) / store.decrypt_string(…). Old ciphertext stays readable; for canaries use db_crypto.create_canary check_canary (format-compatible). (Android & iOS; Desktop never used these)
  • scrub_undecryptable_credit_card_data_for_remote_replacement() no longer takes the key. (iOS)
  • set_local_encryption_key is removed from the sync engine. Stop passing the creditcards key in local_encryption_keys before updating. Passing one now panics. (Android & iOS; consumer patches: (WorkManagerSyncManager.kt / RustSyncManager.swift)

Important

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.

@theidkamp theidkamp changed the title FXCM-2280: Implement Migration for Encrypted Autofill Storage FXCM-2279 & FXCM-2280: Versioned secure-fields blob for credit-card numbers + migration Sep 10, 2026
@theidkamp
theidkamp force-pushed the fxcm-2280-migration branch 3 times, most recently from 00784a9 to 3c5b714 Compare September 14, 2026 13:46
@theidkamp
theidkamp changed the base branch from main to db-crypto September 14, 2026 13:50
@theidkamp
theidkamp force-pushed the fxcm-2280-migration branch 10 times, most recently from 2d1e2e5 to afc4fce Compare September 18, 2026 13:08
Move autofill's credit-card encryption onto the shared db-crypto crate and let
AutofillDb own the encryptor, as logins' LoginDb does. The consumer supplies it
when building the store, so no key is passed into individual calls or down
through the sync layers.
Move encrypting and decrypting a card number into a single struct, so the
knowledge of what the stored value looks like lives in one place instead of
being spread across the db and sync code. The stored value becomes the
serialized struct - a JSON blob with room for a CVV - so a second encrypted
field can be added without another format change.

New writes use the blob from here on; a bare number written before it still
decrypts, and existing rows are rewritten in FXCM-2280.
…ned methods

The store owns the key, so string crypto becomes a method on it:
store.encrypt_string(cleartext) / store.decrypt_string(ciphertext), same
stored format as the record paths. The namespace functions that took the key
as a parameter are gone - they cannot be served once the key lives in NSS.
create_autofill_key() stays for consumers that manage a static key.
@theidkamp theidkamp changed the title FXCM-2279 & FXCM-2280: Versioned secure-fields blob for credit-card numbers + migration FXCM-2279/2280/2282: Secure-fields blob for card numbers, v6 migration, store-owned string crypto Sep 22, 2026
@theidkamp
theidkamp marked this pull request as ready for review September 22, 2026 13:59

This branch has not been deployed

No deployments
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