Fix project permission bypass#3915
Closed
BunsDev wants to merge 3 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the project-permissions surface by removing implicit “Supreme” trust and making the HTTP routes that could mutate grants/proposals fail closed until a real authenticated approval flow exists.
Changes:
- Removed implicit Supreme access from
canAccessProject/filterProjectsForFamiliar, requiring persisted grants instead. - Made
/api/project-grantsPOST/DELETE and/api/grant-proposalsPOST +/api/grant-proposals/[id]PATCH return 403 fail-closed responses. - Updated API contract tests and permission tests to assert the new fail-closed behavior and bootstrap-grant requirement.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/project-permissions.ts | Removes implicit Supreme access checks; keeps access purely grant-based and updates audit reasoning. |
| src/lib/project-permissions.test.ts | Updates expectations to require explicit bootstrap grants for Supreme and verifies filtering behavior. |
| src/app/api/project-grants/route.ts | Disables unauthenticated grant mutation endpoints by always returning 403 on POST/DELETE. |
| src/app/api/project-grants/route.test.ts | Updates route-contract assertions to ensure mutation primitives aren’t exposed by the HTTP layer. |
| src/app/api/grant-proposals/route.ts | Disables unauthenticated proposal creation by always returning 403 on POST. |
| src/app/api/grant-proposals/[id]/route.ts | Disables unauthenticated proposal resolution by always returning 403 on PATCH. |
| src/app/api/api-contracts.test.ts | Updates route contracts to reflect that these endpoints no longer parse JSON bodies. |
Comments suppressed due to low confidence (1)
src/lib/project-permissions.ts:205
assertProjectAccessstill loadsloadHumanPermissionConfig()solely to passconfig.supremeFamiliarIdintocanAccessProject, but that value is no longer used. This adds unnecessary file/env reads to every permission check; after making the parameter optional, this can just load permissions and callcanAccessProjectdirectly.
const [permissions, config] = await Promise.all([
loadProjectPermissions(),
loadHumanPermissionConfig(),
]);
const allowed = canAccessProject(permissions, ctx, projectId, config.supremeFamiliarId);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
@copilot resolve the merge conflicts on this branch. |
Contributor
Conflicts are resolved on this branch. I merged |
BunsDev
deleted the
codex/fix-unauthenticated-project-grant-vulnerability
branch
July 26, 2026 20:44
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.
Motivation
familiarId/proposedBy/claimedHumanApprovalvalues, allowing unauthenticated callers to create/revoke grants or impersonate Supreme and bypass project access checks.Description
POST/DELETEto/api/project-grantsand returning a 403 with a clear error message instead of trusting request bodies (file:src/app/api/project-grants/route.ts).POSTto/api/grant-proposalsandPATCHto/api/grant-proposals/[id]until an authenticated human/Supreme approval flow is added (files:src/app/api/grant-proposals/route.ts,src/app/api/grant-proposals/[id]/route.ts).canAccessProjectandfilterProjectsForFamiliarrequire explicit persisted grants (file:src/lib/project-permissions.ts).src/app/api/api-contracts.test.ts,src/app/api/project-grants/route.test.ts,src/lib/project-permissions.test.ts).Testing
node --experimental-strip-types src/lib/project-permissions.test.ts,node --experimental-strip-types src/app/api/project-grants/route.test.ts, andnode --experimental-strip-types src/app/api/api-contracts.test.tsand they succeeded.pnpm typecheckand it succeeded.pnpm test:apiand all API tests passed.Codex Task