Skip to content

fix: encrypt postal addresses with lockbox - #301

Open
jaspermayone wants to merge 3 commits into
mainfrom
fix/encrypt-addresses
Open

jaspermayone wants to merge 3 commits into
mainfrom
fix/encrypt-addresses

Conversation

@jaspermayone

Copy link
Copy Markdown
Member

Summary

Postal addresses were stored in plain text. This PR encrypts them with Lockbox, like the other personal data in Weave. It fixes code scanning alert #7.

  • These fields are now ciphertext: line1 to line3, city, postal_code, nickname, the contact name, email and phone, shipping_notes, latitude and longitude.
  • state and country stay in plain text, because residency checks and deletion aggregates read them in SQL.
  • Address ignores the old plain-text columns, so new writes go only to ciphertext.
  • filter_parameters now filters *_address_attributes, so the address form does not reach the request log.
  • Address.ransackable_attributes is id only. No caller searched the street lines.

Migrations

flowchart LR
  A["1. add *_ciphertext columns<br/>(irreversible)"] --> B["2. copy plain text to ciphertext<br/>(Lockbox.migrate, restart: false)"]
  B --> C["this PR: model reads and writes ciphertext only"]
  C --> D["follow-up PR: drop the plain-text columns"]
Loading
  • The backfill uses a local model on the same table, so Lockbox derives the same key as Address.
  • restart: false fills only rows with no ciphertext, so a second run does not wipe rows that the new code wrote.
  • Migration 1 is irreversible. After the deploy, the ciphertext is the only copy of a new or edited address.
  • The plain-text columns keep their old values until the follow-up PR drops them.

Checks

  • bundle exec rspec: 2890 examples, 0 failures. Address, migration and request specs ran again after the review fixes: 1105 examples, 0 failures.
  • bin/rubocop: no offenses.
  • bin/brakeman: no warnings.
  • db/schema.rb is edited by hand to add only the new columns. The private test DB would also dump the queue tables.

@jaspermayone
jaspermayone requested a review from a team November 18, 2026 17:03
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