Skip to content

[WIP] Fix REST API path injection in pkg/cli/outcome_eval.go - #50909

Merged
pelikhan merged 2 commits into
mainfrom
copilot/uk-ai-resilience-fix-rest-api-injection
Aug 6, 2026
Merged

[WIP] Fix REST API path injection in pkg/cli/outcome_eval.go#50909
pelikhan merged 2 commits into
mainfrom
copilot/uk-ai-resilience-fix-rest-api-injection

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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
Copilot AI requested a review from pelikhan August 6, 2026 16:07
@pelikhan
pelikhan marked this pull request as ready for review August 6, 2026 17:32
Copilot AI balanced review requested due to automatic review settings August 6, 2026 17:32
@pelikhan
pelikhan merged commit f4cd8b8 into main Aug 6, 2026
1 check passed
@pelikhan
pelikhan deleted the copilot/uk-ai-resilience-fix-rest-api-injection branch August 6, 2026 17:32

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.

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

  • escapeOwnerRepo still allows dot-only path components because url.PathEscape("..") returns ... For example, repo ../evil remains ../evil, allowing URL resolution to remove the repos segment. 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: escapeOwnerRepo leaves . 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 thread pkg/cli/outcome_eval.go
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 thread pkg/cli/outcome_eval.go
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, "/")
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.86.0

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.

[uk-ai-resilience] [Security] Tier C: REST API path injection in pkg/cli/outcome_eval.go (alerts #641, #642)

3 participants