Repository navigation
Stop interpolating archive paths into inline handlers - #470
Merged
Merged
Conversation
The source browser built its file tree with onclick handlers such as
loadFile('${escapeHTML(file.path)}'). The browser decodes HTML entities in
an attribute before running the handler, so the &git-pkgs#39; that escapeHTML
produces turns back into a quote and ends the string. A cached package
with a crafted file name ran script on the proxy origin for anyone who
browsed it.
- Carry the path in data-path and dispatch clicks from one delegated
listener on the file tree
- Render the binary download button as a link instead of an onclick
that assigns window.location
- Fail the template tests when an inline handler interpolates data
andrew
approved these changes
Oct 14, 2026
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.
The source browser built its file tree with inline handlers such as
onclick="loadFile('${escapeHTML(file.path)}')". The browser decodes HTML entities in an attribute value before it runs the handler, so the'thatescapeHTMLproduces turns back into'and ends the JS string. Once a package with a crafted file name in its archive (e.g.a');alert(1);//) is cached, opening it in/ui/package/...runs that script on the proxy origin.Changes
data-action/data-path, and one delegated click listener on#file-treedispatches toloadFileTree/loadFile. The path now only ever sits in HTML attribute context, whereescapeHTMLis sufficient.<a href>instead of anonclickthat setswindow.location.currentPathupdates work as before.Testing
TestTemplatesInterpolateNoDataIntoInlineHandlersscans every embedded template for anon*="…${attribute. Before the fix it found the 4 handlers inbrowse_source.html.go test -race ./internal/server/...,go vetandgolangci-lintv2.13.1 pass.