Skip to content

fix: pass seconds (not ms) to Redis EXPIRE for admin signature replay cache - #3963

Open
SashaMIT wants to merge 1 commit into
interledger:mainfrom
SashaMIT:fix/admin-api-signature-redis-ttl-seconds
Open

fix: pass seconds (not ms) to Redis EXPIRE for admin signature replay cache#3963
SashaMIT wants to merge 1 commit into
interledger:mainfrom
SashaMIT:fix/admin-api-signature-redis-ttl-seconds

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

canApiSignatureBeProcessed (backend and auth) computes ttlMilliseconds = adminApiSignatureTtlSeconds * 1000 for the Date.now() signature-age check, then passes that same value to redis.expire.

Redis EXPIRE takes seconds. With the default ADMIN_API_SIGNATURE_TTL_SECONDS=30, replay-cache keys were retained for ~30000 seconds (~8.3 hours) instead of 30 seconds.

Direction is fail-safe for replay protection (keys live longer than intended), but it causes unnecessary Redis memory retention under admin traffic. The auth session store already converts correctly (expireInSec = maxAgeMs / 1000 + 10 in auth/src/app.ts).

Fix

  • Keep milliseconds for the wall-clock age check.
  • Pass ttlSeconds to redis.expire in both packages.
  • Extend the existing "already processed" tests to assert redis.ttl(signature:…) is within the configured second window (a ms/seconds mixup would leave TTL ≈ ttlSeconds * 1000).

Verification

Local unit-mismatch repro (no Redis required): default 30s config → code previously passed 30000 to EXPIRE → 8.33h TTL. Full Jest suites need the Postgres/Redis testcontainers environment.

Made with Cursor

… cache

canApiSignatureBeProcessed multiplied the configured TTL by 1000 for the
Date.now() age check, then reused that millisecond value in redis.expire.
Redis EXPIRE takes seconds, so replay-cache keys lived 1000x longer than
intended (default 30s → ~8.3h) in both backend and auth. Keep ms for the
age check; pass ttlSeconds to EXPIRE. Assert redis.ttl stays within the
configured second window.

Co-authored-by: Cursor <cursoragent@cursor.com>
@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit 1ba3e7c
🔍 Latest deploy log https://app.netlify.com/projects/brilliant-pasca-3e80ec/deploys/6a768b82ede77f000857c4af

@github-actions github-actions Bot added type: tests Testing related pkg: backend Changes in the backend package. type: source Changes business logic pkg: auth Changes in the GNAP auth package. labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: auth Changes in the GNAP auth package. pkg: backend Changes in the backend package. type: source Changes business logic type: tests Testing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant