Repository navigation
database: bound collaboration access mode by min(actor, admin) - #8227
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens repository collaboration permission handling by preventing AccessModeOwner from being persisted for collaborator records in the database layer, closing an escalation path reachable via the web UI endpoint that accepts numeric mode values.
Changes:
- Tighten
ChangeCollaborationAccessModevalidation to reject any mode greater thanAccessModeAdmin(thereby disallowingAccessModeOwneron collaboration/access rows). - Add a security fix note to the
0.15.0+devchangelog.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/database/repo_collaboration.go | Restricts persisted collaborator access mode to max Admin, preventing owner-level escalation via numeric mode input. |
| CHANGELOG.md | Documents the security fix in the unreleased changelog section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ### Fixed | ||
|
|
||
| - _Security:_ Repository collaborators with Admin access could escalate their own or others' access mode to Owner via the web UI. |
There was a problem hiding this comment.
This changelog entry doesn’t follow the pattern used by other recent _Security:_ bullets (they typically include a PR link and, when applicable, a GHSA/advisory reference). Consider appending the PR number link for consistency once available, and add an advisory link if this fix will be tracked via GHSA/CVE.
| - _Security:_ Repository collaborators with Admin access could escalate their own or others' access mode to Owner via the web UI. | |
| - _Security:_ Repository collaborators with Admin access could escalate their own or others' access mode to Owner via the web UI. _(PR link pending; add GHSA/CVE link if assigned)_ |
There was a problem hiding this comment.
@wuhan005 I think this feedback is legit. I think I saw one GHSA about this?
Reject any attempt to change a collaboration access mode to a level above the actor's own access mode, and cap the new mode at admin (owner is reserved for the repository owner). Both the web settings handler and the API `addCollaborator` handler now pass the caller's effective access mode through to the database layer.
1a806a5 to
11019a0
Compare
ChangeCollaborationAccessModemin(actor, admin)
Co-authored-by: Joe Chen <jc@unknwon.io> (cherry picked from commit 1fdc9cc)
Describe the pull request
Tighten
ChangeCollaborationAccessModein the database layer so that:AccessModeAdmin.AccessModeOwner(value4) is reserved for the repository owner and is no longer accepted on a collaboration record. This closes the off-by-one in the previous guard (mode > AccessModeOwner).Both call sites (
POST /:username/:reponame/settings/collaboration/access_modein the web UI, andPUT /api/v1/repos/:username/:reponame/collaborators/:collaboratorin the API) now pass the caller's effectiveAccessModethrough to the database function.Advisory: GHSA-4565-r4x7-hg8j
Checklist
Test plan
mode=4for their own UID. The response is 204 but the stored access remains Admin.mode=4for another collaborator's UID. The target's access remains unchanged.