Skip to content

fix: close the defects a sixth audit found - #7

Merged
dinhdev666 merged 1 commit into
mainfrom
fix/audit-defects-and-improvements
Nov 24, 2026
Merged

dinhdev666 merged 1 commit into
mainfrom
fix/audit-defects-and-improvements

Conversation

@dinhdev666

Copy link
Copy Markdown
Owner

Closes the six-audit defect list and adds the four proposals that came with it.

Security. An absolute-form request target (GET http://host/v1/...) bypassed gateway key authentication: the path it was checked against still carried its scheme and authority, no public-path rule matched, and the request reached the route unauthenticated. Model ids and names reported by a provider are now bounded.

Correctness. [DONE] no longer glues onto a stream that ends on a lone \r; an exception in post-attempt bookkeeping no longer leaks the slot and the half-open probe; a full queue answers 503 queue_full rather than inheriting an earlier attempt's 502; a stalled CSV reader is closed; a key stored before start-up is masked; stored settings overrides are validated.

Features. GET /metrics (Prometheus, off by default, token-gated), node index.js --version, POST /api/providers/:id/probe, and vitest over the dashboard.

Verified locally: pnpm run check, pnpm run typecheck, pnpm run test:web (17 tests), pnpm test (7 files), and SMOKE_SLOW=1 pnpm test:smoke.

Security first. A request target in absolute form (`GET http://host/v1/...`)
was authenticated against a path that still carried its scheme and authority, so
no public-path rule matched and the gateway key was never checked: the request
reached the route unauthenticated and answered `404 endpoint_not_available`
where every origin-form request got a `401`. The path is now derived once, in
`src/http/request-path.js`, and every caller uses it.

Provider-reported model ids and names are now bounded at 200 characters, because
an upstream could otherwise store a string of any length in a column the public
model list reads back on every request.

Correctness. A stream ending on a lone `\r` had the appended `[DONE]` glued onto
its last event, which is a frame the client cannot parse. An exception during
post-attempt bookkeeping leaked the provider slot and the half-open probe. A full
queue could answer `502` because the refusal was overwritten by an earlier
attempt's error. A stalled CSV reader held the export open for hours. A provider
key stored before the process started was never masked in a later log line.
Settings read stored overrides without validating them, so a row written by an
older build could contradict the schema the dashboard renders.

Observability and the dashboard. `recordStreamFailure` charged every in-band
failure to the breaker, so one client sending oversized streaming prompts could
open a healthy provider's breaker; it now uses the same classification the
buffered path does. Non-counting outcomes no longer raise the provider's failure
statistics. Pending auth errors expire. The breaker reads the registry's
injectable clock. Out-of-schedule providers say "back at 14:00" instead of
"back at {at}", timestamps name their time zone, `RangeTabs` reports
`aria-pressed`, a `Field` describes its control to a screen reader, and the Keys
tab locks a revealed secret again after 30 seconds.

Hygiene. `UpstreamClient` releases an agent when a provider is removed or its
endpoint changes. `ModelRepository.create()` no longer erases the operator's
display name and notes on conflict. `keyPrefix()` stops publishing the tail that
`maskSecret()` refuses to print. Brand icons are read once and served with an
ETag. An unauthenticated `GET /v1/models/:id` no longer runs a model query per
request.

Features. `GET /metrics` serves a Prometheus document from the numbers the
Overview tab already reads: off unless `METRICS_ENABLED` is on, refusing a scrape
while `METRICS_TOKEN` is blank, and labelling a provider by id rather than by
name or endpoint. `node index.js --version` prints the version and exits.
`POST /api/providers/:id/probe` runs the health prober's single-provider probe on
demand. The dashboard gains vitest, so the copy table, the formatters and the
component kit's accessibility wiring are asserted without a browser.

Documentation caught up with the code: settings persistence is the SQLite table,
not `config.json`; the slow CI pass runs on one Node version; `src/http/` is in
the repository map; the configuration tables are checked against the schema, not
generated from it.

Refs: audit report of 2026-11-24
@dinhdev666
dinhdev666 merged commit dda7ba7 into main Nov 24, 2026
6 checks passed
@dinhdev666
dinhdev666 deleted the fix/audit-defects-and-improvements branch November 24, 2026 05:43
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