Skip to content

[Bug]: Arrow S3 LOAD reads object before denying INSERT privilege #28618

Closed

Description

@Ariznawlll

Description

An Arrow IPC LOAD DATA issued by a user without INSERT privilege reaches the configured S3 object store before MatrixOne rejects the statement for privilege denial.

The statement does not write rows, but authorization is not enforced before the external-object access. This can expose unnecessary object reads and makes denied requests depend on object-store availability.

Environment

  • Branch: main
  • Commit: 269d59addd032d20897cc4d86f58de3e387a6d76
  • Deployment: isolated 1-CN embedded MatrixOne cluster; Arrow LOAD and S3 Arrow LOAD explicitly enabled; local version-compatible MinIO and an HTTP observing proxy.
  • Date: 2026-09-10

Steps to reproduce

  1. Create a database/table and insert one owner-controlled seed row.
  2. Start local MinIO with a valid Arrow IPC File object. Route its S3 endpoint through a proxy that records any object-store request.
  3. Create a non-owner user/role with only CONNECT on the account; grant no INSERT/table privilege.
  4. Connect through the MySQL protocol as that user and execute Arrow LOAD DATA URL S3OPTION ... into the owner table.
  5. Observe the SQL result, proxy state, and owner-side row count. Then execute the same LOAD as the owner as a happy-path control.

Actual behavior

  • The non-owner statement is rejected with: internal error: do not have privilege to execute the statement.
  • The proxy records an S3 request before that denial.
  • The table remains seed-only after the denied statement.
  • The owner retry succeeds and produces the expected second row.

Expected behavior

A user who lacks INSERT permission should be rejected before MatrixOne performs S3/Arrow object access. The rejected request must leave the target table unchanged, and the normal owner control must continue to succeed.

Stability and controls

  • Reproducer: 3/3 failures on the latest official main.
  • Happy-path control: 3/3 owner retries succeeded using the same valid Arrow object.
  • Failure atomicity: 3/3 denied statements left exactly the original seed row.

Evidence

Reproducer command:

go test ./pkg/tests/arrowload -run '^TestArrowLoadPermissionDeniedDoesNotReadOrWrite$' -count=3 -timeout=180s

Each run failed only because the proxy observed object access. The denial and row-count checks completed as expected.

Code analysis

Observed behavior is consistent with Arrow external-scan compile setup obtaining the external file list/size and Arrow planning data before the later execution privilege rejection. This is a hypothesis based on the reproduction, not a proposed fix.

Regression coverage

A focused public-protocol regression is prepared in pkg/tests/arrowload/arrow_load_lifecycle_test.go as TestArrowLoadPermissionDeniedDoesNotReadOrWrite. It intentionally remains failing until the product ordering is fixed and should be landed with that fix.

Related

Activity

  1. added this to the MO-202609 milestone on Sep 10, 2026
  2. added
    kind/bug
    on Sep 10, 2026
  3. added theissue type on Sep 10, 2026
  4. added
    ai-easy
    on Oct 21, 2026
  5. Ariznawlll commented on Oct 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:官方 main
    • commit:67c91c5bdf6c669f63331778634215f7aa3e8f58(执行前后均核对为官方 main HEAD;修复 PR fix(load): authorize Arrow LOAD before planning #28633 的 merge commit)
    • 部署方式:隔离的本地 macOS/arm64 嵌入式 MatrixOne(1 CN、1 TN、LogService),真实 MySQL 协议;本机 MinIO 与 HTTP 观察代理。Arrow LOAD 和 S3 Arrow LOAD 已启用。未使用共享 TKE。
    • 测试日期:2026-10-21

    原问题验证

    对 pkg/tests/arrowload/arrow_load_lifecycle_test.go 中的 TestArrowLoadPermissionDeniedDoesNotReadOrWrite 执行 go test -mod=readonly -p 4 ./pkg/tests/arrowload -run '^TestArrowLoadPermissionDeniedDoesNotReadOrWrite$' -count=3 -timeout=20m。该测试以真实 Arrow IPC 文件和 MinIO S3 对象,经观察代理执行原始的无 INSERT 权限 LOAD DATA URL S3OPTION:3/3 均返回权限拒绝,代理记录 0 次对象请求,目标表始终只有 (0, 'seed') 这一行;未出现原先“拒绝前已访问 S3”的现象。JSON 测试事件分别为 3 个 pass,耗时 5.71/4.78/4.63 秒,无 skip。

    Happy Path 覆盖

    1. 同一用户获授目标表 INSERT 后重试相同 Arrow S3 LOAD:3/3 访问 MinIO 对象且成功,目标表由 1 行增至 2 行。确认修复没有误拦截合法读取。
    2. TestArrowLoadBVT/PreparedDatabaseBinding 在真实协议、2 CN 的嵌入式集群定向运行 3 轮;每轮 Initial 与 SameInstance 均通过。PREPARE 后切换会话数据库并改变 sql_mode 触发重规划,数据仍写入准备时数据库,当前会话数据库不被临时授权绑定改变。

    Unhappy Path 覆盖

    1. 无 INSERT 权限直接 LOAD:3/3 权限拒绝、0 次外部对象访问、目标表仍为原始 1 行,证明拒绝原子性。
    2. 无 INSERT 权限执行同一语句的 PREPARE:3/3 权限拒绝、0 次外部对象访问。
    3. 前端授权定向测试覆盖允许、拒绝、权限查询出错及编译器/会话数据库独立绑定;错误路径连续 3 轮通过。NULL/类型转换不是本问题的触发维度;本轮不据此声称覆盖全部 Arrow 类型矩阵。

    白盒验证

    pkg/frontend/load_preplan_auth_test.go 中 6 个定向测试按 -count=3 通过,覆盖预规划目标识别、AST 目标、权限错误传播和数据库绑定。未执行 race 或多节点故障注入;本缺陷是授权与外部读取的顺序问题,实际对象访问已经由上面的公开协议集成测试观测。

    回归测试

    修复 PR #28633 已合入本轮官方 main。PR 内的真实协议回归 pkg/tests/arrowload/arrow_load_lifecycle_test.go::TestArrowLoadPermissionDeniedDoesNotReadOrWrite 定向 3/3,及现有 Arrow BVT 的 PreparedDatabaseBinding 定向 3 轮通过;已有 Go 集成回归直接断言对象请求数、权限拒绝和写入原子性,因此按当前约定不再向 MOTR #247 增加重复场景。本地未重跑整个 Arrow BVT;PR 的 Ubuntu/x86 UT、multi-CN BVT 及覆盖检查为 SUCCESS,不能把其他跳过的 CI 作通过证据。

    测试证据

    • 回归源码:Arrow S3 授权测试
    • PR #28633 CI:Ubuntu/x86 UT、multi-CN BVT 和 Coverage 成功;本轮独立运行结果如上,所有执行的集成用例均未跳过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions