Repository navigation
fix(0028,0029): only report functions exposed by PostgREST - #213
Open
anh-nguyenn wants to merge 1 commit into
Open
anh-nguyenn wants to merge 1 commit into
anh-nguyenn wants to merge 1 commit into
Conversation
These lints match every SECURITY DEFINER pg_proc entry executable by the role, including procedures and trigger functions. PostgREST does not expose either: its schema cache selects prokind = 'f' and excludes functions returning trigger, so the findings claim an /rpc route that does not exist. Filter both lints the same way and add regression cases for a SECURITY DEFINER procedure and a SECURITY DEFINER trigger function.
This branch has not been deployed
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.
Fixes #212.
Problem
Lints
0028_anon_security_definer_function_executableand0029_authenticated_security_definer_function_executablematched everypg_procrow withprosecdef = trueandEXECUTEfor the role. That includes procedures (prokind = 'p') and trigger functions (prorettype = 'trigger'::regtype), which PostgREST does not expose as/rpcendpoints. The findings therefore claimed a route that does not exist.PostgREST's schema-cache function query (
funcsSqlQueryinPostgREST/SchemaCache.hs) filters withprokind = 'f'andt.oid <> 'trigger'::regtype, so the lints should apply the same constraints.Reproduction (reported before the change):
Fix
Both lints now additionally require:
splinter.sqlwas regenerated withpython bin/compile.py.Tests
Added negative cases to
test/sql/0028_*andtest/sql/0029_*for a SECURITY DEFINER procedure and a SECURITY DEFINER trigger function, and updated the expected output. Before the fix those cases produced one and two findings respectively; after the fix both return 0 rows.Validation (PostgreSQL 15.19,
./bin/installcheck):0028_anon_security_definer_function_executable— pass0029_authenticated_security_definer_function_executable— pass0026/0027fail in my local environment because thepg_graphqlextension is not installed there (they fail identically on unmodifiedmain)python bin/check_lints.py— all 29 lints registered