Skip to content

Commit 3294e74

Browse files
committed
fix: prevent XSS via innerHTML in browser tree and explain visualizer (#9865)
Use textContent instead of innerHTML when setting DOM element text to prevent stored XSS through crafted PostgreSQL object names.
1 parent 79e490c commit 3294e74

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

web/pgadmin/static/js/Explain/Graphical.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ PolyLine.propTypes = {
9696

9797
function Multitext({currentXpos, currentYpos, label, maxWidth}) {
9898
const theme = useTheme();
99-
let abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
99+
const abc = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
100100
let xmlns = 'http://www.w3.org/2000/svg';
101101
let svgElem = document.createElementNS(xmlns, 'svg');
102102
svgElem.setAttributeNS(xmlns, 'height', '100%');
103103
svgElem.setAttributeNS(xmlns, 'width', '100%');
104104
let text = document.createElementNS(xmlns, 'text');
105-
text.innerHTML = abc;
105+
text.textContent = abc;
106106
text.setAttributeNS(xmlns, 'x', 0);
107107
text.setAttributeNS(xmlns, 'y', 0);
108108
let attributes={

web/pgadmin/static/js/components/PgTree/FileTreeX/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
458458
if (typeof(label) == 'object' && label.label) {
459459
label = label.label;
460460
}
461-
label$.innerHTML = label;
461+
label$.textContent = label;
462462
}
463463

464464
}
@@ -476,9 +476,9 @@ export class FileTreeX extends React.Component<IFileTreeXProps> {
476476
ref.style.background = 'none';
477477
const label$ = ref.querySelector('span.children-count') as HTMLDivElement;
478478
if(dir.children && dir.children.length > 0) {
479-
label$.innerHTML = '(' + dir.children.length + ')';
479+
label$.textContent = '(' + dir.children.length + ')';
480480
} else {
481-
label$.innerHTML = '';
481+
label$.textContent = '';
482482
}
483483
}
484484
}

0 commit comments

Comments
 (0)