Skip to content

Fix SHOW QUERIES and KILL QUERY privilege filtering - #18359

Open
shuwenwei wants to merge 4 commits into
masterfrom
fix-show-queries-system-privilege
Open

Fix SHOW QUERIES and KILL QUERY privilege filtering#18359
shuwenwei wants to merge 4 commits into
masterfrom
fix-show-queries-system-privilege

Conversation

@shuwenwei

@shuwenwei shuwenwei commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Restrict tree-model SHOW QUERIES results to the current user when the user does not satisfy the MAINTAIN authorization check.
  • Restrict tree-model KILL QUERY to the current user's queries under the same condition.
  • Allow users with the SYSTEM privilege, which contains the deprecated MAINTAIN privilege, to view and kill queries from all users.
  • Add IoTDBShowQueriesIT and IoTDBKillQueryIT with queries that remain active across Session fetches.

Root cause

TreeAccessCheckVisitor.visitShowQueries and visitKillQuery set allowedUsername when the MAINTAIN authorization check succeeded instead of when it failed. As a result, an unprivileged user could see or kill other users' queries, while a privileged user could be unnecessarily restricted.

Impact

Tree-model SHOW QUERIES and KILL QUERY now apply the intended visibility and control rules while retaining the existing MAINTAIN authorization check.

Validation

  • Added integration tests that leave result sets unconsumed and verify query visibility and kill permissions before and after granting SYSTEM; the tests do not grant deprecated MAINTAIN directly.
  • Tests were not run locally, following the repository instruction not to proactively run build or test checks unless requested.

@shuwenwei shuwenwei changed the title [codex] Fix SHOW QUERIES privilege filtering Fix SHOW QUERIES privilege filtering Jul 30, 2026
@shuwenwei
shuwenwei marked this pull request as ready for review July 30, 2026 03:35
@shuwenwei
shuwenwei requested a review from HTHou July 30, 2026 03:36
@shuwenwei shuwenwei changed the title Fix SHOW QUERIES privilege filtering [codex] Fix SHOW QUERIES and KILL QUERY privilege filtering Jul 30, 2026
@shuwenwei shuwenwei changed the title [codex] Fix SHOW QUERIES and KILL QUERY privilege filtering Fix SHOW QUERIES and KILL QUERY privilege filtering Jul 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.39%. Comparing base (a8497be) to head (b1ce540).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...an/relational/security/TreeAccessCheckVisitor.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18359      +/-   ##
============================================
- Coverage     43.40%   43.39%   -0.01%     
  Complexity      374      374              
============================================
  Files          5366     5366              
  Lines        382885   382885              
  Branches      49796    49796              
============================================
- Hits         166187   166171      -16     
- Misses       216698   216714      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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