Skip to content

fix(repo): harden gateway, admin and dashboard after audit - #4

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

dinhdev666 merged 5 commits into
mainfrom
fix/audit-hardening-pass

Conversation

@dinhdev666

Copy link
Copy Markdown
Owner

Audit-driven hardening pass across the gateway, admin API, database layer, dashboard and tooling.

Gateway

  • A timed-out provider is now logged, cooled down and failed over; the aggregated 504 upstream_timeout is only returned once every candidate was tried (previously a single slow provider 504'd the request and left no attempt row).
  • An upstream body-read failure on a 2xx answers 502 instead of echoing the 2xx status with an error envelope.
  • Unknown /v1/* paths are handled inside the authenticated gateway scope: API key required, exactly one request_logs row.
  • Request bodies are captured as raw bytes and forwarded byte-for-byte (invalid UTF-8 included); the model id is trimmed into the forwarded body.
  • SSE: partial frames are capped (1 MiB) and the idle gap uses the new stream_idle_timeout_ms setting; Accept, anthropic-version and response headers (retry-after, rate-limit, request ids) are relayed; header values are sanitized.
  • Cooldown now also covers network failures, 408/409/425 and redirects; 429 all_providers_rate_limited carries Retry-After and x-opencode-router-cooldown-until.
  • Authorization accepts the Bearer scheme only; event emission is guarded; provider credentials are redacted from error messages.

Admin / DB

  • SSRF guard closed for trailing-dot hosts and now also applies to sync paths; /providers/test only reuses a stored key for its own origin; provider id/name/baseUrl/upstream_user_agent reject control characters and credentialed URLs.
  • Deleting a provider removes its synced models; PATCH /providers/:id resets status/cooldown when the URL, key or enabled flag changes; /models/bulk is capped and atomic; PATCH /settings validates everything before writing.
  • x-forwarded-proto only affects the Secure cookie flag when TRUST_PROXY is enabled; the events stream revalidates the session on every heartbeat and is capped; login guard gains a global per-window limit.
  • Prepared-statement cache, new indexes, SQL percentiles, hot-path count helpers, sync upsert without N+1.
  • Audit entries carry session:<id> + client IP and are pruned by the new audit_retention_days; graceful shutdown drains in-flight requests.

Dashboard

  • Key rotation UI, log key/provider filters, upstream_user_agent/retention/idle fields, top providers/keys cards, export truncation warning, in-flight states, per-id model toggle guard, stale defaultEffort cleanup, OS theme default, hidden-tab polling pauses and a11y fixes (inert modal background, real ids, aria-pressed, touch-visible row actions).

Tests / CI / docs

  • e2e: 75 -> 86 checks (single-log-row settle assertions, aborted-request, cookie flags, revoked key, non-retryable 400, 503 failover, timeout 504, brute-force 429, no key material in admin JSON, x_opencode on every surface, port fail-fast).
  • New scripts/check-docs.ts (env vars, routes, settings vs docs/SPEC.md/docs/API.md) wired into CI; tests/scripts are type-checked via tsconfig.test.json; commit linter hardened (Unicode lowercase, real merge detection, empty range fails).
  • docs/SPEC.md, docs/API.md, README.md, AGENTS.md, CONTRIBUTING.md updated with the new behaviour and settings.

Verification: pnpm typecheck, pnpm test (242 tests), pnpm build, pnpm check:docs (no drift), pnpm test:e2e (86/86), and pnpm exec tsx scripts/screenshots.ts --strict (all pages render, no console errors).

@dinhdev666
dinhdev666 merged commit ca81911 into main Dec 6, 2026
3 checks passed
@dinhdev666
dinhdev666 deleted the fix/audit-hardening-pass branch December 6, 2026 13:21
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