Skip to content

Close GitHub guard coverage gaps for pull-request artifacts - #17147

Merged
lpcox merged 3 commits into
mainfrom
copilot/guard-coverage-fix
Nov 23, 2026
Merged

lpcox merged 3 commits into
mainfrom
copilot/guard-coverage-fix

Conversation

@lpcox

@lpcox lpcox commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

pull_request_artifact_write lacked mutation classification, and both artifact tools fell through default DIFC handling.

  • Classification: Add artifact writes to the sorted upstream read-write inventory.
  • Request labels: Apply repository-visibility secrecy to both tools and require writer integrity for upsert/delete.
  • Response labels: Keep reads and returned artifact content at none integrity—even in private repositories—without promoting content based on creator or PR provenance.
  • Regression coverage: Cover classification, public/private visibility, both mutation methods, and raw/MCP-wrapped response envelopes.

@lpcox lpcox changed the title [WIP] Fix guard coverage for missing GitHub CLI operations Close GitHub guard coverage gaps for pull-request artifacts Nov 23, 2026
@lpcox
lpcox marked this pull request as ready for review November 23, 2026 05:02
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 05:02
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical artifact-response flaws allow integrity and blocked-user policy bypasses, while response labeling breaks expected list and write-result response shapes.

3 open issues
What changed in this PR

This PR extends the MCP Gateway’s Rust GitHub guard to cover pull-request artifact operations, addressing the coverage gaps identified in #17138.

Changes:

  • Classifies artifact mutations as read-write operations.
  • Adds repository-visibility secrecy labels, writer integrity for mutations, and none integrity for reads and returned content.
  • Adds regression tests for classification, public/private visibility, mutation methods, and raw/MCP-wrapped responses.
File Description
guards/​github-guard/​rust-guard/​src/​tools.rs Registers artifact writes as read-write and tests classification.
guards/​github-guard/​rust-guard/​src/​labels/​tool_rules.rs Adds explicit artifact request-label rules and tests.
guards/​github-guard/​rust-guard/​src/​labels/​response_items.rs Labels artifact responses as untrusted and tests response envelopes.
guards/​github-guard/​rust-guard/​src/​labels/​constants.rs Defines shared names for both artifact tools.

Review effort: Max (adaptive)


tool_names::PULL_REQUEST_ARTIFACT_READ | tool_names::PULL_REQUEST_ARTIFACT_WRITE => {
let (repo_full, secrecy) = repo_full_with_secrecy(tool_args, ctx);
let integrity: SharedLabels = none_integrity(&repo_full, ctx).into();
tool_names::PULL_REQUEST_ARTIFACT_READ | tool_names::PULL_REQUEST_ARTIFACT_WRITE => {
let (repo_full, secrecy) = repo_full_with_secrecy(tool_args, ctx);
let integrity: SharedLabels = none_integrity(&repo_full, ctx).into();
let items = extract_items_slice(&actual_response, "artifacts");
"manage_notification_subscription",
"manage_repository_notification_subscription",
"merge_pull_request",
tool_names::PULL_REQUEST_ARTIFACT_WRITE, // upserts or deletes PR artifacts and returns untrusted content
@lpcox

lpcox commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in f9bc252: artifact responses now use envelope-preserving path labels, blocked creators and missing creator logins fail closed when blocked-users is active, and artifact writes require response labeling while retaining read-write admission. make agent-finished passes.

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads data returned (list_issues, list_pull_requests, get_file_contents, list_commits) ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 targeted tools absent from the 23-tool catalog (unknown tool error); no call-time gateway refusal observed since write tools never reach the gateway BLOCKED ⚠️
C CLI reads data returned via same github CLI ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh CLI unauthenticated (no GH_TOKEN) — not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh CLI unauthenticated — not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked on any surface. Part B gap: all 6 write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) were absent from the exposed tool catalog entirely (23 read-only tools total), so refusal reflects backend GITHUB_READ_ONLY=1 configuration, not a call-time gateway-specific denial — per the test's own methodology this is INCONCLUSIVE, not PASS. Part D/E gap: gh CLI had no GH_TOKEN in this environment, so the GitHub-API-token-scope boundary could not be exercised this run. Reads (Parts A, C) fully passed on both surfaces.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 27f5092 into main Nov 23, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/guard-coverage-fix branch November 23, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[guard-coverage] Guard coverage gap: 2 operations from github-mcp-server / GitHub CLI not fully covered

3 participants