Skip to content

Potential fix for code scanning alert no. 5: Reflected cross-site scripting - #13

Open
aramprice wants to merge 1 commit into
masterfrom
alert-autofix-5
Open

Potential fix for code scanning alert no. 5: Reflected cross-site scripting#13
aramprice wants to merge 1 commit into
masterfrom
alert-autofix-5

Conversation

@aramprice

Copy link
Copy Markdown
Member

Potential fix for https://github.com/cloudfoundry/go-fetcher/security/code-scanning/5

The safest fix is contextual output encoding for any user-influenced value before inserting it into HTML. Here, repoName (from the URL path) is used in HTML attribute values for both go-import and go-source meta tags. Escape the fully composed attribute content strings with html.EscapeString before formatting HTML.

Best minimal-change fix in handlers/handler.go:

  1. Add standard library import html.
  2. Escape goImportContent before constructing goImport.
  3. Escape goSourceContent before constructing goSource.

This preserves existing behavior while preventing attribute-breaking XSS payloads from being reflected.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ipting

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@aramprice
aramprice marked this pull request as ready for review August 6, 2026 17:03
@aramprice

Copy link
Copy Markdown
Member Author

GitHub workers are currently having issues, which is causing the PR checks to timeout:
=> https://www.githubstatus.com/

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.

1 participant