pingcap / pingcap/tidb

The permission check of `ALTER RANGE ... PLACEMENT POLICY` is missing

Open
#62,420 0 comments 0 reactions 0 assignees View on GitHub
type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

The permission check of `ALTER RANGE ... PLACEMENT POLICY` is missing. A user without any privileges can also execute this statement.

It can be reproduced on docker image `pingcap/tidb:nightly`.

### 1. Minimal reproduce step (Required)

1. Create an empty user with root:
```sql
-- login as user 'root'
CREATE PLACEMENT POLICY `five_replicas` FOLLOWERS=4;
CREATE USER foo;
```

2. Log in as the user foo and execute:
```sql
-- login as user 'foo'
ALTER RANGE global PLACEMENT POLICY = default;
ALTER RANGE global PLACEMENT POLICY = 'five_replicas';
-- Query OK, 0 rows affected (0.00 sec)
```

### 2. What did you expect to see? (Required)

These statements should fail when executed by a user without any privileges.

### 3. What did you see instead (Required)

These statements are executed successfully.

### 4. What is your TiDB version? (Required)

```
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v9.0.0-beta.1.pre-533-g671534a
Edition: Community
Git Commit Hash: 671534a755e5ac3fbb5b515cc15f4d54142e6810
Git Branch: HEAD
UTC Build Time: 2025-04-09 14:12:27
GoVersion: go1.23.8
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two ALTER RANGE ... PLACEMENT POLICY statements from the issue with an unprivileged user, then trace how TiDB handles their authorization. Done means both statements are rejected for a user without privileges while authorized execution continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
authorization, databases, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.