[Bug]: SHOW INDEX and information_schema.STATISTICS expose columns pruned by role rules

Aperta
#33,251 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@iamlinjunhong ci sta già lavorando.

Dal 25/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

kind/bug severity/s1

Environment

  • MatrixOne: workspace commit d58476485f029f076a8b42ac16262bf5c119deb5 (main)
  • OS/Arch: macOS 15.5, arm64 (Apple Silicon)
  • Deployment: single-node mo-service started from a copy of etc/launch with every port shifted by +20000 (CN frontend on 127.0.0.1:26001)
  • Clients: MySQL CLI 9.7.1 with --default-character-set=utf8mb4; admin connected as dump, restricted user as poc_u

Actual Behavior

With role rule select uid from pocdb.vault where salary < 10000 on pocdb.vault, the restricted user can only see the uid column. The established metadata behavior works:

  • information_schema.COLUMNS returns only uid (this is the fix of issue #29095).
  • SHOW CREATE TABLE vault and DESC vault fail with ERROR 20101: do not have privilege to execute the statement (matches BVT role_rule.result).

But two other metadata paths disclose the very same pruned column without any visibility check:

  • SHOW INDEX FROM vault returns Key_name=idx_salary, Column_name=salary, Expression=salary (and succeeds instead of being rejected like SHOW CREATE TABLE).
  • SELECT index_name, column_name FROM information_schema.statistics WHERE table_schema='pocdb' AND table_name='vault' returns idx_salary | salary.

The leak is identical whether enable_remap_hint is 0 or 1. The restricted user therefore learns that a hidden column named salary exists and that an index idx_salary is built on it, although the column-pruning policy (and the SHOW COLUMNS/SHOW CREATE TABLE fail-closed gate) exists precisely to prevent disclosing such physical metadata.

Expected Behavior

Pruned columns must not be disclosed through metadata interfaces: SHOW INDEX and information_schema.STATISTICS must apply the same column-visibility policy as information_schema.COLUMNS (fixed by #29095), so index entries referencing pruned columns (here salary/idx_salary) are not visible to the restricted user.

Steps to Reproduce

As admin (dump):

create database pocdb;
create table pocdb.vault (uid int, salary int, note varchar(20));
insert into pocdb.vault values (1, 8000,'n1'),(2, 25000,'n2'),(3, 3, 'n3');
create index idx_salary on pocdb.vault(salary);
create role pocA;
grant connect on account * to pocA;
grant select, update, delete on table pocdb.vault to pocA;
alter role pocA add rule 'select uid from pocdb.vault where salary < 10000' on table pocdb.vault;
create user poc_u identified by '123456' default role pocA;

As poc_u (database pocdb):

select column_name from information_schema.columns where table_schema='pocdb' and table_name='vault';  -- only uid (correct, #29095)
show create table vault;                      -- ERROR 20101 (correct, fail-closed)
show index from vault;                        -- BUG: shows idx_salary / salary
select index_name, column_name from information_schema.statistics
  where table_schema='pocdb' and table_name='vault';  -- BUG: idx_salary | salary

Repeat with set enable_remap_hint = 1; — the leak is unchanged.

Additional Information

Code pointers:

  • pkg/sql/plan/rewrite_metadata.go:67-75 applyRewriteMetadataVisibility filters only information_schema.columns (informationSchemaColumnsTable), returning early for every other table, so information_schema.statistics never gets the visibility filter that #29095 introduced.
  • pkg/sql/plan/rewrite_metadata.go:33-60 checkShowRewriteMetadata documents the intended discipline: "SHOW COLUMNS and SHOW CREATE TABLE expose physical metadata ... Only a proven all-column chain can expose it", and fails closed otherwise. SHOW INDEX has no equivalent gate and simply returns the raw index metadata, including pruned column names.

Recommended fix: extend the visibility policy used for COLUMNS to information_schema.STATISTICS (filter out rows whose COLUMN_NAME is not provably visible) and either apply the same filtering to SHOW INDEX output or gate it with checkShowRewriteMetadata-style fail-closed semantics for consistency with SHOW COLUMNS/SHOW CREATE TABLE. The second option (rejecting the whole statement) is simpler and matches the existing physical-metadata discipline; either way the pruned column name must not be returned.

Precedent establishing that this class of disclosure is a bug: #29095 (information_schema.columns exposing rule-hidden columns, fixed). Related but distinct: #31675 / #33160 (EXPLAIN row-count side channel), #32698 (read-only index statistics feature).

Full reproduction, exactly as Loom ran it
#!/bin/bash
# Role-rule pruned columns leak through SHOW INDEX and information_schema.STATISTICS
# while information_schema.COLUMNS and SHOW CREATE TABLE are correctly protected.
# Requires single-node mo-service built from commit d58476485f, admin dump/111.
set -u
HOST=127.0.0.1
PORT=26001
ADMIN="mysql -h $HOST -P $PORT -u dump -p111 --default-character-set=utf8mb4"
USERC="mysql -h $HOST -P $PORT -u poc_u -p123456 --default-character-set=utf8mb4 pocdb"

$ADMIN -e "
drop user if exists poc_u; drop role if exists pocA; drop database if exists pocdb;
create database pocdb;
create table pocdb.vault (uid int, salary int, note varchar(20));
insert into pocdb.vault values (1, 8000,'n1'),(2, 25000,'n2'),(3, 3, 'n3');
create index idx_salary on pocdb.vault(salary);
create role pocA;
grant connect on account * to pocA;
grant select, update, delete on table pocdb.vault to pocA;
alter role pocA add rule 'select uid from pocdb.vault where salary < 10000' on table pocdb.vault;
create user poc_u identified by '123456' default role pocA;"

echo '=== [1] baseline: COLUMNS hides pruned columns (only uid) ==='
$USERC -e "select column_name from information_schema.columns where table_schema='pocdb' and table_name='vault';"
echo '=== [2] baseline: SHOW CREATE TABLE fails closed ==='
$USERC -e "show create table vault;"
echo '=== [3] BUG: SHOW INDEX exposes pruned column salary ==='
$USERC -e "show index from vault;"
echo '=== [4] BUG: information_schema.STATISTICS exposes pruned column salary ==='
$USERC -e "select index_name, column_name from information_schema.statistics where table_schema='pocdb' and table_name='vault';"
echo '=== [5] same leak with enable_remap_hint=1 ==='
$USERC -e "set enable_remap_hint=1; show index from vault; select index_name, column_name from information_schema.statistics where table_schema='pocdb' and table_name='vault';"
$ADMIN -e "drop user if exists poc_u; drop role if exists pocA; drop database if exists pocdb;"

Found by Loom bug hunt (module: custom-393355822b; tests: unit, white-box, end-to-end; severity: S1)

Lingua principale
Go
Stelle
1.9k
Fork
312
Merge medio
22h 59m
PR unite (30g)
736

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di matrixorigin/matrixone

Tutte le issue di matrixorigin/matrixone

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.