From b2ffa828c31700c12d11344ad8674e42250d0288 Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sat, 20 Jun 2026 14:11:57 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[HIGH]=20Fi?= =?UTF-8?q?x=20HTML=20comment=20breakout=20in=20JSON=20serialization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🚨 Severity: HIGH 💡 Vulnerability: Markdown Injection / HTML Comment Breakout 🎯 Impact: An attacker could inject `-->` into JSON payloads, prematurely closing HTML comments and injecting arbitrary Markdown into GitHub issue comments. 🔧 Fix: Escaped `<`, `>`, and `&` to unicode (`\u003c`, `\u003e`, `\u0026`) in the serialized JSON. ✅ Verification: Tested syntax and verified valid unicode JSON parsing. --- .jules/sentinel.md | 4 ++++ scripts/ci/opencode_review_normalize_output.py | 1 + 2 files changed, 5 insertions(+) create mode 100644 .jules/sentinel.md diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 000000000..f030d327c --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2024-06-20 - Prevent HTML Comment Breakout in JSON Serialization +**Vulnerability:** Markdown Injection / HTML Comment Breakout +**Learning:** JSON serialized into HTML comments (like ``) can contain `-->` in string values, causing GitHub's Markdown parser to close the comment prematurely and render the remaining JSON as attacker-controlled text or Markdown. +**Prevention:** Always escape `<` and `>` as `\u003c` and `\u003e` (and `&` as `\u0026`) when embedding JSON in HTML contexts (even Markdown comments) to prevent breakout. diff --git a/scripts/ci/opencode_review_normalize_output.py b/scripts/ci/opencode_review_normalize_output.py index 2a850c646..711fd1ef3 100755 --- a/scripts/ci/opencode_review_normalize_output.py +++ b/scripts/ci/opencode_review_normalize_output.py @@ -123,6 +123,7 @@ def main(argv: list[str]) -> int: continue normalized_json = json.dumps(control, separators=(",", ":"), ensure_ascii=False) + normalized_json = normalized_json.replace("<", "\\u003c").replace(">", "\\u003e").replace("&", "\\u0026") output_file.write_text( "\n".join( [