Skip to content

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

Merged
mkurapov merged 3 commits into
interledger:mainfrom
SashaMIT:fix/admin-api-signature-redis-ttl-seconds
Oct 28, 2026
Merged

mkurapov merged 3 commits 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 ab462a9
🔍 Latest deploy log https://app.netlify.com/projects/brilliant-pasca-3e80ec/deploys/6ae1f607f4e050f0830dbe4e

@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
@mkurapov
mkurapov merged commit 40c29e9 into interledger:main Oct 28, 2026
58 checks passed
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.

2 participants