[WIP] Fix REST API path injection in pkg/cli/outcome_eval.go - #50909
Merged
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot stopped work on behalf of
pelikhan due to an error
August 6, 2026 16:07
pelikhan
marked this pull request as ready for review
August 6, 2026 17:32
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens outcome-evaluation REST requests against path injection.
Changes:
- Adds segment-wise endpoint escaping.
- Applies escaping to object and array API requests.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/outcome_eval.go |
Escapes REST endpoint path segments before invoking gh api. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Suppressed comments (2)
pkg/cli/outcome_eval.go:268
escapeOwnerRepostill allows dot-only path components becauseurl.PathEscape("..")returns... For example, repo../evilremains../evil, allowing URL resolution to remove therepossegment. Reject.and..owner/repository components before constructing the API path.
args := []string{"api", fmt.Sprintf("repos/%s/%s", escapeOwnerRepo(ownerRepo), escapeEndpoint(endpoint))}
pkg/cli/outcome_eval.go:293
- This array path has the same dot-segment gap:
escapeOwnerRepoleaves.and..unchanged, so a crafted repository slug can still alter the resolved REST path. Validate and reject dot-only owner/repository components before interpolation.
args := []string{"api", fmt.Sprintf("repos/%s/%s", escapeOwnerRepo(ownerRepo), escapeEndpoint(endpoint))}
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Balanced
Comment on lines
+254
to
+258
| parts := strings.Split(endpoint, "/") | ||
| for i, p := range parts { | ||
| parts[i] = url.PathEscape(p) | ||
| } | ||
| return strings.Join(parts, "/") |
Comment on lines
+253
to
+258
| func escapeEndpoint(endpoint string) string { | ||
| parts := strings.Split(endpoint, "/") | ||
| for i, p := range parts { | ||
| parts[i] = url.PathEscape(p) | ||
| } | ||
| return strings.Join(parts, "/") |
Contributor
|
🎉 This pull request is included in a new release. Release: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
escapeEndpointhelper to URL-escape each segment of the REST API endpoint pathescapeEndpointinghAPIGet(alert Add timeout option to the neutral tool "bash" with optional configuration. Update compiler to generate code that configures the timeout in the agent. If the agent does not support timeout, fail the compilation. https://github.com/githubnext/gh-aw/issues/623 #641)escapeEndpointinghAPIGetArray(alert Fix patch application #642)