Skip to content

Potential fix for code scanning alert no. 1: DOM text reinterpreted as HTML#6

Open
cbulock wants to merge 1 commit into
mainfrom
alert-autofix-1
Open

Potential fix for code scanning alert no. 1: DOM text reinterpreted as HTML#6
cbulock wants to merge 1 commit into
mainfrom
alert-autofix-1

Conversation

@cbulock
Copy link
Copy Markdown
Owner

@cbulock cbulock commented May 19, 2026

Potential fix for https://github.com/cbulock/cindor/security/code-scanning/1

To fix this without changing functionality, ensure any DOM-derived state that is later interpolated into HTML strings is encoded before insertion into innerHTML templates. In this file, reuse existing escaping for attribute contexts (escapeAttribute(...)) and add strict runtime validation for enum-like values.

Best single approach here:

  1. Validate activeAlertTone at assignment time (in hydrateHomeExamples) so only allowed tones are accepted.
  2. Escape dynamic strings in HTML attributes in renderDocsHome, especially:
    • value="${activeSectionId}"value="${escapeAttribute(activeSectionId)}"
    • tone="${activeAlertTone}"tone="${escapeAttribute(activeAlertTone)}"
  3. Keep existing behavior intact (same rendering strategy and rerender flow), only hardening interpolations.

Edits are all in apps/docs/src/main.ts in the shown regions around:

  • renderDocsHome(...) template interpolations.
  • toneSelector and layerFilter change handlers in hydrateHomeExamples().

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…s HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@cbulock cbulock marked this pull request as ready for review May 19, 2026 19:40
Copilot AI review requested due to automatic review settings May 19, 2026 19:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Hardens the docs app’s innerHTML string templates against XSS by escaping DOM-derived values before interpolating them into HTML attributes, and by adding runtime allow-list validation for enum-like UI state.

Changes:

  • Escapes activeSectionId before interpolating into the cindor-tabs value="..." attribute.
  • Escapes activeAlertTone before interpolating into the cindor-alert tone="..." attribute.
  • Adds runtime allow-list validation when assigning activeAlertTone and catalogLayer from segmented-control values.

Comment thread apps/docs/src/main.ts
Comment on lines +1449 to +1452
catalogLayer =
nextLayer === "all" || nextLayer === "primitives" || nextLayer === "composites" || nextLayer === "workflows"
? nextLayer
: "all";
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.

2 participants