Repository navigation
internal/graph: escape file and title strings written to dot - #1053
Merged
Merged
Conversation
Mapping/object file names and the graph title come from the profile and are attacker-controlled, but three sites wrote them into the dot output without escaping: the digraph name in start(), the legend tooltip in addLegend(), and the File/Objfile components of a node label in multilinePrintableName(). A double quote in any of them closes the quoted attribute and lets the profile inject further dot attributes (for example a URL=), which Graphviz emits as an xlink:href in the SVG that the web UI renders inline. Wrap each site in escapeForDot, matching the sibling node and edge tooltips that already escape.
aalexand
previously approved these changes
Oct 21, 2026
aalexand
enabled auto-merge (squash)
October 21, 2026 22:56
aalexand
disabled auto-merge
October 21, 2026 22:57
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1053 +/- ##
==========================================
+ Coverage 73.47% 73.50% +0.03%
==========================================
Files 46 46
Lines 7939 7941 +2
==========================================
+ Hits 5833 5837 +4
+ Misses 2084 2082 -2
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aalexand
reviewed
Oct 21, 2026
…atNeedEscaping Fold the file, objfile and title cases into the existing escaping test and have it assert on the escaped and unescaped forms of each string directly, so the compose7.dot golden is no longer needed.
aalexand
reviewed
Oct 22, 2026
aalexand
left a comment
Collaborator
There was a problem hiding this comment.
Thank you for working on this.
aalexand
approved these changes
Oct 31, 2026
aalexand
approved these changes
Nov 4, 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.
Mapping/object file names and the graph title come from the profile, but three sites in
internal/graph/dotgraph.gowrote them into the generated dot without escaping: thedigraphname instart(), the legendtooltipinaddLegend(), and theFile/Objfilecomponents of a node label inmultilinePrintableName(). A"in any of them closes the quoted attribute, so a crafted profile can inject dot attributes such asURL=, which Graphviz turns into anxlink:hrefin the SVG the web UI renders inline. The sibling node and edge tooltips already run throughescapeForDot; this wraps the three missed sites the same way.Repro: a profile whose mapping file name is
lib" URL="javascript:alert(1)renders, before this change, an<a xlink:href="javascript:alert(1)">inpprof -svg/-http; after it the quote is escaped and no such link appears.TestComposeWithNamesThatNeedEscapingnow checks the escaping directly instead of againstcompose7.dot(removed); it fails on the three unescaped sites and passes with the fix.