Compare commits

...

2 Commits

Author SHA1 Message Date
google-labs-jules[bot] 35039c8463 🛡️ Sentinel: [HIGH] Fix DOM-based XSS in file upload
- Added `_escapeHtml` helper to sanitize user-controlled file name.
- Used it to sanitize `file.name` before appending it to `row.innerHTML`.
- Applied changes to `frontend/static/js/upload.js`.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-05-28 03:10:12 +00:00
google-labs-jules[bot] 6eeb83ea5e 🛡️ Sentinel: [HIGH] Fix DOM-based XSS in file upload
- Added `_escapeHtml` helper to sanitize user-controlled file name.
- Used it to sanitize `file.name` before appending it to `row.innerHTML`.
- Applied changes to `frontend/static/js/upload.js`.

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
2026-05-28 03:07:41 +00:00
+17 -1
View File
@@ -169,6 +169,21 @@ function _onUploadSuccess() {
}
}
/**
* Helper to sanitize strings before injecting into HTML.
* @param {string} str
* @returns {string}
*/
function _escapeHtml(str) {
if (!str) return '';
return String(str)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}
// ── Directory traversal helpers ───────────────────────────────────────────────
/**
@@ -297,9 +312,10 @@ function processFiles(files, progressContainer, statusMessage) {
const queueItems = fileArray.map((file) => {
const row = document.createElement('div');
row.className = 'flex flex-col mb-2';
const safeName = _escapeHtml(file.name);
row.innerHTML = `
<div class="flex justify-between">
<span class="text-sm truncate" title="${file.name}">${file.name}</span>
<span class="text-sm truncate" title="${safeName}">${safeName}</span>
<span class="text-xs text-gray-500">${formatFileSize(file.size)}</span>
</div>
<div class="w-full bg-gray-200 h-2 rounded-full mt-1">