0002_auth_users_exposed false positive: pg_depend join lacks a refclassid filter (cross-catalog OID collision)

未关闭 适合新手
#171 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@tushardev-365 已经在做这个了。

开始于 2026年7月29日。

  • #174 来自 @tushardev-365 —— 未关闭
  • #177 来自 @karpovantonme —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
postgres

调研方向

从 lints/0002_auth_users_exposed.sql 开始,检查 issue 中描述的 pg_depend join。使用报告中的诊断查询重现跨 catalog 的 OID 冲突。当 lint 不再报告依赖仅为 pg_proc 对象的 view,同时仍能检测到对 auth.users 的 relation 依赖时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Summary

lints/0002_auth_users_exposed.sql joins the view's rewrite dependencies to auth.users by OID only:

join pg_catalog.pg_depend d
    on d.refobjid = auth_users_pg_class.oid

There is no d.refclassid = 'pg_catalog.pg_class'::regclass predicate, so any pg_depend row from a view's rewrite whose refobjid numerically collides with auth.users' pg_class OID — but actually references an object in a different catalog (pg_proc, pg_type, …) — fires the lint.

Observed instance

On one of our projects, auth.users has pg_class OID 16499, and a public view calls a SECURITY DEFINER helper function whose pg_proc OID is also 16499. The view selects only from public tables (verified: zero relation dependency on auth.users), yet the advisor reports it as CRITICAL auth_users_exposed, and the "action required: security vulnerabilities" email goes out weekly.

Diagnostic query that shows the collision:

with au as (
  select oid from pg_class
  where relname = 'users' and relnamespace = 'auth'::regnamespace
),
rw as (
  select oid from pg_rewrite where ev_class = 'public.<your_view>'::regclass
)
select d.refclassid::regclass as ref_catalog,
       case when d.refclassid = 'pg_proc'::regclass then d.refobjid::regprocedure::text
            when d.refclassid = 'pg_class'::regclass then d.refobjid::regclass::text
            else d.refobjid::text end as ref_object,
       d.deptype
from pg_depend d, au, rw
where d.objid = rw.oid and d.refobjid = au.oid;

Result on the affected project: one row, ref_catalog = pg_proc, ref_object = <helper function>(text,uuid) — not a relation.

Suggested fix

Add the catalog filter to the join:

join pg_catalog.pg_depend d
    on d.refobjid = auth_users_pg_class.oid
    and d.refclassid = 'pg_catalog.pg_class'::regclass

(Other OID-equality joins in the lint suite may want the same audit.)

主要语言
PLpgSQL
星标
284
派生
110
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

supabase/splinter 的其他 Issue

查看 supabase/splinter 的全部 Issue

相似的 Issue

更多 Databases Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。