Skip to content

Commit 0ec6917

Browse files
chschanclaude
andcommitted
RS-22478: fix stored XSS in palm tree tooltips
HTML-escape row/column names and label text built into tooltip content (covers both the tooltip render and its size measurement). Rebuilt the inst/htmlwidgets bundle. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a43ef9c commit 0ec6917

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

inst/htmlwidgets/rhtmlPalmTrees.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/htmlwidgets/rhtmlPalmTrees.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

theSrc/scripts/TipContentFactory.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
import _ from 'lodash'
2+
3+
function escapeHtml (value) {
4+
return String(value)
5+
.replace(/&/g, '&amp;')
6+
.replace(/</g, '&lt;')
7+
.replace(/>/g, '&gt;')
8+
.replace(/"/g, '&quot;')
9+
.replace(/'/g, '&#39;')
10+
}
11+
212
// tip depends on
313
// this.settings.tooltipsHeadingFontFamily
414
// this.settings.tooltipsHeadingFontSize
@@ -45,7 +55,7 @@ function makeTipContent ({
4555
})
4656
}).join('\n')
4757

48-
let headingText = `${rowName}${(_.isEmpty(yLabel) ? '' : ` - ${yLabel}`)} ${rowTotal}`
58+
let headingText = `${escapeHtml(rowName)}${(_.isEmpty(yLabel) ? '' : ` - ${escapeHtml(yLabel)}`)} ${rowTotal}`
4959
return `<div class="tipHeading tip-${rowIndex}" style="font-family:${headingFontFamily};font-size:${headingFontSize}px">${headingText}</div>
5060
<div class="tipTableContainer">
5161
<table class="tipTable">
@@ -70,8 +80,8 @@ function makeTipContentRow ({
7080
unselectedColor,
7181
}) {
7282
return `<tr class="tip-column tip-column-${columnIndex} ${(valueEnabled) ? '' : 'column-off"'}">
73-
<td style="text-align:right;font-family:${fontFamily};font-size:${fontSize}px">${prefix || ''}${value || ''}${suffix || ''}</td>
74-
<td style="text-align:left;font-family:${fontFamily};font-size:${fontSize}px">${name}</td>
83+
<td style="text-align:right;font-family:${fontFamily};font-size:${fontSize}px">${prefix ? escapeHtml(prefix) : ''}${value || ''}${suffix ? escapeHtml(suffix) : ''}</td>
84+
<td style="text-align:left;font-family:${fontFamily};font-size:${fontSize}px">${escapeHtml(name)}</td>
7585
<td style="text-align:center">
7686
<div style="width:${barWidth}px;height:8px;background-color:${(valueEnabled) ? barColor : unselectedColor}"></div>
7787
</td>

0 commit comments

Comments
 (0)