Skip to content

fix(repo): harden gateway auth, fidelity and dashboard flows - #3

Merged
dinhdev666 merged 2 commits into
mainfrom
fix/hardening-pass
Dec 6, 2026
Merged

dinhdev666 merged 2 commits into
mainfrom
fix/hardening-pass

Conversation

@dinhdev666

Copy link
Copy Markdown
Owner

What changed

Implements the full improvement pass: security hardening (spoofable request.ip/brute-force bypass, provider-URL SSRF, secret rotation durability, CSV formula injection), pass-through fidelity (pre-body auth, verbatim bodies and stream bytes, redirect refusal, real timeouts and backpressure), missing features (rotation strategies, Retry-After, per-session revoke, API key rotation, exact 60s stats, scheduler cooldown probe) and dashboard fixes (focus management, keyboard-accessible logs, stale detail, filters, chart time axis, dirty-edit protection). Docs and config templates were refreshed to match.

Surface affected

  • Gateway (/v1/*) — chat completions / responses / messages / models
  • Admin API (/admin/api/*)
  • Dashboard (web/)
  • Database schema or repositories (new indexes, deleteOtherSessions, deleteAuditBefore, rotateApiKey, statsOverview.requestsLast60s/errorsLast60s)
  • Docs / CI / tooling only

Verification

  • pnpm typecheck
  • pnpm test — 110/110 (was 20)
  • pnpm build
  • pnpm test:e2e — 75/75 (was 51)
  • Manual check against a real provider (pnpm test:live) — N/A

Checklist

  • Commit messages and the PR title follow Conventional Commits
  • No secrets, API keys, database files or .env files are included
  • docs/SPEC.md updated (auth hook ordering, cookie format, rotation strategies, streaming/redirect/timeout behaviour, admin session + key + settings contract, logging rules)
  • Streaming pass-through fidelity preserved (original bytes written; re-encoding only for frames actually rewritten)
  • Dashboard changes keep dark/light parity

Deliberate deviations / deferred

  • log_store_bodies was removed (it never stored anything) instead of implementing body capture with redaction/retention — avoids a false forensic/privacy promise.
  • FIX-28: latency percentiles are still computed in JS over an indexed scan, now behind the ~2s stats TTL cache; prepared-statement caching in Repo was not done.
  • Provider↔model ownership for shared model ids is documented as a limitation (no membership table).
  • Feature ideas not shipped: per-key rpm quota, SSE Last-Event-ID replay, audit filters, cross-platform Chrome resolution in scripts/screenshots.ts (documented instead).

🤖 Generated with Claude Code

Gateway
- authenticate /v1/* in an onRequest hook before the body is parsed; rejected
  requests still write exactly one request_logs row (paired start/end events)
- forward request bodies verbatim when normalization is a no-op, and stream the
  original upstream bytes (invalid UTF-8/BOM preserved), with backpressure
- real total + idle timeouts for streamed bodies, client-abort propagation
- refuse upstream redirects (redirect: 'manual'), forward a client header
  allowlist (anthropic-beta, x-stainless-*, trace headers)
- rotation_strategy now implements round-robin, priority and random;
  cooldown skips no longer create attempt rows; fatal errors keep provider
  attribution; retry-after extends the provider cooldown
- /v1/models* is logged like every other request; request id on every response

Security
- TRUST_PROXY opt-in (default false) so X-Forwarded-For can no longer bypass the
  dashboard login brute-force guard or forge client_ip
- provider test/sync SSRF guard (PROVIDER_ALLOW_PRIVATE_HOSTS opt-in)
- rotate-secret refuses with 409 when ROUTER_SECRET is set, persists before the
  swap, and returns cache-control: no-store
- CSV export neutralises formula injection; admin 500s no longer echo internals
- revoke-all sessions no longer stops at the 50 newest; login/password routes
  have a 4 KB body limit and a 200-char password cap

Admin
- per-session revoke endpoint, API key rotation, provider test with a draft
  baseUrl against the stored key, provider test failures recorded
- stats expose exact requestsLast60s/errorsLast60s behind a short TTL cache
- scheduler probes cooled-down providers; settings whitelist ignores inherited
  property names; log filters are validated strictly; log_store_bodies removed

Dashboard
- focus trap/autofocus/restore for Modal, Drawer and the mobile sidebar
- keyboard-accessible log rows, no stale request detail, stable time filters,
  clamped pagination, time-proportional charts, working live tail in poll mode
- provider id on create, draft connection test, all rotation strategies,
  per-session revoke UI, dirty-edit protection, secret modal survives rotation

Docs/tests
- SPEC/API/README/CONTRIBUTING/AGENTS/.env.example updated; Node floor 22.13
- 110 unit tests and 75 e2e acceptance checks (previously 20/51)
pnpm/action-setup@v4 rejects a workflow `version` input when package.json
declares `packageManager` (Multiple versions of pnpm specified). Drop the
duplicated input so package.json stays the single source of truth.
@dinhdev666
dinhdev666 merged commit a7955dd into main Dec 6, 2026
3 checks passed
@dinhdev666
dinhdev666 deleted the fix/hardening-pass branch December 6, 2026 12:08
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.

1 participant