Repository navigation
Fix commit integrity escalation in GitHub guard - #14894
Conversation
Pass commit refs into guard policy and avoid integrity promotions when repository visibility or default-branch reachability is unknown. Include public forks in visibility searches and add regression coverage. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 89bf729b-f427-42ac-b7f5-ccf4219b6c78
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Notes:
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved integrity-labeling gaps and enclave compatibility issues prevent safe approval.
4 open findings
What changed in this PR
Hardens commit integrity labeling in MCP Gateway’s GitHub guard to avoid trusting unverified commit history.
Changes:
- Pass REST commit refs into guard policy.
- Include forks in visibility checks and preserve unknown visibility.
- Remove SHA-only merged-integrity promotion and add regression tests.
| File | Description |
|---|---|
| internal/proxy/handler.go | Forwards commit ref query parameters. |
| internal/proxy/handler_test.go | Tests ref propagation to the guard. |
| internal/proxy/handler_difc_test.go | Captures guard inputs in the test stub. |
| guards/github-guard/rust-guard/src/labels/tool_rules.rs | Makes commit promotions visibility-aware. |
| guards/github-guard/rust-guard/src/labels/response_paths.rs | Updates commit collection labeling. |
| guards/github-guard/rust-guard/src/labels/response_items.rs | Updates individual commit labeling. |
| guards/github-guard/rust-guard/src/labels/mod.rs | Revises SHA-based integrity expectations. |
| guards/github-guard/rust-guard/src/labels/helpers.rs | Adds conservative commit integrity handling. |
| guards/github-guard/rust-guard/src/labels/backend.rs | Includes forks in visibility searches. |
🧠 Review effort: Max
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| // Use exact repository scoping for visibility lookup. | ||
| let query = format!("repo:{repo_id}"); | ||
| let query = format!("repo:{repo_id} fork:true"); |
| } | ||
|
|
||
| tool_name == tool_names::GET_COMMIT && looks_like_commit_sha(sha_or_ref) | ||
| is_default_branch_ref(sha_or_ref) |
| is_default_branch: bool, | ||
| ctx: &PolicyContext, | ||
| ) -> Vec<String> { | ||
| commit_integrity_with_visibility( |
|
|
||
| let commit_sha = get_str_or(item, field_names::SHA, UNKNOWN_LABEL_FALLBACK); | ||
| let short_sha = short_sha(commit_sha); | ||
| let item_repo_private = repo_visibility_private_for_repo_id(repo_for_labels); |
Co-authored-by: lpcox <[email protected]>
Fixed in |
|
@copilot address review feedback |
Co-authored-by: lpcox <[email protected]>
Addressed in |


Summary
shaquery parameter from RESTlist_commitsrequests into guard policy so arbitrary branch/SHA history is not treated as default-branch history.get_commitby SHA as proof of default-branch reachability; only list-by-explicit-default-ref receives the merged promotion.Validation
make agent-finishedpassed: build, lint, Go tests, integration tests, and Rust guard tests.Addresses the findings in GHSA-r2rq-2jcw-xqx5.