Skip to content

fix: store hashed token fingerprints in the JWT blacklist - #3795

Open
jbair06 wants to merge 1 commit into
mainfrom
3794-hash-blacklisted-jwt-keys
Open

jbair06 wants to merge 1 commit into
mainfrom
3794-hash-blacklisted-jwt-keys

Conversation

@jbair06

@jbair06 jbair06 commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

The blacklist now keys on a SHA-256 fingerprint of the token instead of the raw JWT, matching how OTP codes are hashed. Legacy raw-key entries are still checked until they expire, with a TODO to remove that lookup.

Fixes #3794

Fixes TT-019

Blacklist keys are now a SHA-256 of the token; legacy raw keys are still honored until they expire.

Signed-off-by: John Bair <john.bair@swirldslabs.com>
@jbair06
jbair06 requested a review from a team as a code owner November 21, 2026 00:14
@jbair06
jbair06 requested a review from ericleponner November 21, 2026 00:14
@jbair06 jbair06 self-assigned this Nov 21, 2026
@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.98%. Comparing base (424ed25) to head (564f16f).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3795   +/-   ##
=======================================
  Coverage   99.98%   99.98%           
=======================================
  Files         224      224           
  Lines        7034     7034           
  Branches     1302     1276   -26     
=======================================
  Hits         7033     7033           
  Misses          1        1           

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jbair06 jbair06 added Bug A error that causes the feature to behave differently than what was expected based on design docs Backend labels Nov 21, 2026
@jbair06 jbair06 added this to the v0.43.0 milestone Nov 21, 2026
@jbair06
jbair06 requested a lite review from Copilot November 21, 2026 00:53

Copilot AI 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.

🟡 Changes recommended

A critical rolling-deployment compatibility issue remains: old instances read only raw blacklist keys while new instances write only hashed keys, allowing blacklisted tokens to remain accepted.

1 open issue
What changed in this PR

Updates JWT blacklist storage to use SHA-256 token fingerprints instead of raw JWT Redis keys while retaining temporary compatibility with legacy entries.

Changes:

  • Stores newly blacklisted tokens under hashed fingerprint keys.
  • Checks hashed and legacy raw-token keys during migration.
  • Expands unit tests for hashing, compatibility lookups, and Redis errors.
File Description
back-end/​libs/​common/​src/​blacklist/​blacklist.service.ts Implements hashed JWT blacklist keys and temporary legacy raw-key lookup support.
back-end/​libs/​common/​src/​blacklist/​blacklist.service.spec.ts Tests hashed storage, legacy compatibility lookups, and Redis failure handling.

Review effort: Lite

async blacklistToken(jwt: string | null) {
if (jwt !== null) {
await this.client.set(jwt, this.BLACKLISTED, 'EX', this.getJwtExpirationSeconds());
await this.client.set(this.getTokenKey(jwt), this.BLACKLISTED, 'EX', this.getJwtExpirationSeconds());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Bug A error that causes the feature to behave differently than what was expected based on design docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store hashed token fingerprints in the JWT blacklist

2 participants