Skip to content

fix: reject path-like tenant IDs before WAL join - #7790

Open
SashaMIT wants to merge 1 commit into
grafana:mainfrom
SashaMIT:fix/reject-path-like-generator-tenant
Open

fix: reject path-like tenant IDs before WAL join#7790
SashaMIT wants to merge 1 commit into
grafana:mainfrom
SashaMIT:fix/reject-path-like-generator-tenant

Conversation

@SashaMIT

Copy link
Copy Markdown

What this PR does:

storage.New already rejects an empty tenant because filepath.Join(cfg.Path, "") plus os.RemoveAll would wipe the metrics-generator WAL root. A tenant of .. still escapes: Join resolves to the parent of cfg.Path, then RemoveAll deletes that parent.

HTTP PushSpans is already covered. validation.ExtractValidTenantID goes through dskit/tenant.TenantID, which calls ValidTenantID and rejects . / .. / /. Kafka ingest does not. generator_kafka.go takes string(r.Key) and calls getOrCreateInstance with no tenant check, so a record keyed .. still reaches storage.New.

This PR runs the same dskit/tenant.ValidTenantID check in storage.New before the Join. Empty stays the existing error. ., .., and IDs with unsupported characters (including /) return invalid tenant ID.

I used Cursor while writing the change and tests. I reviewed every line and ran the new cases locally.

Which issue(s) this PR fixes:
n/a

Checklist

  • Tests updated
  • Documentation added
  • Changelog entry added under .chloggen/ (run make chlog-new, or make chlog-new FILENAME=<name> to override the default branch-name file; see .chloggen/README.md)

Made with Cursor

storage.New already refused an empty tenant because Join plus RemoveAll
would wipe the WAL root. A tenant of ".." still escaped to the parent
directory. Kafka ingest uses the record key as the tenant and never
runs ExtractValidTenantID, so this is the last gate.

Signed-off-by: Sasha Mitchell <sash.t.mitchell@gmail.com>
@cla-assistant

cla-assistant Bot commented Aug 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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