Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-24 - Cross-Site Scripting (XSS) in UI Modals
**Vulnerability:** The confirm dialog component used `innerHTML` with string interpolation for dynamic arguments like `title`, `message`, `confirmText`, and `cancelText`, introducing a Cross-Site Scripting (XSS) vulnerability.
**Learning:** Reusable UI components that accept arbitrary text arguments are prone to XSS if they construct DOM elements using template literals and `innerHTML` instead of dynamically setting properties like `textContent` after DOM construction.
**Prevention:** Avoid `innerHTML` when rendering user-provided or dynamically constructed text variables in frontend modules. Render the skeleton HTML first, select the nodes, and populate their content using `textContent`.
13 changes: 9 additions & 4 deletions webui/js/confirmDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export function showConfirmDialog(options) {
dialog.innerHTML = `
<div class="confirm-dialog-header">
<span class="confirm-dialog-icon material-symbols-outlined" style="color: ${typeConfig.color}">${typeConfig.icon}</span>
<span class="confirm-dialog-title">${title}</span>
<span class="confirm-dialog-title"></span>
</div>
<div class="confirm-dialog-body">${message}</div>
<div class="confirm-dialog-body"></div>
<div class="confirm-dialog-footer">
<button class="button cancel confirm-dialog-cancel">${cancelText}</button>
<button class="button confirm confirm-dialog-confirm">${confirmText}</button>
<button class="button cancel confirm-dialog-cancel"></button>
<button class="button confirm confirm-dialog-confirm"></button>
</div>
`;

Expand All @@ -48,6 +48,11 @@ export function showConfirmDialog(options) {
const footerElement = dialog.querySelector('.confirm-dialog-footer');
const cancelButton = dialog.querySelector('.confirm-dialog-cancel');
const confirmButton = dialog.querySelector('.confirm-dialog-confirm');

titleElement.textContent = title;
bodyElement.textContent = message;
cancelButton.textContent = cancelText;
confirmButton.textContent = confirmText;
let isClosed = false;

// Show with animation
Expand Down