Skip to content

receive: validate grpc remote write tenant#8817

Open
officialasishkumar wants to merge 3 commits into
thanos-io:mainfrom
officialasishkumar:receive-validate-grpc-tenant
Open

receive: validate grpc remote write tenant#8817
officialasishkumar wants to merge 3 commits into
thanos-io:mainfrom
officialasishkumar:receive-validate-grpc-tenant

Conversation

@officialasishkumar

Copy link
Copy Markdown
  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixes #8812.

  • Validate the tenant carried by gRPC RemoteWrite before the ingestor-only fast path or router fanout uses it.
  • Use the configured/default tenant for empty gRPC tenant values, matching HTTP receive behavior when no tenant header is supplied.
  • Return InvalidArgument for invalid tenant values instead of using them to select or create TSDB directories.

Verification

  • go test -tags slicelabels ./pkg/receive -run 'TestReceiveGRPCTenantValidation|TestTenantFromWriteRequest|TestReceiveTenantValidation|TestHandlerSplitTenantLabelLocalWrite|TestReceiveQuorumHashmod|TestReceiveQuorumKetama' -count=1

@GiedriusS GiedriusS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please refactor so the same GetTenantFromHTTP could be reused? I think we can just remove *http.Request there and pass some generic types.

@officialasishkumar

Copy link
Copy Markdown
Author

Done in 0a7cb2f: GetTenantFromHTTP now delegates to generic metadata extraction shared with the gRPC write path. Focused tenancy, receive, and query compile checks passed.

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
@officialasishkumar officialasishkumar force-pushed the receive-validate-grpc-tenant branch from 0a7cb2f to 00b3c95 Compare May 20, 2026 09:21
@officialasishkumar

Copy link
Copy Markdown
Author

Refactored the gRPC tenant validation to reuse GetTenantFromHTTP through a generic header getter in 00b3c95.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Receive gRPC RemoteWrite: Tenant field not validated (path traversal)

2 participants