Skip to content

Conversation

@GrimbiXcode
Copy link
Owner

Potential fix for https://github.com/GrimbiXcode/mtgscan/security/code-scanning/1

To fix the problem, escape any untrusted text content before inserting it into innerHTML. Specifically, for the notification system, instead of interpolating the user-provided message (which could contain HTML) directly into the notification's innerHTML, you should either:

  1. Escape meta characters in the message string (convert <, >, &, ", ' etc. to their HTML entity equivalents), OR
  2. Set the notification content using textContent instead of innerHTML for the message part.

The best approach in this context is to set .innerHTML only for safe, static markup (like the icon and structure), and inject the user-provided message as plain text using textContent.

This means:

  • In showNotification, change the logic so that the notification container is constructed as a DOM structure with createElement, then set the icon via innerHTML (as it's from a hardcoded set), and set the message via textContent.
  • Alternatively, if you need to keep using a template string, escape the message text before interpolation.

The edits are needed in showNotification (lines 2305-2309). If escaping is used, a small escapeHtml method will be required in the class.

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>
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