You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 50fbac4
Browse filesBrowse the repository at this point in the historyBrowse files
🛡️ Sentinel: [CRITICAL] Fix XSS in blog markdown parser (#1082)
* 🛡️ Sentinel: [CRITICAL] Fix XSS in blog markdown parser
* 🛡️ Sentinel: [CRITICAL] Fix XSS in blog markdown parser
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: GDS K S <gagandua078@gmail.com>
Copy file name to clipboardExpand all lines: .jules/sentinel.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,11 @@
7
7
**Learning:** Browsers do not escape single (`'`) or double (`"`) quotes when reading `.innerHTML` after assigning `.textContent`. If this "escaped" string is placed inside an HTML attribute (like `<button title="${escapeHtml(input)}">`), it can break out and cause XSS.
8
8
**Prevention:** Always use regex replacements or a robust library to escape HTML entities (`&`, `<`, `>`, `"`, `'`) for user input, especially when the output will be embedded within HTML attributes.
9
9
10
+
## 2025-02-14 - XSS in Markdown rendering logic
11
+
**Vulnerability:** The Markdown rendering logic in `src/app/blog/[slug]/page.tsx` directly used user input for HTML string formatting without HTML-escaping characters, allowing both raw HTML execution and `javascript:` protocol link injections.
12
+
**Learning:** Custom markdown parsers that rely on string `.replace` and pass the output directly into `dangerouslySetInnerHTML` are highly susceptible to XSS if not carefully escaped at the correct step, particularly against attributes like `href`.
13
+
**Prevention:** Always use a robust HTML-escaping utility before converting markdown tokens to HTML elements, and strictly block or filter unsafe protocols like `javascript:` when formatting user-provided URLs in `href` attributes.
10
14
## 2026-09-16 - Sentinel Character Injection in Regex-based Syntax Highlighter
11
-
**Vulnerability:** The `esc()` function in `src/components/icons/shared/syntax-highlight.tsx` failed to strip internal sentinel characters (\`\` and \`\`) before they were used as placeholders in regex replacements for syntax highlighting.
15
+
**Vulnerability:** The `esc()` function in `src/components/icons/shared/syntax-highlight.tsx` failed to strip internal sentinel characters (`` and ``) before they were used as placeholders in regex replacements for syntax highlighting.
12
16
**Learning:** When using internal sentinel characters for multi-pass string replacements, they must be stripped from the original user input first. Otherwise, an attacker can submit an SVG containing these characters, bypassing the intended markup structure and injecting arbitrary HTML/JavaScript (XSS) when the highlighted code is rendered.
13
17
**Prevention:** Always strip custom sentinel markers from the input before any regex substitution logic begins. Better yet, avoid replacing string tags into `dangerouslySetInnerHTML` if possible, favoring a safer AST-based rendering approach.
0 commit comments