fix: filter 0002_auth_users_exposed pg_depend join by refclassid - #174
Open
tushardev-365 wants to merge 1 commit into
Open
fix: filter 0002_auth_users_exposed pg_depend join by refclassid#174tushardev-365 wants to merge 1 commit into
tushardev-365 wants to merge 1 commit into
Conversation
The join to pg_depend matched on refobjid alone, so a rewrite dependency whose refobjid numerically collides with the auth.users pg_class oid but actually references an object in another catalog (e.g. a SECURITY DEFINER function in pg_proc) would falsely trip the lint. On affected projects this sends a weekly critical auth_users_exposed alert for a view that never touches auth.users. Qualify the referenced catalog with refclassid = pg_class, matching the classid filter the other pg_depend joins in this suite already use (0001, 0016, 0017). All 28 regression tests still pass, so true-positive detection is unchanged. Fixes supabase#171
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
0002_auth_users_exposedjoinspg_dependtoauth.usersonrefobjidalone:refobjidis only unique within a catalog, so a view's rewrite dependency whoserefobjidnumerically collides with theauth.userspg_classoid, but actually references an object in a different catalog (e.g. aSECURITY DEFINERfunction inpg_proc), matches this join. The view is then reported asauth_users_exposedeven though it has no dependency onauth.users, and the project gets a weekly critical "security vulnerability" email for it.This is the issue reported in #171, with a reproduced collision (
auth.userspg_classoid == a helper function'spg_procoid) and a diagnostic query.Fix
Qualify the referenced catalog on the join:
This is the
refobjid-side equivalent of theclassid = 'pg_catalog.pg_class'::regclassfilter the otherpg_dependjoins in the suite already use (0001,0016,0017), so it also brings0002in line with them.splinter.sqlwas regenerated withbin/compile.py.Testing
All 28 regression tests pass, so true-positive detection is unchanged:
The collision itself depends on runtime oid assignment and can't be forced deterministically in the fixture-based suite, so there's no new failing-then-passing case; the existing
0002true positives plusqueries_are_unionablecover that the change is safe and the bundle still unions. Happy to add a characterization test if you'd prefer one.Closes #171