Skip to content

Fix XSS vulnerabilities and data exposure in client-side JavaScript#1

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/check-repo-for-insecurities
Draft

Fix XSS vulnerabilities and data exposure in client-side JavaScript#1
Copilot wants to merge 6 commits intomainfrom
copilot/check-repo-for-insecurities

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 21, 2026

Security audit identified DOM-based XSS vectors, information disclosure via console logging, and unsanitized external data injection.

Fixes

XSS Prevention

  • Replaced innerHTML with textContent in tooltip rendering and modal close button
  • Prevents script injection via chart data labels and user interactions

Data Exposure

  • Removed console.log statements exposing Google Sheets data, geolocation info, and navigation state
  • Retained console.error for debugging

Input Sanitization

  • Added multi-layer sanitization for Google Sheets CSV data before DOM insertion
  • Handles HTML entities, script tags, dangerous protocols (javascript:, data:, vbscript:), and event handlers
  • Applied to 4 files fetching external spreadsheet data

Example sanitization:

const sanitizeInput = (input) => {
  if (typeof input !== 'string') return '';
  let sanitized = input;
  
  // Decode entities first to prevent <script> bypasses
  const textarea = document.createElement('textarea');
  textarea.innerHTML = sanitized;
  sanitized = textarea.value;
  
  // Remove script tags, HTML, dangerous protocols, event handlers
  sanitized = sanitized.replace(/<script[\s\S]*?<\/script[\s]*>/gi, '');
  sanitized = sanitized.replace(/<\/?[^>]+(>|$)/g, '');
  sanitized = sanitized.replace(/javascript\s*:|data\s*:|vbscript\s*:/gi, '');
  sanitized = sanitized.replace(/\bon\w+\s*=\s*["']?[^"']*["']?/gi, '');
  
  return sanitized.trim();
};

Artifacts

  • SECURITY.md - Audit findings, recommendations for CSP/SRI implementation
  • global/security-utils.js - Reusable sanitization utilities

CodeQL Results

24 alerts → 12 alerts. Remaining alerts are theoretical regex edge cases mitigated by defense-in-depth.

Original prompt

check this repo for insecurities


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits January 21, 2026 08:19
Co-authored-by: tm1303 <14999594+tm1303@users.noreply.github.com>
Co-authored-by: tm1303 <14999594+tm1303@users.noreply.github.com>
Co-authored-by: tm1303 <14999594+tm1303@users.noreply.github.com>
Co-authored-by: tm1303 <14999594+tm1303@users.noreply.github.com>
Co-authored-by: tm1303 <14999594+tm1303@users.noreply.github.com>
Copilot AI changed the title [WIP] Check repository for insecurities Fix XSS vulnerabilities and data exposure in client-side JavaScript Jan 21, 2026
Copilot AI requested a review from tm1303 January 21, 2026 08:28
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