Skip to content

fix: close five ingestion and stream-handling security gaps - #159

Merged
VibeSWE merged 5 commits into
mainfrom
fix/ingest-security-hardening
Nov 24, 2026
Merged

VibeSWE merged 5 commits into
mainfrom
fix/ingest-security-hardening

Conversation

@VibeSWE

@VibeSWE VibeSWE commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

  1. GET /api/v1/demodata required 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.
  2. The OTLP endpoints accepted internal streams. POST /v1/logs, /v1/metrics and /v1/traces did not check whether X-P-Stream names an internal stream, so a key allowed to ingest into one stream could write rows into pmeta or pstats. Internal streams are now refused before any stream is created or changed, as on /api/v1/ingest.
  3. A session could ingest into another tenant. In multi-tenant mode ingestion takes the tenant from 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.
  4. Internal stream names could be taken. A caller could create a stream named pmeta, pbilling or pstats before 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.
  5. x-p- headers could replace server-recorded fields. x-p-p_src_ip and x-p-p_user_agent replaced the recorded source address and user agent, 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.

The first commit also 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.

Behaviour changes

  • Clients that called /api/v1/demodata without credentials now get 401.
  • A request that sets x-p-p_src_ip, x-p-p_user_agent, x-p-p_format or x-p-p_timestamp no 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 --lib 1,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 stream pmeta got 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:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

🤖 Generated with Claude Code

VibeSWE and others added 5 commits November 23, 2026 15:40
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>
@VibeSWE VibeSWE added the bug Something isn't working label Nov 24, 2026
@VibeSWE
VibeSWE merged commit 69373e5 into main Nov 24, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant