Checking access…

Skip to main content
Audience: CCG Platform Engineers

Operate Session Cookie Encryption & Key Rotation

Use these procedures to rotate keys, investigate failures, and respond to incidents. See the overview for the design and the reference for configuration and error details.

Incident Response: Revoking a Compromised Key​

Pushing a new HSID-JWE-SECRET version is not the same operation as revoking the old one, and conflating the two is the single most important pitfall in this design for an actual key-compromise incident.

  • pushNewSecretVersion (a new Key Vault secret version) makes a new version current for future encryptions. It does not touch the old version's enabled state at all. The old (possibly compromised) version is picked up by the normal grace-period sweep like any routine rotation, and β€” by design, to protect legitimate in-flight sessions β€” stays enabled and decryptable for the full configured grace-period (16 minutes by default) after being superseded.
  • disableSecretVersion (an explicit disable of a specific, existing version) is a separate Key Vault operation. Disabling an existing version does not fire a SecretNewVersionCreated Event Grid event (no new version was created), so pods do not learn about it near-instantly the way they do for a new-version push. Instead, every pod's own disableExpiredPreviousVersions() sweep re-reads each version's enabled state from Key Vault unconditionally, on every tick, before any grace-period math runs β€” so a version Security force-disables converges across every pod within one grace-period-check-cron interval (1 minute by default), completely independent of the 16-minute grace period.

Practical consequence: if a key is genuinely compromised, Security must do both of the following, not just the first:

  1. Push a new version (az keyvault secret set --name HSID-JWE-SECRET --value <new-base64-key>) so new sessions stop using the compromised key.
  2. Explicitly disable the compromised version (az keyvault secret set-attributes --name HSID-JWE-SECRET --version <compromised-version> --enabled false) so every pod stops honoring it within about a minute, instead of the full grace period.

Step 2 does mean any legitimate, still-valid session encrypted with the compromised version is invalidated early too (forcing re-authentication) β€” that's the correct trade-off during an actual compromise, and is exactly why this isn't done automatically for routine rotations.

SessionCookieDecryptCli (src/test/java/.../tools, never ships in the deployable jar) decrypts a compact JWE outside a running instance, using the same nimbus-jose-jwt classes as CredentialService:

mvn -q test-compile org.codehaus.mojo:exec-maven-plugin:3.1.0:java \
-Dexec.mainClass=com.optum.wallet.authorization.tools.SessionCookieDecryptCli \
-Dexec.classpathScope=test \
-Dexec.args="<compact-jwe> <base64-aes-256-key>"

Both arguments can be supplied via SESSION_COOKIE / SESSION_COOKIE_KEY env vars instead (keeps them out of the process arg list visible via ps/CI logs β€” this does not hide them from shell history).

The key is the raw Base64 AES-256 value for the Key Vault secret version named in the cookie's kid header:

az keyvault secret show --name HSID-JWE-SECRET --version <kid> --query value -o tsv

The CLI never calls Key Vault itself. Treat any key that has passed through a shell/chat/ticket as compromised β€” rotate it, don't reuse it.

Troubleshooting​

A key was just compromised β€” how do I revoke it right now?​

Pushing a new version is not enough by itself β€” see Incident Response: Revoking a Compromised Key. You must also explicitly disable the compromised version (az keyvault secret set-attributes ... --enabled false) for every pod to stop honoring it within ~1 minute instead of the full grace period.

A rotation didn't get picked up by all pods​

Check:

  1. Event Grid subscription for Microsoft.KeyVault.SecretNewVersionCreated on HSID-JWE-SECRET is active (validation handshake logged once when the subscription was created).
  2. KEY_ROTATION_EXTERNAL_VERSION_DETECTED in the logs of the pods that should have reacted.
  3. Even without Event Grid, every pod self-heals within latest-version-ttl (default 1 minute) via its own TTL-based refresh.

An old key version isn't being disabled​

Check:

  1. KEY_ROTATION_GRACE_PERIOD_SWEEP_COMPLETED / KEY_ROTATION_PREVIOUS_VERSION_DISABLED logs.
  2. Whether the version has a successor yet β€” the newest version is never a disable candidate, and grace is measured from when a version was superseded, not from its own createdOn.
  3. KEY_ROTATION_PREVIOUS_VERSION_DISABLE_FAILED for a Key Vault-side error (e.g. RBAC).

Customers are getting logged out / 401s right after a rotation​

This should never happen within the configured grace period β€” if it does:

  1. Confirm grace-period >= latest-version-ttl + max(OIDC state TTL, checkout session TTL) β€” startup would otherwise fail via SessionCookieEncryptionSafetyValidator, so this points at a live misconfiguration bypassing that check (e.g. the Key Vault rotation-interval override was changed without redeploying, decoupling actual behavior from what the safety validator checked at startup).
  2. Check for LEGACY_KID_LESS_COOKIE_REJECTED β€” a kid-less cookie from before a cutover deploy, with no legacy-version configured for that transition window.