Skip to content

fix(web): bound stale portal signing keys and serialize JWKS refreshes - #1005

Open
defangdevs wants to merge 1 commit into
masterfrom
fix/634-jwks-stale
Open

defangdevs wants to merge 1 commit into
masterfrom
fix/634-jwks-stale

Conversation

@defangdevs

Copy link
Copy Markdown
Owner

Fixes #634.

Symptom: with JWKS fetches failing, cached keys were trusted forever (a year-old set was returned), and six concurrent requests caused six fetches.

  • portal_jwks_keys drops keys older than JWKS_MAX_STALE (2h = TTL + 1h grace) on every return path: cooldown, failed fetch and fresh.
  • Cache read/decide/reserve runs under a thread + flock lock, and attempted is written before the network call, so concurrent requests fetch at most once.
  • docs/portal-handoff.md states the two-hour bound.
  • New portal-jwks check (tests/test-portal-jwks.py): expired keys rejected on failed fetch and during cooldown, grace still served, bound survives repeated failures, six threads -> one fetch.

Checks run (aarch64): portal-jwks, module-generated-up-to-date, golden-snapshot. Regenerated modules/agent-box.nix and tests/golden/.

🤖 Generated with Claude Code

#634)

Every return path of portal_jwks_keys now enforces JWKS_MAX_STALE (two
hours since the last successful fetch), including the refresh cooldown and
failed-fetch paths. The refresh attempt is reserved under a file lock
before the network call, so concurrent requests cause at most one fetch.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RVYuG58Xp5uVuw6PdS6GHW
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3f7e89e0-23c3-4ef2-9656-d5193847dd28
Commits

Reviewing files that changed from the base of the PR and between 50c659f and 6904289.

Files selected for processing: 6

  • docs/portal-handoff.md
  • flake.nix
  • modules/agent-box.nix
  • modules/src/settings-daemon.py
  • tests/golden/web/payloads/agent-box-settings/bin/agent-box-settings
  • tests/test-portal-jwks.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

security: bound stale portal signing keys and serialize JWKS refreshes

1 participant