Skip to content

chore: improve jwt at-rest token encryption#1755

Open
paustint wants to merge 1 commit into
mainfrom
sec/jwt-token-encryption-improvement
Open

chore: improve jwt at-rest token encryption#1755
paustint wants to merge 1 commit into
mainfrom
sec/jwt-token-encryption-improvement

Conversation

@paustint
Copy link
Copy Markdown
Contributor

@paustint paustint commented Jun 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings June 1, 2026 14:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the shared at-rest token encryption primitive from legacy unauthenticated AES-256-CBC to authenticated AES-256-GCM, while preserving backward compatibility by auto-detecting and decrypting previously-stored CBC ciphertext. It also updates API service documentation/comments to reflect the new versioned ciphertext format and adds unit tests to lock in the compatibility and tamper-detection behavior.

Changes:

  • Switch encryptString to write AES-256-GCM with a gcm!-prefixed, colon-safe payload format and keep decryptString backward-compatible with legacy CBC blobs.
  • Add unit tests covering: GCM-by-default output, round-trips, legacy CBC decryption compatibility, and tamper detection.
  • Update service-level comments/docs in Salesforce org encryption and JWT token encryption to reflect the new authenticated encryption behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
libs/shared/node-utils/src/lib/shared-node-utils.ts Implements versioned encryption: write GCM (gcm!…) and read both GCM + legacy CBC.
libs/shared/node-utils/src/lib/tests/shared-node-utils.encryption.spec.ts Adds tests for GCM output, compatibility with legacy CBC, and tamper detection.
apps/api/src/app/services/salesforce-org-encryption.service.ts Updates inline documentation to reflect authenticated GCM writes and legacy read-only debt.
apps/api/src/app/services/jwt-token-encryption.service.ts Updates documentation to reflect versioned encrypt/decrypt primitives and GCM-by-default behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libs/shared/node-utils/src/lib/shared-node-utils.ts
Comment thread libs/shared/node-utils/src/lib/shared-node-utils.ts
Comment thread libs/shared/node-utils/src/lib/__tests__/shared-node-utils.encryption.spec.ts Outdated
Comment thread libs/shared/node-utils/src/lib/shared-node-utils.ts
Comment thread libs/shared/node-utils/src/lib/shared-node-utils.ts
Comment thread libs/shared/node-utils/src/lib/__tests__/shared-node-utils.encryption.spec.ts Outdated
@paustint paustint force-pushed the sec/jwt-token-encryption-improvement branch from 3b1a826 to 06aa30a Compare June 1, 2026 22:46
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