Repository navigation
Fail closed on unclassified GitHub API writes - #16034
Merged
Merged
Conversation
Co-authored-by: lpcox <[email protected]>
Copilot
AI
changed the title
[WIP] Fix guard coverage gap for GitHub CLI operations
Fail closed on unclassified GitHub API writes
Nov 5, 2026
lpcox
marked this pull request as ready for review
November 5, 2026 17:58
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical labeling and authorization flaws can expose private data in public repositories and allow scoped generic writes to bypass blocked-operation restrictions.
4 open issues
What changed in this PR
Changes the GitHub proxy to reject unclassified API writes instead of forwarding them outside the guard pipeline, addressing the coverage gap in #16029.
Changes:
- Rejects REST writes and requires GraphQL requests to select a valid query.
- Adds scoped
github_api_writeguard classification and blocks calls without scope. - Adds regression coverage and documents the new proxy behavior.
| File | Description |
|---|---|
internal/proxy/handler.go |
Rejects writes and validates GraphQL before routing. |
internal/proxy/handler_test.go |
Changes write-operation expectations from passthrough to denial. |
internal/proxy/graphql.go |
Detects operation-overriding URL parameters. |
internal/proxy/api_write_test.go |
Covers denied writes and preserved read handling. |
guards/github-guard/rust-guard/src/tools.rs |
Classifies github_api_write as a CLI write operation. |
guards/github-guard/rust-guard/src/lib.rs |
Infers write scope and blocks unscoped calls. |
guards/github-guard/rust-guard/src/labels/tool_rules.rs |
Adds scoped secrecy and writer-integrity labels. |
guards/github-guard/rust-guard/src/labels/constants.rs |
Defines the synthetic API-write identifier. |
docs/RELEASE_NOTES.md |
Announces the fail-closed write behavior. |
docs/PROXY_MODE.md |
Documents write restrictions and synthetic-operation scope. |
Review effort: Max (auto)
| if !owner.is_empty() && !repo.is_empty() { | ||
| // Generic endpoints may change access-sensitive state even in public repos. | ||
| secrecy = policy_private_scope_label(&owner, &repo, repo_id, ctx); | ||
| integrity = writer_integrity(repo_id, ctx); |
Comment on lines
+1162
to
+1166
| // Generic endpoints may change access-sensitive state even in public repos. | ||
| secrecy = policy_private_scope_label(&owner, &repo, repo_id, ctx); | ||
| integrity = writer_integrity(repo_id, ctx); | ||
| } else if !org.is_empty() { | ||
| secrecy = private_scope_label(org); |
| return | ||
| } | ||
|
|
||
| graphQLBody, err = selectReadOnlyGraphQLOperation(graphQLBody) |
| return | ||
| } | ||
|
|
||
| graphQLBody, err = selectReadOnlyGraphQLOperation(graphQLBody) |
Collaborator
|
@copilot address review feedback |
Co-authored-by: lpcox <[email protected]>
Contributor
Author
Addressed the review feedback in commit |
This was referenced Nov 5, 2026
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.


Arbitrary
gh apiREST and GraphQL mutations could bypass operation-name guard classification, including implicit POSTs triggered by request fields.github_api_write_denied). Writes must use named, guard-covered MCP tools.github_api_writeto CLI write operations with repository/organization-scoped writer integrity and conservative private secrecy. Block missing-scope calls after integrity baseline enforcement.Example of an implicit POST now rejected by the proxy:
gh api repos/OWNER/REPO/issues -f title=example # HTTP 403: github_api_write_denied