Skip to content

Do not short-circuit tenant resolver chain when query string tenant value is blank#25212

Merged
ebicoglu merged 2 commits into
rel-10.2from
enhance/query-string-tenant-resolve
Apr 8, 2026
Merged

Do not short-circuit tenant resolver chain when query string tenant value is blank#25212
ebicoglu merged 2 commits into
rel-10.2from
enhance/query-string-tenant-resolve

Conversation

@maliming

@maliming maliming commented Apr 7, 2026

Copy link
Copy Markdown
Member

Previously, QueryStringTenantResolveContributor set context.Handled = true when the __tenant query string parameter was present but its value was empty or whitespace. This caused the tenant resolver chain to stop early, preventing subsequent resolvers (e.g. header, cookie) from being evaluated.

While this is not a real security vulnerability since user credentials are still validated regardless of the resolved tenant context, it is an unexpected behavior: a blank query string value should not suppress a valid tenant header.

This change removes the Handled = true for blank values, allowing the resolver chain to continue to later resolvers. Unit tests have been added to cover this scenario.

Related: volosoft/volo#22072

Copilot AI review requested due to automatic review settings April 7, 2026 01:03
@maliming maliming added this to the 10.2-patch milestone Apr 7, 2026
@maliming maliming requested a review from ebicoglu April 7, 2026 01:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes tenant resolution so that an empty/whitespace __tenant (or configured TenantKey) query-string parameter no longer stops the tenant resolver pipeline, allowing later contributors (e.g., header/cookie) to resolve the tenant as expected.

Changes:

  • Updated QueryStringTenantResolveContributor to return null (without setting context.Handled) when the query-string tenant value is blank.
  • Added unit tests to verify header resolution still works when the query-string tenant value is empty, and that host fallback occurs when no other resolver provides a tenant.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/QueryStringTenantResolveContributor.cs Stops short-circuiting the resolver chain when the query-string tenant value is blank.
framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests/Volo/Abp/AspNetCore/MultiTenancy/AspNetCoreMultiTenancy_Without_DomainResolver_Tests.cs Adds coverage for the “empty query-string value” scenario (header wins; otherwise host fallback).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@ebicoglu ebicoglu merged commit 0cf6cb8 into rel-10.2 Apr 8, 2026
7 of 8 checks passed
@ebicoglu ebicoglu deleted the enhance/query-string-tenant-resolve branch April 8, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants