caelum0x 357abb92c8 fix(relay): gate raw observability/dataset/internal routes to operator keys
Relay serves many Railyard products from one shared gateway, each with its
own API key, but the upstream TensorZero inference-listing, dataset,
evaluation and /internal/* routes carry zero per-key scoping (unlike
/relay/traces, /relay/billing/* and the provider-key/catalog-price editors,
which already check require_operator or scope to the caller's own key).

Reproduced live: used Rally's real production key to run one inference with
a unique marker prompt, then fetched that same inference's full prompt,
output and tags (including its owning api_key_public_id) using Menivor's
completely different key via POST /v1/inferences/get_inferences - any
tenant could read any other tenant's full inference history, datasets, and
raw object-storage bytes.

Fix: route_layer a require_operator_middleware over build_observability_routes
(list/get_inferences), build_datasets_routes, build_optimization_routes,
build_gepa_routes, build_evaluations_routes, and all of
build_internal_non_otel_enabled_routes except /internal/autopilot/status
(which must stay fully unauthenticated as a liveness probe). A missing
principal still passes through unchanged, so a single-tenant deployment
with [gateway.auth] off (the TensorZero default, and every e2e test that
doesn't configure auth) is unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-29 17:49:21 +03:00
..