Skip to content

[Bug]: Column-level GRANT silently degrades to full-table grant #32443

Closed

Description

@Ariznawlll

Existing issue search:

  • I have searched existing issues to avoid duplicates

Branch Name: main

Commit ID: e2459cc55f4b514893e19732743460bc5f16d552 (2026-11-09)

Environment: Local single-node launch (CN + TN + LogService in one process tree), macOS arm64, freshly compiled from current main, clean catalog. MySQL 8.3.0 used for cross-checking behavior on the same machine.

Actual Behavior:

GRANT SELECT(col1, col2) ON TABLE ... TO PUBLIC is silently accepted, but the column list is dropped entirely — the grant becomes a full-table SELECT grant, and because every account inherits public, all users gain full-table read access to all columns.

Two additional edge findings from the same test:

  1. GRANT SELECT(col) ON TABLE t TO <specific_user> fails with there is no role <user> — the column-privilege path apparently treats the grantee as a role only.
  2. The PUBLIC path succeeds silently, which is the dangerous direction.

Verification shows the AST layer parses and stores the column list (Privilege.ColumnList in pkg/sql/parsers/tree/revoke.go), but pkg/frontend/authenticate.go contains zero consumption of ColumnList — the column restriction vanishes between parsing and privilege enforcement.

Expected Behavior:

  • Either reject column-level GRANT syntax explicitly (ERROR: column-level privileges not supported), or implement actual column-level enforcement.
  • TO PUBLIC with a column list must never silently degrade into a full-table grant visible to all accounts.
  • GRANT ... TO <user> with a column list should not fail with "there is no role " (a user should be a valid grantee, same as table-level grants).

Steps to Reproduce:

-- 1. Setup
CREATE DATABASE bh1;
CREATE TABLE bh1.t (id INT PRIMARY KEY, c_pub INT, c_secret VARCHAR(32));
INSERT INTO bh1.t VALUES (1, 10, 'credit-card-1234');

CREATE USER u_colv IDENTIFIED BY 'B1!';

-- 2. Column-level grant restricted to c_pub, granted to PUBLIC
GRANT SELECT(c_pub) ON TABLE bh1.t TO PUBLIC;
-- → returns OK, silently

-- 3. Login as u_colv (who only inherits public)
--    3a. Read the UNAUTHORIZED column:
SELECT c_secret FROM bh1.t;
-- → returns 'credit-card-1234'  (should be DENIED)

--    3b. SELECT *:
SELECT * FROM bh1.t;
-- → returns all columns  (should be DENIED)

-- 4. Contrast: grant to a SPECIFIC user instead
GRANT SELECT(c_pub) ON TABLE bh1.t TO u_colv;
-- → ERROR 20101 (HY000): internal error: there is no role u_colv
--    (unauthorized-column reads are correctly denied only because
--     this grant failed, not because columns are enforced)

Severity: Security. The dangerous combination is "syntax accepted + column list dropped + PUBLIC inherited by every account". An operator may believe they granted 2 columns while the entire table (including sensitive columns) becomes readable by all users.

Cross-reference: Verified at least 3 times on 2026-11-09/10 against current main. Storage layer is fine (privilege row lands in mo_catalog.mo_role_privs); the defect is in the parse-to-enforcement path (Privilege.ColumnList never consumed).

Activity

  1. added
    kind/bug
    on Nov 10, 2026
  2. added theissue type on Nov 10, 2026
  3. added
    severity/s0
    and removed
    severity/s0
    on Nov 10, 2026
  4. changed the title [-][Bug]: Column-level GRANT silently accepted but column list dropped — degrades to full-table grant visible to every account (via PUBLIC)[/-] [+][Bug]: Column-level GRANT silently degrades to full-table grant[/+] on Nov 11, 2026
  5. added a commit that references this issue on Nov 13, 2026
    2573b28
  6. XuPeng-SH commented on Nov 13, 2026

    @XuPeng-SH
    Contributor

    QA handoff (main, not acceptance)

    Merged fix: #32649, main merge SHA 2573b2895bb73af99c95960c2f5595edde7b62b1 (reviewed PR head fb85c8024e5401e6a627ff2e6fda1d4ab71aa85a). The fix explicitly rejects column-qualified GRANT and REVOKE with error 20105 before role lookup or privilege mutation, including mixed privilege lists. Whole-object grants are retained; this does not implement column-level authorization or direct per-user object grants.

    Evidence reviewed: the merged guard and committed regressions; the author's report of six BVT scripts (992 successful, 18 existing-issue skips, 0 failed/abnormal) and full-graph pinned static checks; the same-head review reports 9 focused frontend/planner roots / 16 executions passing without skips. These are remote author/reviewer reports, not tests executed in this handoff run. Raw per-case CI/author artifacts were not independently checked here, and no fresh main server/BVT run was performed.

    No current applicable verified counterexample or unfinished development follow-up was found in the complete issue/PR discussion. Handing to @Ariznawlll for QA; keep this issue open pending acceptance. Please verify rejection and absence of partial mutation for PUBLIC, role/user grantees, mixed lists and both GRANT/REVOKE, plus unchanged whole-object grant/revoke controls. Check fresh-session behavior and existing grants separately: rejection of new column-qualified statements is not proof of remediation of previously widened grants. Direct-user grant semantics remain a separate issue (#32478). No 4.2 backport is requested by this handoff.

  7. Ariznawlll commented on Nov 16, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    原问题验证

    按 issue 步骤构造 bh1.t 与 u_colv:GRANT SELECT(c_pub) ON TABLE t TO PUBLIC 现在返回 ERROR 20105 (HY000): not supported: column-level privilege select,不再静默 OK;以 u_colv 登录后 SELECT c_secret、SELECT * 均报 ERROR 20101: do not have privilege to execute the statement。原报告的"PUBLIC 静默降级后任意用户可读敏感列"路径未复现。

    Happy Path 覆盖

    1. 整表 GRANT SELECT ON TABLE t TO PUBLIC 仍正常成功,public-default 用户实际能读到全表,随后 REVOKE ... FROM PUBLIC 正常收回。
    2. 角色授权链路完整:GRANT SELECT ON TABLE t TO r + GRANT r TO u(default role r)后该用户可正常读取全表。
    3. SHOW GRANTS FOR <user> 正常渲染经角色继承的对象授权(GRANT select ON table ...),与 fix(sql): reject column privileges and render granted object scopes #32649 同 PR 触碰的渲染路径一致。

    Unhappy Path 覆盖

    1. GRANT SELECT(c_pub) ... TO PUBLIC(危险方向)→ ERROR 20105,未持久化任何权限。
    2. GRANT SELECT(c_pub) ... TO <user> → ERROR 20105,不再是误导性的 there is no role <user>。
    3. 多列 SELECT(c_pub, c_secret) 与第二权限种类 INSERT(c_secret) 同样被 20105 拒绝;列级 REVOKE SELECT(c_pub) 同样拒绝。
    4. 安全断言:PUBLIC 列级授权被拒后,仅持 connect/show databases 基础角色的用户对 c_secret、SELECT * 乃至授权列 c_pub 的读取全部报 20101——静默降级路径已封死。

    白盒验证

    核对已合入的 #32649:doGrantPrivilege/doRevokePrivilege 在角色查找与持久化之前调用 checkNoPrivilegeColumnList 对列级权限 fail-closed(20105);整表授权路径未改动。另确认 GRANT ... TO <user> 报 there is no role 是既有设计(grantee 仅接受角色,官方 BVT 全部 grant to role),非本修复引入的回归。未修改产品源码。

    回归测试

    已提交 matrixorigin/motr#350:14_issue_regression/issue_32443_column_privileges_rejected,覆盖上述全部 happy + unhappy 路径。本 issue 与修复 PR 均落在 main(milestone MO-202611,无 4.2-dev backport),故回归 PR 目标为 motr main 分支。

    测试证据

    本地 motr --record 建立基线后,diff 模式连续复跑两轮(含完整用户/角色/库清理,幂等性验证),并与 #32599 回归用例 -j 2 并行一轮:每轮 38/38 语句全绿、输出逐字节稳定;result 基线随 PR #350 提交。

    测试结论

    测试通过。

  8. Ariznawlll commented on Nov 16, 2026

    @Ariznawlll
    CollaboratorAuthor

    验证通过(comment),回归测试已提交 motr#350。关闭。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/frontendkind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions