Skip to content

Commit 8efcdbf

Browse files
abhizipstackclaude
andauthored
fix: sanitize dangerouslySetInnerHTML with DOMPurify to prevent XSS (#33)
Add DOMPurify sanitization to the ANSI log renderer in no-code-model. The parseLog function converts ANSI escape codes to HTML via ansi-to-html, then renders with dangerouslySetInnerHTML. Without sanitization, malicious content in logs could execute scripts. - Install dompurify dependency - Wrap ansiToHtml.toHtml() output with DOMPurify.sanitize() - Only instance of dangerouslySetInnerHTML in the entire frontend Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5d912de commit 8efcdbf

File tree

3 files changed

+14
-35
lines changed

3 files changed

+14
-35
lines changed

frontend/package-lock.json

Lines changed: 11 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"cronstrue": "^3.0.0",
1919
"crypto-js": "^4.2.0",
2020
"dagre": "^0.8.5",
21+
"dompurify": "^3.3.3",
2122
"echarts": "^6.0.0",
2223
"framer-motion": "^12.23.12",
2324
"immer": "^10.0.2",

frontend/src/ide/editor/no-code-model/no-code-model.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useEffect, useRef, useState } from "react";
1414
import { Resizable } from "react-resizable";
1515
import Cookies from "js-cookie";
1616
import AnsiToHtml from "ansi-to-html";
17+
import DOMPurify from "dompurify";
1718
import yaml from "js-yaml";
1819
import {
1920
CalendarOutlined,
@@ -358,7 +359,7 @@ function NoCodeModel({ nodeData }) {
358359
});
359360
updateSpec(newSpec);
360361
};
361-
const parseLog = (log) => ansiToHtml.toHtml(log);
362+
const parseLog = (log) => DOMPurify.sanitize(ansiToHtml.toHtml(log));
362363

363364
const hideGenAIAndTimeTravelTabs = true;
364365
const BOTTOM_TABS = [

0 commit comments

Comments
 (0)