Skip to content

fix(dashboard): enforce localhost bind, API token auth, and credential redaction (#137) - #359

Merged
Kaap10 merged 1 commit into
codeforstartups:developmentfrom
Lawliet2004:fix/dashboard-security-137
Nov 30, 2026
Merged

Kaap10 merged 1 commit into
codeforstartups:developmentfrom
Lawliet2004:fix/dashboard-security-137

Conversation

@Lawliet2004

Copy link
Copy Markdown
Contributor

Description

Hardens the observability dashboard server so AWS credentials never reach the browser, the API binds only to loopback hosts by default, and all /api/* endpoints require a server-side API token.

Related issue

Fixes #137

Changes

  • Enforced loopback-only host binding by default in create_server() and serve() (127.0.0.1, localhost, ::1), requiring an explicit allow_remote=True opt-in for non-loopback hosts.
  • Added server-side API token resolution (api_token=, DYNAVEC_DASHBOARD_TOKEN, or auto-generated 256-bit secrets.token_urlsafe(32)) verified with hmac.compare_digest via Authorization: Bearer or X-Dynavec-Token on all /api/* routes (rejecting query-string tokens and returning 401 with WWW-Authenticate: Bearer).
  • Added Origin validation and CORS preflight (OPTIONS) handling for loopback origins and explicit allowed_origins, returning 403 for untrusted origins.
  • Passed all JSON API responses through dynavec.logging.redact_secrets() and added Cache-Control: no-store, X-Content-Type-Options: nosniff, and Referrer-Policy: no-referrer headers.
  • Added integer bounds validation for window and limit query parameters (returning 400 instead of crashing with ValueError).
  • Updated dashboard/lib/api.ts to forward NEXT_PUBLIC_DYNAVEC_TOKEN via X-Dynavec-Token and documented the security model in dashboard/README.md and tools/build_docs.py.
  • Added offline HTTP security tests in tests/test_dashboard_security.py.

Testing

  • Tests pass locally (make run-ci: ruff, strict mypy across 90 files, and full pytest suite)
  • Ruff checks pass
  • Documentation updated, if applicable

Checklist

  • My changes are focused and relevant to this pull request.
  • I have added or updated tests where appropriate.
  • I have reviewed my changes for unrelated modifications.
  • I have updated documentation where necessary.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Kaap10 Kaap10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks for hardening the dashboard server with loopback binding, constant-time token auth, origin validation, and secret redaction. Approved and ready to merge.

@Kaap10
Kaap10 merged commit 8f3f859 into codeforstartups:development Nov 30, 2026
4 checks passed
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.

Dashboard: security — local-only, server-side creds, API token

3 participants