Skip to content

Fix commit integrity escalation in GitHub guard - #14894

Merged
lpcox merged 3 commits into
mainfrom
lpcox-security-advisory
Oct 14, 2026
Merged

lpcox merged 3 commits into
mainfrom
lpcox-security-advisory

Conversation

@lpcox

@lpcox lpcox commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Pass the sha query parameter from REST list_commits requests into guard policy so arbitrary branch/SHA history is not treated as default-branch history.
  • Include forks in repository visibility searches and avoid granting commit writer integrity when visibility is unknown.
  • Stop treating get_commit by SHA as proof of default-branch reachability; only list-by-explicit-default-ref receives the merged promotion.
  • Add regression tests for ref propagation, unknown visibility, and SHA-only commit lookups.

Validation

  • make agent-finished passed: build, lint, Go tests, integration tests, and Rust guard tests.

Addresses the findings in GHSA-r2rq-2jcw-xqx5.

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
Copilot AI max review requested due to automatic review settings October 14, 2026 17:38
@lpcox

lpcox commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

@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 AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads data returned (issues, PRs, README.md, commits) ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 7 targets absent from 23-tool catalog BLOCKED ⚠️
C CLI reads (via proxied github CLI on PATH) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh fully unauthenticated — not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh fully unauthenticated — not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

Notes:

  • Parts A/C confirmed: all reads succeeded via both MCP tools and the proxied github CLI (23 read-only tools exposed, e.g. list_issues, list_pull_requests, get_file_contents, list_commits).
  • Part B: no write tool (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) appears in the exposed catalog at all — this proves gh-aw's GITHUB_READ_ONLY=1 backend config, not mcpg's own gateway-level DIFC/guard blocking (per the framework's own stated limitation). No write was attempted or leaked.
  • Parts D/E: gh CLI has no GH_TOKEN in this environment and errors immediately on any call (even reads), so write/mutation rejection could not be attributed to gateway or token-scope enforcement — genuinely untested this run, not a pass.
  • No writes leaked on any surface; nothing created, starred, reacted to, or modified.

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

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

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);

Copilot AI commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@copilot fix this failing ci check https://github.com/github/gh-aw-mcpg/actions/runs/38608360450/job/116004995907?pr=14894

Fixed in e217ab2 by marking the test-only wrapper #[cfg(test)], preventing the denied dead-code warning in the WASM release build. The forced WASM build and all 670 Rust tests passed; make agent-finished also passed.

@lpcox

lpcox commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

Copilot AI commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed in d94fce2: enclave lookups now accept only the guard’s exact fork:true qualifier, GraphQL history uses a conservative non-default ref, and same-repository commits reuse visibility results including unknown. Focused regressions and make agent-finished passed.

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.

3 participants