fix(security): authorize @gittensory Q&A commands by real repo permission (#788) - #838
Conversation
…sion, not author_association (#788) The read-only @gittensory Q&A maintainer commands derived the actor's role from payload.comment.author_association, which maps org `MEMBER` (mere org membership) to the maintainer role — a privilege escalation the moment those commands gain write power (#778: merge/close/review). The action-command path (#538) already resolves the REAL repo permission via getRepositoryCollaboratorPermission; the Q&A path did not. Fix: maybeProcessGittensoryMentionCommand now resolves the commenter's real repo permission (resolveRealRepoPermissionAssociation) instead of trusting the spoofable author_association — an org member with only read access is no longer treated as a maintainer. Matches the action-command path and closes the hole before the agent-layer write actions land. Tests: added a regression test (org MEMBER + read-only permission → denied with not_maintainer_or_pr_author); updated the existing Q&A command tests to mock the real /collaborators/:login/permission lookup (each command now makes one extra permission API call).
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
gittensory · advisory review Reviewed 2 changed file(s) — two independent AI reviewers. Changed files: Suggested action: ✅ Safe to merge — both reviewers found no blocking issues. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Worth double-checking
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #838 +/- ##
==========================================
- Coverage 96.56% 96.56% -0.01%
==========================================
Files 98 98
Lines 14198 14197 -1
Branches 5175 5174 -1
==========================================
- Hits 13711 13710 -1
Misses 105 105
Partials 382 382 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #788. Agent-layer write-safety prerequisite.
The hole
The read-only
@gittensoryQ&A maintainer commands derived the actor's role frompayload.comment.author_association(command-authorization.ts:139 maps orgMEMBER→maintainer). OrgMEMBER= mere membership in the owning org, not maintainer-of-this-repo. Low-stakes while read-only — but a privilege-escalation bug the moment@gittensorycommands gain write power (#778: merge/close/review). The action-command path (#538) already resolves the real repo permission viagetRepositoryCollaboratorPermission; the Q&A path didn't.The fix
maybeProcessGittensoryMentionCommandnow resolves the commenter's real repo permission (resolveRealRepoPermissionAssociation→ admin/maintain→maintainer, write→collaborator, else none) inside the existingPromise.all, instead of trusting the spoofableauthor_association. An org member with only read access is no longer treated as a maintainer. Matches the action-command path and closes the hole before the agent-layer write actions land. No behavior change for genuine maintainers; PR-author / confirmed-miner paths unchanged.Tests
MEMBERwith onlyreadpermission running@gittensory queue-summaryis denied (not_maintainer_or_pr_author), and the real/collaborators/:login/permissionlookup was consulted.Verification
typecheck clean · full suite 1996 passed, 1 skipped (pre-existing pngjs visual-agent skip) · changed authorization path fully covered.
Relates #772 (Wave 2 — Agent Layer), #538, #778.