pingcap / pingcap/tidb

The permission check of a series of `SPLIT TABLE` commands is missing

Open
#62,427 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 a series of `SPLIT TABLE` commands is missing. A user without any privileges can also execute these commands.

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

The following commands are affected:
```sql
SPLIT PARTITION TABLE ... PARTITION BY
SPLIT TABLE ... PARTITION BY
SPLIT TABLE ... INDEX BY
SPLIT TABLE ... BY
```

### 1. Minimal reproduce step (Required)

1. Create an empty user with root:
```sql
-- login as user 'root'
-- create a table for test
CREATE DATABASE test;
CREATE TABLE test.tbl (x INT);

-- create an empty user
CREATE USER foo;
SHOW GRANTS FOR foo;
/*
+---------------------------------+
| Grants for foo@% |
+---------------------------------+
| GRANT USAGE ON *.* TO 'foo'@'%' |
+---------------------------------+
*/
```

2. Log in as the user foo and execute (**Note that foo does not have any privileges**):
```sql
-- login as user 'foo'
SPLIT TABLE test.tbl BY (100), (200);
SPLIT TABLE test.tbl INDEX idx BY (100), (200);
```

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

Since the user 'foo' does not have any privilege, he should not be able to execute the `SPLIT TABLE` command to modify unauthorized tables.

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

These commands succeed unexpectedly:

```sql
-- login as user 'foo'
SPLIT TABLE test.tbl BY (100), (200);
/*
+--------------------+----------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
+--------------------+----------------------+
| 2 | 1 |
+--------------------+----------------------+
1 row in set (0.01 sec)
*/

SPLIT TABLE test.tbl INDEX idx BY (100), (200);
/*
+--------------------+----------------------+
| TOTAL_SPLIT_REGION | SCATTER_FINISH_RATIO |
+--------------------+----------------------+
| 3 | 1 |
+--------------------+----------------------+
1 row in set (0.00 sec)
*/
```

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

```
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v8.5.2-20250707-57b0825
Edition: Community
Git Commit Hash: 57b0825102d3dce7679856df8f39e1c8641285d7
Git Branch: heads/refs/tags/v8.5.2-20250707-57b0825
UTC Build Time: 2025-07-07 09:12:09
GoVersion: go1.23.6
Race Enabled: false
Check Table Before Drop: false
Store: unistore |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```

Contributor guide

Open the contributing guide

Research direction

Locate the implementations of the affected SPLIT TABLE commands and existing privilege-check tests. Add a regression case using an unprivileged user that verifies each listed command is rejected, then run the relevant SQL test suite to confirm authorized behavior remains intact.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.