Skip to content

fix(proxy): preserve encoded REST path identity - #16781

Merged
lpcox merged 1 commit into
mainfrom
lpcox-fix-encoded-rest-paths
Nov 18, 2026
Merged

lpcox merged 1 commit into
mainfrom
lpcox-fix-encoded-rest-paths

Conversation

@lpcox

@lpcox lpcox commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • construct upstream GitHub URLs with net/url instead of reparsing concatenated path strings
  • preserve literal percent-like path segments so guard routing and upstream repository identities remain consistent
  • add forwarding and end-to-end regression coverage for double-encoded repository paths

Security impact

Prevents a double-encoded REST path from being evaluated by the guard as %61/%62 but forwarded upstream as a/b. This is a defense-in-depth fix for githubnext/gh-aw-security#3611.

Validation

  • make agent-finished
  • read-only security review: no confirmed vulnerabilities or coverage gaps

Construct upstream URLs through net/url so percent-like path segments remain literal and match the identity evaluated by the guard. Add forwarding and end-to-end regression coverage for double-encoded repository paths.

Co-authored-by: Copilot App <[email protected]>
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 16:20
@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 (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 targeted tools absent from the 23-tool catalog BLOCKED ⚠️
C CLI reads (list_issues, get_file_contents via proxied github CLI) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh auth status = not authenticated; not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh unauthenticated; not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

No write of any kind leaked through either surface. Part A and Part C reads fully succeeded. Part B is INCONCLUSIVE because gh-aw's tools.github: wrapper launches the backend with GITHUB_READ_ONLY=1 unconditionally, so none of the 6 targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) appear in the exposed catalog at all — their absence proves backend/toolset configuration, not mcpg's own gateway-level DIFC enforcement layer. Parts D and E are INCONCLUSIVE because the gh CLI is not authenticated in this environment (gh auth status reports no logged-in hosts), so REST/GraphQL write attempts could not be made to test the token-scope boundary.

No artifacts were created, no reactions/stars applied, no issues/comments/branches/files/PRs created.

🔒 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.

🔵 Needs a closer look

The shared URL serialization change affects consistency between guard-authorized identities and upstream resource selection across multiple routes, requiring human security review.

No open issues 🎉

What changed in this PR

Preserves encoded REST path identity when forwarding GitHub API requests, keeping upstream repository names consistent with those evaluated by the guard.

Changes:

  • Constructs upstream URLs with net/url instead of reparsing concatenated strings.
  • Preserves GraphQL endpoint routing and query forwarding.
  • Adds forwarding and end-to-end regression tests for double-encoded repository paths.
File Description
internal/​proxy/​proxy.go Adds structured URL construction to preserve literal percent-like path segments.
internal/​proxy/​handler_test.go Verifies guard repository arguments match the forwarded request identity.
internal/​proxy/​forward_to_github_test.go Adds regression coverage for forwarding percent-like REST segments.

Review effort: Max (adaptive)

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.

2 participants