From 46de578a7eb149ecf2790b5f2ecdd182d7e538d4 Mon Sep 17 00:00:00 2001 From: Julius Brussee Date: Mon, 1 Jun 2026 21:04:58 +0200 Subject: [PATCH] fix(docs): escape user input in demo terminal (XSS) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Folds in #438 — the docs demo terminal interpolated user input via innerHTML (real reflected/DOM XSS); build nodes with textContent instead. (PR title 'CLI input handler' was a misnomer.) Co-Authored-By: Claude Opus 4.8 (1M context) --- docs/index.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 7505048..a0f4c9f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -417,7 +417,17 @@ cliInput.addEventListener('keydown', (e) => { const val = cliInput.value.trim(); const row = document.createElement('div'); row.className = 'term-line'; - row.innerHTML = ` ${val}`; + + // SECURITY FIX: Create DOM elements safely to prevent XSS + const prompt = document.createElement('span'); + prompt.className = 'term-accent'; + prompt.textContent = '❯'; + + const commandText = document.createElement('span'); + commandText.textContent = ` ${val}`; // textContent automatically escapes HTML + + row.appendChild(prompt); + row.appendChild(commandText); cliInput.parentElement.before(row); const res = document.createElement('div');