Conversation
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.
Summary
Fixes the bug reported in #390: the
SECURITY DEFINERhelper example insecurity-rls-performance.mdrevokedEXECUTEfrom all roles — includingauthenticatedandservice_role— and then used that same function inside an RLS policy.Postgres evaluates policy expressions with the calling role's privileges, so any role whose queries can trigger the policy needs
EXECUTEon every function the policy references. Following the previous example verbatim caused every authenticated query against the protected table to fail with:What changed
PUBLIConly (which blocks uninvited direct calls — the actual security goal), then explicitly grantsEXECUTEback to the roles that legitimately evaluate the policy (authenticated; commented examples foranon/service_rolewhen their policies reference the helper).Why this matters for agents specifically
An agent following the old example produces a project where auth appears "broken" after a security hardening pass. The shortest recovery path an agent typically takes is removing the hardening entirely. The corrected example gives agents a pattern that hardens correctly on the first pass and a diagnostic hint (42501 → check policy/view references) when it doesn't.