Skip to content

Bug 2075560 - Remove the key-based encrypt/decrypt_string functions - #7576

Merged
theidkamp merged 1 commit into
mozilla:theidkamp/pr-7573from
theidkamp:fxcm-2280-migration
Sep 28, 2026
Merged

theidkamp merged 1 commit into
mozilla:theidkamp/pr-7573from
theidkamp:fxcm-2280-migration

Conversation

@theidkamp

@theidkamp theidkamp commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #7573 (base is theidkamp/pr-7573; will be rebased onto main right after #7573 merges, so both land in the same nightly)

What

Bug 2075560: Remove the key-based encrypt_string / decrypt_string namespace functions. With transparent card numbers (#7573) no consumer handles ciphertext, so nothing needs them. create_autofill_key() stays for consumers that manage a static key; for canaries use db_crypto.create_canary / check_canary (format-compatible with canaries created via the removed encrypt_string).

Breaking API changes

  • encrypt_string(key, ...) / decrypt_string(key, ...) removed. (Android AutofillCrypto.kt & iOS RustAutofill.swift/RustKeychain.swift; Desktop never used these)

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
  • 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
  • Dependencies: This PR follows our dependency management guidelines

@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
@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
@theidkamp
theidkamp changed the base branch from db-crypto to main September 23, 2026 08:36
@theidkamp
theidkamp requested review from DimiDL and jo September 24, 2026 11:26
@theidkamp
theidkamp changed the base branch from main to fxcm-2281-integrate-encryptor September 25, 2026 10:02
@theidkamp
theidkamp changed the base branch from fxcm-2281-integrate-encryptor to theidkamp/pr-7573 September 25, 2026 10:04

@jo jo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looked at ac27ed6#r4103960593, and have some comments which I'd like to submit while looking at the next commits.

I guess the tests testing cc_number_enc will be converted to run against secure fields in the next commit, right?

&record.cc_number_enc,
self.encdec.as_ref(),
record.guid.as_str(),
)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So if we have any undecryptable credit card, get_local_dupe would return an error - is this expected behaviour?
I know this is how it was before but since we now possibly delay key retrieval - which could fail - this might become more important.

Comment on lines +212 to +215
Ok(serde_json::from_str(&cleartext).unwrap_or(Self {
cc_number: cleartext,
cc_cvv: None,
}))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the fallback here, logins throw if the json is not parseable. And we don't reuse the old cc_number_enc value, so there's no need for this fallback, isn't it?

Ok(InternalCreditCard {
guid: p.id,
cc_name: p.entry.cc_name,
cc_number_enc,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wait, why does InternalCreditCard still use cc_number_enc?

id: self.guid,
entry: PayloadEntry {
cc_name: self.cc_name,
cc_number,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need cc_cvv here?

Comment thread components/autofill/src/lib.rs Outdated
cc_number: cleartext,
..Default::default()
}
.encrypt(&static_key_encryptor(&key)?, "<no guid>")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe I do not understand this, this seems wrong. Isn't this part of the old API for cc_number_enc, which this commit does not touch?

Comment on lines +185 to +191
let cleartext = serde_json::to_string(self)
.map_err(|e| Error::EncryptionFailed(format!("{e} (encrypting {guid})")))?;
let cipherbytes = encdec
.encrypt(cleartext.into_bytes())
.map_err(|e| Error::EncryptionFailed(format!("{e} (encrypting {guid})")))?;
String::from_utf8(cipherbytes)
.map_err(|e| Error::EncryptionFailed(format!("{e} (encrypting {guid}: data not utf8)")))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This masks all errors, maybe you could align with logins and propagate the underlying error?

@theidkamp theidkamp changed the title FXCM-2279/2280/2282: Secure-fields blob for card numbers, v6 migration, store-owned string crypto Bug 2075567, 2075564, 2075560 - Secure-fields blob for card numbers, v6 migration, store-owned string crypto Sep 25, 2026
@jo

jo commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

The encrypted SecureCreditCardFields blob should go into a new field secFields, analog to logins, instead of re-using the current cc_number_enc field. A migration should not change a field's type, but only add new fields, or deprecate old ones.

@jo

jo commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Okay, so here's the new plan, as discussed on slack:

  1. cc_number_enc will be made transparent, ideally directly in Bug 2075563 - Integrate EncryptorDecryptor into the autofill database #7573 as the second commit. Then the consumer will only see cc_number and the component will handle the encoding and decoding internally.
  2. a new PR that adds cc_cvv_enc with a migration, and handles encryption in the same way as cc_number_enc.

We can close this branch.

@theidkamp
theidkamp changed the base branch from theidkamp/pr-7573 to main September 25, 2026 15:51
@theidkamp
theidkamp changed the base branch from main to theidkamp/pr-7573 September 25, 2026 15:51
@theidkamp theidkamp changed the title Bug 2075567, 2075564, 2075560 - Secure-fields blob for card numbers, v6 migration, store-owned string crypto Bug 2075560, 2075563 - Remove the key-based string crypto; add a --profile option to autofill-utils Sep 25, 2026
@theidkamp
theidkamp marked this pull request as draft September 25, 2026 15:55
With transparent card numbers no consumer handles ciphertext, so the
namespace functions that took a key have no callers left.
create_autofill_key() stays for consumers that manage a static key.
@theidkamp theidkamp changed the title Bug 2075560, 2075563 - Remove the key-based string crypto; add a --profile option to autofill-utils Bug 2075560 - Remove the key-based encrypt/decrypt_string functions Sep 28, 2026
@theidkamp
theidkamp changed the base branch from theidkamp/pr-7573 to main September 28, 2026 12:25
@theidkamp
theidkamp changed the base branch from main to theidkamp/pr-7573 September 28, 2026 12:25
@theidkamp
theidkamp merged commit 6156f4a into mozilla:theidkamp/pr-7573 Sep 28, 2026
13 checks passed
@mergify

mergify Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

⚠️ The sha of the head commit of this PR conflicts with #7573. Mergify cannot evaluate rules on this PR. Once #7573 is merged or closed, Mergify will resume processing this PR. ⚠️

@theidkamp

Copy link
Copy Markdown
Collaborator Author

Per review discussion: the removal moved into #7573 as its fourth commit, so consumers need exactly one parallel patch. Closing - the CVV work continues in #7631.

@theidkamp
theidkamp deleted the fxcm-2280-migration branch September 28, 2026 13:14
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.

2 participants