Skip to content

Fix DOM-based XSS in terminal command echo (workspace.js) - #11

Merged
piyyy314 merged 5 commits into
masterfrom
copilot/fix-code-scanning-alerts-again
Aug 8, 2026
Merged

Fix DOM-based XSS in terminal command echo (workspace.js)#11
piyyy314 merged 5 commits into
masterfrom
copilot/fix-code-scanning-alerts-again

Conversation

Copilot AI commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

User input (rawCmd) was interpolated directly into an innerHTML assignment, allowing arbitrary HTML/JS injection via crafted terminal commands (CodeQL alert #3, js/xss-through-dom).

Changes

  • sentinelos/js/workspace.js: Replace unsafe innerHTML template literal with explicit DOM construction for the terminal echo line — prompt text set via textContent, user input appended as a createTextNode, ensuring raw input is never parsed as HTML.
// Before — XSS: rawCmd injected into innerHTML
appendTermLine(`<span class="prompt">sentinel@core:~$</span> ${rawCmd}`, true);

// After — safe DOM construction
const echoLine = document.createElement('div');
echoLine.className = 'term-line';
const prompt = document.createElement('span');
prompt.className = 'prompt';
prompt.textContent = 'sentinel@core:~$';
echoLine.appendChild(prompt);
echoLine.appendChild(document.createTextNode(' ' + rawCmd));

@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer Ready Ready Preview Aug 8, 2026 3:13pm

@piyyy314

piyyy314 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

…f innerHTML for user input

Co-authored-by: piyyy314 <192450738+piyyy314@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code scanning alert #3 Fix DOM-based XSS in terminal command echo (workspace.js) Aug 8, 2026
Copilot AI requested a review from piyyy314 August 8, 2026 13:23
@piyyy314
piyyy314 marked this pull request as ready for review August 8, 2026 13:51
Copilot AI lite review requested due to automatic review settings August 8, 2026 13:51
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Mitigates a DOM-based XSS in the terminal command echo by eliminating innerHTML interpolation of user input and constructing the echoed line using safe DOM APIs.

Changes:

  • Replaced appendTermLine(..., true) usage with explicit DOM element creation for the echo line.
  • Ensured rawCmd is inserted via createTextNode (not parsed as HTML) and prompt text via textContent.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sentinelos/js/workspace.js Outdated
Comment on lines +48 to +58
if (termScreen && cursorLine) {
const echoLine = document.createElement('div');
echoLine.className = 'term-line';
const prompt = document.createElement('span');
prompt.className = 'prompt';
prompt.textContent = 'sentinel@core:~$';
echoLine.appendChild(prompt);
echoLine.appendChild(document.createTextNode(' ' + rawCmd));
termScreen.insertBefore(echoLine, cursorLine);
termScreen.scrollTop = termScreen.scrollHeight;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit — the guard now checks only termScreen, and falls back to termScreen.appendChild(echoLine) when cursorLine is absent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest commit. The guard now only checks termScreen, with a fallback to termScreen.appendChild(echoLine) when cursorLine is absent.

Co-authored-by: piyyy314 <192450738+piyyy314@users.noreply.github.com>
…XSS in chat messages

Co-authored-by: piyyy314 <192450738+piyyy314@users.noreply.github.com>
@piyyy314
piyyy314 merged commit 953fa34 into master Aug 8, 2026
7 of 8 checks passed
@piyyy314
piyyy314 deleted the copilot/fix-code-scanning-alerts-again branch August 8, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants