registry/internal/api/handlers/v0
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Radoslav Dimitrov fecef4f9ed
fix: don't leak internal error detail in GET /v0/servers 500 response (#1338)
## Summary
Fixes the information-disclosure regression introduced by #1335 (item 1
of #1337).

`ListServersError` passed the raw `err` into
`huma.Error500InternalServerError(...)`. huma serializes extra error
args into the response body's `errors` array (`ErrorModel.Errors`,
`json:"errors,omitempty"`), so on the **public, unauthenticated** `GET
/v0/servers` endpoint a genuine DB failure echoed the internal wrapped
error from `internal/database/postgres.go` (`error iterating rows: <pgx
error>`) back to the client. pgx/pgconn errors can carry SQLSTATE codes,
constraint/table/column names, and internal messages (CWE-209).

## Change
- Drop `err` from the 500 call so only the generic message is returned;
keep `log.Printf` for the server-side detail — matching the sibling
handlers (`servers.go:190/220`, `edit.go`, `status.go`).
- Add a regression test
(`TestListServersError_realFailureDoesNotLeakDetail`) that marshals the
500 error and asserts the internal detail is absent from the
client-visible body. Existing tests only asserted status codes, which is
why the leak slipped through.

The 499 client-cancelled path is unchanged (the client has already
disconnected, so nothing is leaked there).

## Test plan
- [x] `go test ./internal/api/handlers/v0/... -run ListServersError`
(3/3 pass)
- [x] `go build ./...`, `go vet`, `golangci-lint` (no new findings in
changed files)

## Note
This leaves the non-security items in #1337 (correcting the `superfluous
WriteHeader` claim, `statusClientClosed` const reuse, broader
cancellation-guard scope) for separate follow-up. Closing #1337 here
since the only security-impacting item is addressed; reopen/split if
you'd prefer to track the nits independently.

Closes #1337

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 03:08:33 -04:00
..
auth fix(auth/http): extend SSRF blocklist to IPv6 6to4/NAT64/site-local prefixes (#1250) 2026-05-04 09:41:23 -04:00
edit.go security: fix open redirect and add small hardening (#1227) 2026-04-29 19:14:00 -04:00
edit_test.go Publisher-managed "deleted" support (#893) 2026-02-27 09:00:07 -08:00
health.go Replace / with - for operation IDs (#660) 2025-10-14 15:26:43 +03:00
health_test.go Introduce v0.1 version of the API (#658) 2025-10-14 11:04:48 +03:00
list_errors.go fix: don't leak internal error detail in GET /v0/servers 500 response (#1338) 2026-06-05 03:08:33 -04:00
list_errors_test.go fix: don't leak internal error detail in GET /v0/servers 500 response (#1338) 2026-06-05 03:08:33 -04:00
ping.go Replace / with - for operation IDs (#660) 2025-10-14 15:26:43 +03:00
ping_test.go Introduce v0.1 version of the API (#658) 2025-10-14 11:04:48 +03:00
publish.go Added /validate endpoint and modified mcp-publish so that all validation happens there (#896) 2026-02-04 15:52:07 +02:00
publish_integration_test.go Make Repository field properly optional in server.json (#717) 2025-10-29 13:23:47 +00:00
publish_registry_validation_test.go Introduce v0.1 version of the API (#658) 2025-10-14 11:04:48 +03:00
publish_test.go Added /validate endpoint and modified mcp-publish so that all validation happens there (#896) 2026-02-04 15:52:07 +02:00
response.go auth: New auth flow (#273) 2025-08-15 13:03:35 +01:00
servers.go fix: client-cancelled GET /v0/servers returns 499 without error log (#1335) 2026-06-05 02:59:47 -04:00
servers_test.go Publisher-managed "deleted" support (#893) 2026-02-27 09:00:07 -08:00
status.go security: fix open redirect and add small hardening (#1227) 2026-04-29 19:14:00 -04:00
status_test.go Publisher-managed "deleted" support (#893) 2026-02-27 09:00:07 -08:00
telemetry_test.go Make Repository field properly optional in server.json (#717) 2025-10-29 13:23:47 +00:00
ui.go Add simple web UI for browsing the registry (#757) 2025-11-10 12:37:36 +00:00
ui_index.html fix(ui): encode publisher-controlled URLs for href attribute context (#1248) 2026-05-04 09:25:41 -04:00
validate.go Added /validate endpoint and modified mcp-publish so that all validation happens there (#896) 2026-02-04 15:52:07 +02:00
validate_test.go Added /validate endpoint and modified mcp-publish so that all validation happens there (#896) 2026-02-04 15:52:07 +02:00
version.go Introduce a /version API (#667) 2025-10-15 17:24:46 +03:00
version_test.go Introduce a /version API (#667) 2025-10-15 17:24:46 +03:00