Skip to content

Disable upstream redirects in all proxy modes - #17032

Merged
lpcox merged 4 commits into
mainfrom
copilot/disable-upstream-redirects
Nov 21, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/disable-upstream-redirects

Conversation

@lpcox

@lpcox lpcox commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Default and delegation modes followed upstream redirects while authorizing and labeling responses against the original repository path. Rename or transfer redirects could therefore return data outside the intended scope.

  • Redirect enforcement: Set CheckRedirect unconditionally and use no-redirect forwarding for every request, exposing 3xx responses to existing coarse authorization.
  • Client routing: Retain proxy-local rewrites for upstream API Location URLs so clients reauthorize the target. Preserve authorized external download URLs; document the all-mode policy.
  • Regression coverage: Assert one upstream request, coarse allow/deny behavior, and rejection when a delegated client follows a redirect outside its assigned repository.

@lpcox lpcox changed the title [WIP] Disable upstream redirect following in all modes Disable upstream redirects in all proxy modes Nov 21, 2026
@lpcox
lpcox marked this pull request as ready for review November 21, 2026 18:19
Copilot AI adaptive review requested due to automatic review settings November 21, 2026 18:19
@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 redirect-handling flaws allow clients to bypass proxy authorization and response filtering, while guard enrichment incorrectly accepts redirect stubs as successful data.

3 open issues
What changed in this PR

This PR addresses #17031 by making GitHub API redirects client-driven in every proxy mode, rather than fetching redirect targets under the original repository’s authorization and labels.

Changes:

  • Disable upstream redirect following for all proxy requests.
  • Add regression coverage for coarse authorization, request counts, and delegated redirect targets.
  • Document the all-mode policy and existing API URL rewriting and external download behavior.
File Description
internal/​proxy/​proxy.go Applies an unconditional no-follow policy to upstream requests.
internal/​proxy/​handler_difc_test.go Tests redirect authorization, single-request forwarding, and delegated target denial.
docs/​PROXY_MODE.md Documents redirects across all modes and client-facing URL handling.

Review effort: Max (adaptive)

Comment thread internal/proxy/proxy.go
return doWithoutFollowingRedirects(s.httpClient, req)
}
return s.httpClient.Do(req)
return doWithoutFollowingRedirects(s.httpClient, req)
Comment thread internal/proxy/proxy.go
return doWithoutFollowingRedirects(s.httpClient, req)
}
return s.httpClient.Do(req)
return doWithoutFollowingRedirects(s.httpClient, req)
Comment thread internal/proxy/proxy.go
return doWithoutFollowingRedirects(s.httpClient, req)
}
return s.httpClient.Do(req)
return doWithoutFollowingRedirects(s.httpClient, req)
@lpcox

lpcox commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot address review feedback

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

Copilot AI commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@copilot address review feedback

Addressed the redirect authorization, enrichment, and URL-rewriting feedback. Commit: 37bac22.

@lpcox

lpcox commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

@github-actions

This comment has been minimized.

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

Copilot AI commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the failing lint checks https://github.com/github/gh-aw-mcpg/actions/runs/44936573353/job/136944868657?pr=17032

Fixed the testifylint failure by moving the fatal assertion outside the HTTP handler. make lint and make agent-finished pass. Commit: f01ec10.

@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 (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 target tools absent from exposed catalog (only 23 read-only tools registered) BLOCKED ⚠️
C CLI reads (same ops via gateway-backed github CLI) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh not authenticated (gh auth status failed); not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh not authenticated; not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: all 6 write-tool targets (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) were absent from the gateway-backed github CLI catalog entirely — this confirms backend/toolset configuration (gh-aw's GITHUB_READ_ONLY=1) but does not independently confirm mcpg's own gateway-level write-blocking layer, per the test methodology. No write was attempted or leaked.

⚠️ Parts D/E: gh CLI is not authenticated in this environment, so the token-scope write-boundary could not be exercised. No write was attempted.

No reaction, star, issue, comment, branch, file, or PR was created in any part of this run.

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

@lpcox
lpcox merged commit 2743e60 into main Nov 21, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/disable-upstream-redirects branch November 21, 2026 19:37
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.

proxy: disable upstream redirect following in all modes (default and delegation)

3 participants