Skip to content

🔒 [security fix] Replace innerHTML with textContent to mitigate XSS risk#3651

Merged
yurishkuro merged 3 commits intojaegertracing:mainfrom
jkowall:security-fix-innerHTML-xss-risk-calc-positioning-10016137243870737156
Mar 22, 2026
Merged

🔒 [security fix] Replace innerHTML with textContent to mitigate XSS risk#3651
yurishkuro merged 3 commits intojaegertracing:mainfrom
jkowall:security-fix-innerHTML-xss-risk-calc-positioning-10016137243870737156

Conversation

@jkowall
Copy link
Copy Markdown
Contributor

@jkowall jkowall commented Mar 21, 2026

🎯 What: The vulnerability fixed is a potential Cross-Site Scripting (XSS) issue in the calcRects function of packages/jaeger-ui/src/components/DeepDependencies/Graph/DdgNodeContent/calc-positioning.ts.

⚠️ Risk: The use of innerHTML when setting the content of a measurement span could allow an attacker to inject and execute malicious scripts if the input strings (like service or operation names) are not properly sanitized or originate from an untrusted source.

🛡️ Solution: The fix replaces innerHTML with textContent. Since the code is only intended to measure the visual dimensions of plain text strings, textContent provides a secure alternative that prevents the browser from parsing the input as HTML, thus eliminating the XSS vector. A security-focused unit test has also been added to verify this behavior.


PR created automatically by Jules for task 10016137243870737156 started by @jkowall

@jkowall jkowall requested a review from a team as a code owner March 21, 2026 20:47
Copilot AI review requested due to automatic review settings March 21, 2026 20:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR mitigates a potential XSS vector in the Deep Dependencies graph node sizing logic by avoiding HTML parsing when measuring text, and adds a regression/security-focused unit test.

Changes:

  • Replaced innerHTML with textContent in calcRects() to ensure measurement strings are treated as plain text.
  • Added a new unit test intended to verify HTML-like input is handled as text.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/jaeger-ui/src/components/DeepDependencies/Graph/DdgNodeContent/calc-positioning.ts Uses textContent instead of innerHTML when measuring text widths (XSS mitigation).
packages/jaeger-ui/src/components/DeepDependencies/Graph/DdgNodeContent/calc-positioning.test.js Adds a security regression test for HTML-tag-like input handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jkowall jkowall added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label Mar 21, 2026
Copilot AI review requested due to automatic review settings March 21, 2026 21:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

google-labs-jules bot and others added 3 commits March 22, 2026 10:55
This change mitigates a potential Cross-Site Scripting (XSS) vulnerability by replacing `innerHTML` with `textContent` when setting the content of a measurement span. Since the purpose of the code is to measure the width of plain text strings (service names, operation names, etc.), `textContent` is a safer and more appropriate choice as it does not parse input as HTML.

- Updated `packages/jaeger-ui/src/components/DeepDependencies/Graph/DdgNodeContent/calc-positioning.ts`
- Added security test case to `packages/jaeger-ui/src/components/DeepDependencies/Graph/DdgNodeContent/calc-positioning.test.js` to ensure HTML tags are treated as plain text.

Signed-off-by: Jules <jules@example.com>

Co-authored-by: jkowall <1859948+jkowall@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
Signed-off-by: Jonah Kowall <jkowall@kowall.net>
@jkowall jkowall force-pushed the security-fix-innerHTML-xss-risk-calc-positioning-10016137243870737156 branch from 3e1abd1 to d01a71d Compare March 22, 2026 14:56
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.26%. Comparing base (8ef3273) to head (d01a71d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3651      +/-   ##
==========================================
+ Coverage   89.15%   89.26%   +0.11%     
==========================================
  Files         305      306       +1     
  Lines        9743     9894     +151     
  Branches     2597     2630      +33     
==========================================
+ Hits         8686     8832     +146     
- Misses       1053     1059       +6     
+ Partials        4        3       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jkowall jkowall enabled auto-merge March 22, 2026 14:58
@jkowall jkowall added this pull request to the merge queue Mar 22, 2026
@yurishkuro yurishkuro removed this pull request from the merge queue due to a manual request Mar 22, 2026
@yurishkuro yurishkuro closed this Mar 22, 2026
@yurishkuro yurishkuro reopened this Mar 22, 2026
@yurishkuro yurishkuro enabled auto-merge March 22, 2026 17:48
@yurishkuro yurishkuro added this pull request to the merge queue Mar 22, 2026
Merged via the queue into jaegertracing:main with commit 75cefa8 Mar 22, 2026
23 checks passed
jkowall added a commit to jkowall/jaeger-ui-F that referenced this pull request Mar 29, 2026
jaegertracing#3651)

Replaced `innerHTML` with `textContent` in `calc-positioning.ts` to
prevent potential Cross-Site Scripting (XSS) when measuring service and
operation names.

Note: This is a duplicate of jaegertracing#3651 which is already merged to main.

changelog:security

Co-authored-by: jkowall <1859948+jkowall@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants