-
Notifications
You must be signed in to change notification settings - Fork 1
feat(function-resolution): port the route-validated invocation surface #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
358 changes: 358 additions & 0 deletions
358
...s/function-resolution/deploy/schemas/function_resolution/procedures/create_invocation.sql
Large diffs are not rendered by default.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
.../deploy/schemas/function_resolution/procedures/grants/grant_execute_create_invocation.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| -- Deploy schemas/function_resolution/procedures/grants/grant_execute_create_invocation to pg | ||
|
|
||
| -- requires: schemas/function_resolution/schema | ||
| -- requires: schemas/function_resolution/procedures/create_invocation | ||
|
|
||
| BEGIN; | ||
|
|
||
| -- The request roles reach exactly one function in this schema. Schema USAGE is | ||
| -- not a widening: pgpm-defaults revokes EXECUTE on new functions from PUBLIC and | ||
| -- this schema grants it only to administrator, so the sibling resolver functions | ||
| -- stay unreachable and the grant below is the whole surface. | ||
| GRANT USAGE ON SCHEMA function_resolution TO anonymous; | ||
|
|
||
| GRANT EXECUTE ON FUNCTION function_resolution.create_invocation(uuid, text, text, jsonb, text, jsonb, uuid, uuid) TO authenticated; | ||
| GRANT EXECUTE ON FUNCTION function_resolution.create_invocation(uuid, text, text, jsonb, text, jsonb, uuid, uuid) TO anonymous; | ||
|
|
||
| COMMIT; |
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
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
7 changes: 7 additions & 0 deletions
7
...s/function-resolution/revert/schemas/function_resolution/procedures/create_invocation.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| -- Revert schemas/function_resolution/procedures/create_invocation from pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| DROP FUNCTION function_resolution.create_invocation(uuid, text, text, jsonb, text, jsonb, uuid, uuid); | ||
|
|
||
| COMMIT; |
10 changes: 10 additions & 0 deletions
10
.../revert/schemas/function_resolution/procedures/grants/grant_execute_create_invocation.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- Revert schemas/function_resolution/procedures/grants/grant_execute_create_invocation from pg | ||
|
|
||
| BEGIN; | ||
|
|
||
| REVOKE EXECUTE ON FUNCTION function_resolution.create_invocation(uuid, text, text, jsonb, text, jsonb, uuid, uuid) FROM anonymous; | ||
| REVOKE EXECUTE ON FUNCTION function_resolution.create_invocation(uuid, text, text, jsonb, text, jsonb, uuid, uuid) FROM authenticated; | ||
|
|
||
| REVOKE USAGE ON SCHEMA function_resolution FROM anonymous; | ||
|
|
||
| COMMIT; |
Binary file modified
BIN
+5.69 KB
(110%)
packages/function-resolution/sql/pgpm-function-resolution--0.44.0.bundle.tar.gz
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 security · high
Route
anonymousflag is immutable, fail-open on revocationinstall_route_bindingswrites the route'sanonymouscolumn only in an INSERT guarded byWHERE NOT EXISTSon(domain_id, path)(install_route_bindings.sql:436); its only UPDATE (lines 475-489) backfillsserving_site_fieldand never touchesanonymous. Re-running with a document that removesanonymous: trueto close a URL leaves the existing rowanonymous = true, andcreate_invocation(which enforcesr.anonymousfor anonymous callers at line 287) keeps authorizing it, so the operator's revocation silently does not take effect and the URL stays publicly reachable. The same immutability also means a route newly declaredanonymousnever opens.📋 Prompt for AI Agents
In packages/function-resolution/deploy/schemas/function_resolution/procedures/install_route_bindings.sql around lines 434-464, the
anonymousflag is only written on INSERT and theWHERE NOT EXISTSguard (lines 438-440) skips existing routes, so a route once installedanonymous=truecan never be revoked by re-running the install. Add an UPDATE, after the insert, that reconcilesanonymouson already-present rows for the same(domain_id, path)and ownership key, mirroring the existing serving_site_field backfill at lines 475-489:UPDATE <routes_schema>.<routes_table> AS r SET anonymous = $6 WHERE r.domain_id = $1 AND r.path = $2 AND r.anonymous IS DISTINCT FROM $6 AND <routes_key pin>. This ensures removinganonymous: truefrom the document actually closes the route, preventing the fail-open case where a URL the operator closed remains anonymously reachable via create_invocation.