T09 · Insecure Skill Coding Practices
- Location
assets/scanner.html:287- Finding
DOM-Based HTML Injection Through Attacker-Controlled Filenames
- Content
View full analysis
{ const row = document.createElement('tr'); row.innerHTML = ` ${file.name} ${file.type} ${formatFileSize(file.size)} ${file.lastModifiedDate} `; tbody.appendChild(row); }); ``` ### Technical Analysis `File.name` and `File.webkitRelativePath` originate from files selected by the user and must be treated as untrusted data. A filename can contain HTML metacharacters on supported filesystems. The code interpolates this data directly into `row.innerHTML`, causing the browser to parse it as markup rather than display it as text. A crafted filename containing an element with an event handler can therefore introduce active DOM content when `generateTable()` runs. The derived `file.type` value is also inserted through the same unsafe sink. The ...[truncated 2283 chars]- Remediation
View remediation
