Magento

Magento encryption key rotation after a 2.4.8 upgrade

Magento

Magento encryption key rotation is now a CLI-only job on Adobe Commerce 2.4.8, and that change surprises teams who still expect System > Manage Encryption Key in Admin. I am Alan Vo, a Gold Coast web developer with 18 years on Magento, Shopify, and WooCommerce stores. When a merchant finishes a 2.4.8 upgrade, security reviews often ask for key rotation after CVE-2024-34102 guidance or a quarterly hygiene pass. This note covers the production sequence: maintenance mode, bin/magento encryption:key:change, optional re-encryptors, and how Adobe keeps older ciphertext readable without rewriting every row on day one.

Why Magento encryption key rotation matters after 2.4.8

Magento encryption key rotation matters after 2.4.8 because Adobe removed the Admin UI for changing keys and shipped a redesigned key stack in the 2.4.8 release notes. Integration passwords, payment module credentials, and other sensitive core_config_data values rely on the ChaCha20-Poly1305 key stored in app/etc/env.php or a CRYPT_KEY environment variable, as described in Adobe's encryption key guide. A compromised key from an old backup, a leaked env.php in a ticket, or a post-incident audit all point to the same action: rotate, then prove checkout and admin integrations still decrypt.

The platform design also changed how keys age. Adobe documents that when you update the key, a new primary key is added to a list while older keys remain available for decrypting legacy ciphertext. Edited sensitive values re-encrypt with the newest key. That model balances performance and resilience, but it does not replace your runbook. You still schedule downtime, warn stakeholders about forced logouts, and run re-encrypt commands when you want every row on the latest key.

Compliance and partner questionnaires increasingly ask for proof of rotation, not only patch levels. Magento catalogue projects I ship (Adobe Commerce, Hyva, headless BFFs) share infrastructure with ERP and PIM feeds. One stale env.php in a staging clone that mirrors production keys can undo months of hardening. Treat rotation as infrastructure work tied to the upgrade window, not a surprise Friday task.

How Magento encryption key rotation works in core

Magento encryption key rotation works through CLI commands in the EncryptionKey module, exposed in the bin/magento reference.

The change command is:

``bash bin/magento encryption:key:change ``

Optional -k or --key accepts a 32-character string; if you omit it, Magento generates a random key and writes it into env.php. Adobe states the command updates the key inside env.php and that execution triggers a cache clean in troubleshooting guidance for pre-2.4.8 patches. On Adobe Commerce on Cloud, you still deploy the updated env.php or environment variable through your normal sensitive-config pipeline after running the command on the node that owns the file.

Magento encryption key rotation catalogue work on a large monitor

Multi-key behavior is important for operators. Adobe's CVE guidance explains that the application reads ciphertext with the key that encrypted it and writes new values with the primary key. That means payment gateways often keep working immediately after rotation if credentials were not re-saved. It also means long-tail rows can stay on older keys until you run a re-encrypt job or an editor touches the field.

Adobe documents separate data re-encryption commands for systematic rewrites:

``bash bin/magento encryption:data:list-re-encryptors bin/magento encryption:data:re-encrypt core_config_data sales_order_payment ``

Default re-encryptors cover system configuration and sales_order_payment fields. Custom modules can register SimpleHandler-based re-encryptors for extension tables that store encrypted card or token columns. List re-encryptors before you assume a third-party vault table is covered.

Another command, bin/magento encryption:payment-data:update, re-encrypts stored card data with the latest cipher. Use it when Adobe's security notes or your acquirer audit calls out legacy cipher usage, not on every rotation by default. Confusing payment-data migration with day-to-day key rotation is a common source of unnecessary production risk.

Cloud operators disable cron with ./vendor/bin/ece-tools cron:disable and re-enable with cron:enable, per the encryption key admin doc. On-premises teams edit crontab. Maintenance mode wraps the window because Adobe warns that rotation invalidates customer and admin sessions (integration users excepted). Plan a comms line for "you will need to sign in again" across storefront and Admin.

Production checklist for Magento encryption key rotation

A Magento encryption key rotation window is complete when keys, caches, cron, integrations, and re-encrypt status match Adobe's documented order.

  1. Confirm 2.4.8+ and command availability. Run bin/magento list | grep encryption:key:change and verify output matches Adobe's expected help text before you touch production.
  2. Snapshot and permissions. Ensure app/etc/env.php is writable on the target node. Back up env.php and your secrets manager entry. On Cloud, confirm whether CRYPT_KEY overrides file storage.
  3. Announce session impact. Adobe documents immediate invalidation of shopper and admin sessions. Pick a low-traffic window and pause marketing sends that deep-link to authenticated account areas.
  4. Enable maintenance mode. bin/magento maintenance:enable keeps partial checkouts from racing cron while keys change.
  5. Disable cron. Use ece-tools on Cloud or comment crontab on VMs. Stopped indexers and consumers reduce mid-rotation writes to encrypted fields.
  6. Rotate the key. Run bin/magento encryption:key:change or supply -k only when your security team provides a vetted 32-character value. Store the previous key in your vault per Adobe's recommendation to keep recovery material secure.
  7. Flush caches. bin/magento cache:flush on-premises or magento-cloud cc on Cloud, matching the admin guide.
  8. Re-enable cron and disable maintenance. Restore traffic only after smoke tests pass.
  9. Run re-encryptors when required. After incident response or policy that demands uniform key age, run bin/magento encryption:data:re-encrypt core_config_data sales_order_payment and any custom encryptors your modules register.
  10. Smoke test decrypt paths. Place a zero-dollar or sandbox authorization, save a shipping integration password in staging first, and confirm masked fields still load in Admin without exceptions in var/log/system.log.
  11. Deploy config to all nodes. Staging-only rotation is useless if production env.php or CRYPT_KEY lags. Sync through your pipeline the same way you would any other secret rotation.
Warehouse shelves standing in for a Magento inventory grid

Document who ran the command, the ticket link, and whether re-encrypt finished. Auditors ask for timestamps, not only "we rotated."

What breaks during Magento encryption key rotation

Magento encryption key rotation breaks predictable things when teams skip maintenance, cron control, or communication about sessions.

Mass logouts are by design. Shoppers mid-checkout may need to re-authenticate if your checkout binds heavily to customer sessions. Single-page checkout and headless carts with Bearer tokens behave differently, but Admin users will be kicked out. Schedule support coverage.

Missing CLI on older minors blocks the runbook. Merchants still on 2.4.7 without Adobe's isolated patch must install patch ac-12589 for their line or upgrade to 2.4.8 before relying on encryption:key:change. Do not paste raw key material through the deprecated Admin screen on versions where it still exists if Adobe already flagged bugs.

Partial cluster deploys produce decrypt exceptions. If node A has the new crypt array and node B still reads an old single key, random 500s appear on config reads. Treat env.php and CRYPT_KEY as fleet-wide state.

Re-encrypt runtime on large sales_order_payment tables can exceed your maintenance window. Adobe's re-encrypt command walks encrypted columns; run it off-peak and watch MySQL replication lag on read replicas used for reporting.

Custom encrypted fields stay on legacy keys until touched or until you ship a SimpleHandler re-encryptor. Payment extensions that stash tokens in bespoke tables are the usual gap. encryption:data:list-re-encryptors is your discovery step.

Backup restores can reintroduce an old key file while the database expects a newer key list. After any restore drill, compare env.php to the vault and re-run rotation if the file rolled back.

Boxed products on a packing bench

Headless and integration tokens minted before rotation may fail if your custom code cached derived secrets. Adobe notes newer keys sign authentication tokens for privileged automations. Flush integration caches and regenerate OAuth credentials where your module docs require it.

How to measure success after Magento encryption key rotation

Magento encryption key rotation success shows up in logs, checkout metrics, and configuration reads rather than a single green banner in Admin.

Watch var/log/exception.log for Unable to decrypt or Encryptor errors for 24 hours after the window. Spike during the first cron pass often means a node or a custom table still holds ciphertext from a key you dropped from the list.

Re-save one sensitive Admin field intentionally (for example a FedEx or Australia Post API password in staging) and confirm the value persists across cache flush. That proves write path uses the new primary key.

Compare payment authorization rates in your gateway dashboard for the rotation hour versus the prior week. Magento encryption key rotation should not move approval rates; a dip often means braintree or adyen credentials failed to decrypt.

Run bin/magento encryption:data:list-re-encryptors after custom module deploys. If your vendor ships a new re-encryptor name, add it to the post-rotation job list.

For Cloud projects, verify ece-tools cron re-enabled: stuck cron:disable starves indexers and makes unrelated SEO and catalog jobs look broken.

Record session volume in your analytics tagged with the maintenance window so marketing does not misread a logout cliff as funnel regression.

Magento encryption key rotation sits next to platform upgrades and headless read paths on the same Adobe Commerce estates I maintain. The retail conversion case documents catalogue-scale Magento work where checkout uptime and ops hygiene mattered. Never Never Distillery is a D2C Magento build where payment credentials and carrier integrations must survive deploys cleanly. Arteriors shows Hyva-facing performance work that still depends on sound core configuration under the theme. For adjacent reading, see Magento GraphQL customer orders for account-area headless patterns after shoppers re-login, and Adobe Commerce Live Search for SaaS modules that also store integration secrets in core_config_data.

FAQ

When must Magento encryption key rotation use CLI instead of Admin?

Adobe deprecated the Manage Encryption Key Admin screen and removed it in 2.4.8. After you upgrade to 2.4.8 or Adobe Commerce 2.4.8, you must rotate with bin/magento encryption:key:change following the encryption key steps. Earlier versions may still show Admin UI, but Adobe recommends CLI, especially after security patches tied to CVE-2024-34102.

Watch product still used as a Magento PDP example

Does Magento encryption key rotation require re-encrypting every database row immediately?

No. Adobe documents a key list where older keys decrypt legacy data and the primary key encrypts new or edited values. Run bin/magento encryption:data:re-encrypt with core_config_data and sales_order_payment (and custom re-encryptors) when policy or incident response requires uniform rewrites, as described in data re-encryption.

Will Magento encryption key rotation log out customers and admins?

Yes. Adobe states rotation immediately invalidates customer and admin sessions, excluding integration users. Plan maintenance messaging and support coverage. Headless clients should handle 401 responses and prompt re-login or token refresh.

How do I choose between encryption:key:change and encryption:payment-data:update?

Use encryption:key:change for routine Magento encryption key rotation and updating the key material in env.php or environment variables. Use encryption:payment-data:update when Adobe's security guidance calls for migrating stored card ciphertext to a newer cipher, per the CLI reference. They solve different problems; do not run payment-data update on every rotation without a documented reason.

Retail aisle used while thinking through Magento filters

Keep reading

Contact if you want this kind of work on a live store.