Skip to content

pg_db_role_setting 的 ALTER ... SET ... TO DEFAULT 可绕过新限制 #1374

Closed

Description

@enkilee

Bug Report

ALTER ... SET ... TO DEFAULT 可绕过新限制
位置:src/backend/catalog/pg_db_role_setting.c ~35-46
原因链路:
仅在 valuestr != NULL 时检查 GUC_DISALLOW_IN_DB_ROLE_SETTING
ExtractSetVariableArgs() 对 SET ... TO DEFAULT/RESET 返回 NULL(src/backend/utils/misc/guc_funcs.c ~236-244)
问题:会跳过限制检查,形成策略绕过。
影响:仍可通过 DB/ROLE 级别 ALTER 命令修改该参数相关持久化状态路径。

IvorySQL Version

5.4

OS Version (uname -a)

linux mint

Configuration options ( config.status --config )

Current Behavior

Expected behavior/code

Step to reproduce

Additional context that can be helpful for identifying the problem

Activity

  1. added
    bug
    on Jun 30, 2026
  2. jiaoshuntian commented on Jun 30, 2026

    @jiaoshuntian
    Collaborator

    We will follow up on this issue.

  3. 123123213weqw commented on Jul 8, 2026

    @123123213weqw
    Contributor

    Hi, I'd like to work on this if no one has started yet.

    Plan (based on the report): in src/backend/catalog/pg_db_role_setting.c, the GUC_DISALLOW_IN_DB_ROLE_SETTING check currently runs only when valuestr != NULL. Since ALTER ... SET ... TO DEFAULT / RESET makes ExtractSetVariableArgs() return NULL, the check is skipped and the restriction is bypassed. I'd key the restriction check off the variable name (stmt->name) regardless of whether a value is supplied, so the TO DEFAULT / RESET path is also blocked. I'd also add a regression test.

    Happy to adjust if you'd prefer a different approach. Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions