Repository navigation
fix: close five ingestion and stream-handling security gaps - #159
Merged
Merged
Conversation
GET /api/v1/demodata had no authentication layer. Any caller could make the server run its demo script, which ingests rows and creates dashboards, alerts and filters with the deployment's root credentials. The route now requires an authenticated caller. Adds a test-only helper that installs a PARSEABLE backed by a temporary local store, so route tests can run code that reads the global configuration. Found and first drafted by a GLM-5.3 review agent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
setup_otel_stream, which serves POST /v1/logs, /v1/metrics and /v1/traces, did
not check whether X-P-Stream names an internal stream, unlike /api/v1/ingest
and /api/v1/logstream/{name}. Because check_auth matches any stream-scoped
permission against internal streams, a key allowed to ingest into one user
stream could write rows into pmeta or pstats and change their log source.
Internal streams are now refused before any stream is created or changed.
Found and first drafted by a GLM-5.3 review agent.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
In multi-tenant mode ingestion takes the tenant from the x-p-tenant header. Basic credentials were checked against that tenant, but a session was not, so a session issued in one tenant could ingest and create streams in another: authorization ran against the session's tenant while the handler wrote to the claimed one. A session must now claim its own tenant. Single-tenant mode is unaffected. Found and first drafted by a GLM-5.3 review agent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A caller could create a user stream named pmeta, pbilling or pstats before the server created its own, after which the server's bookkeeping would be written into a caller-owned stream. Creation of a non-internal stream with one of these names is now refused. Existing streams with these names still load. Found and first drafted by a GLM-5.3 review agent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Custom x-p-<key> headers become fields of every ingested row. They were applied after the server recorded the source address and user agent, so x-p-p_src_ip and x-p-p_user_agent replaced the recorded values, x-p-p_format replaced the format, and x-p-p_timestamp added a second p_timestamp column. Headers for those four fields are now ignored; other custom fields are unchanged. Found and first drafted by a DeepSeek V4.1 Flash review agent. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Five fixes to ingestion and stream handling, found by review agents during the OTLP protobuf work. Each is its own commit with a test.
GET /api/v1/demodatarequired no authentication. Any caller could make the server run its demo script, which ingests rows and creates dashboards, alerts and filters with the deployment's root credentials. The route now requires an authenticated caller.POST /v1/logs,/v1/metricsand/v1/tracesdid not check whetherX-P-Streamnames an internal stream, so a key allowed to ingest into one stream could write rows intopmetaorpstats. Internal streams are now refused before any stream is created or changed, as on/api/v1/ingest.x-p-tenant. Basic credentials were checked against that tenant but a session was not, so a session from one tenant could ingest and create streams in another. A session must now claim its own tenant. Single-tenant mode is unaffected.pmeta,pbillingorpstatsbefore the server did, after which the server's own records went into a caller-owned stream. Creating a non-internal stream with one of these names is now refused. Existing streams with these names still load.x-p-headers could replace server-recorded fields.x-p-p_src_ipandx-p-p_user_agentreplaced the recorded source address and user agent,x-p-p_formatreplaced the format, andx-p-p_timestampadded a secondp_timestampcolumn. Headers for those four fields are now ignored; other custom fields are unchanged.The first commit also adds a test-only helper that installs a
PARSEABLEbacked by a temporary local store, so route tests can run code that reads the global configuration.Behaviour changes
/api/v1/demodatawithout credentials now get 401.x-p-p_src_ip,x-p-p_user_agent,x-p-p_formatorx-p-p_timestampno longer changes those fields.Verified
cargo test --lib: 1,429 passed, 0 failed.With all six PRs of this set merged together (#156–#161):
cargo test --lib1,515 passed, 0 failed, and on a running server every one of 17 protobuf requests (15 realistic shapes filling the 10 MiB payload limit, 2 crafted) returned 200 and stored the expected number of rows, authenticated with an API key. On that server an OTLP request without credentials got 401 and one naming the internal streampmetagot 400.Merging
Independent of the OTLP PRs and merges cleanly with them. It conflicts with the request-overhead PR in one place, where both append tests to the same module in
ingest_utils.rs; keep both.This PR has:
🤖 Generated with Claude Code