Summary
A cross-site scripting (XSS) vulnerability in Salvo's list_html function allows untrusted file and folder names to be rendered directly in HTML without proper sanitization.
In deployments where users can upload files to publicly browsable directories, an attacker could craft filenames that inject arbitrary script code into the directory listing page viewed by other users.
Affected context
The vulnerability occurs in Salvo-based applications that use the list_html function to generate a browser-accessible directory index.
It becomes relevant when:
- Directory listings are exposed as public or semi-public HTTP endpoints, and
- Untrusted parties can cause new files or folders to appear in the listed directory (for example via uploads, imports, or synchronization from external sources).
In these conditions, unsanitized file and folder names are embedded into the HTML response, allowing crafted names to introduce active script content into the page.
Exploit preconditions
- Attack surface: HTTP endpoints that render directory listings via Salvo's
list_html. - Required access: Ability to create or influence file/folder names in a directory that is rendered by
list_html(e.g., file upload capability, shared storage, or external sync). - Trigger point: A user (victim) navigates to the affected directory listing URL in a web browser, causing the page to render the malicious filename.
- Why exploitation is possible: The implementation embeds raw file and folder names into HTML output without HTML-escaping or content sanitization, so specially crafted names can break out of intended markup and inject script or HTML attributes.
Why this happens
The core issue is an output encoding failure: untrusted data (file and directory names) are inserted into an HTML context without proper escaping.
This directly maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).
Instead of treating filenames as opaque data that must be encoded for the HTML context (text nodes, attributes, URLs), the rendering logic assumes them to be safe and writes them verbatim into the response.
In any templating or response-building code that mixes untrusted strings with markup, this pattern enables attackers to inject script tags, event handlers, or HTML that the browser executes as part of the page.
Potential impact
- Execution of arbitrary JavaScript in the context of the affected application's origin.
- Theft or hijacking of authenticated sessions via access to cookies, tokens, or browser storage (subject to security flags like HttpOnly).
- Unauthorized actions performed on behalf of a logged-in user through DOM manipulation or forged requests.
- Injection of malicious content into directory index pages that could be used for phishing, defacement, or distributing further payloads.
- Lateral movement against internal web tools if users browse internal file listings in privileged environments.
General mitigation guidance
Effective mitigation focuses on treating filenames as untrusted data and enforcing safe output patterns:
- Apply context-appropriate HTML escaping to all file and folder names before including them in directory listing pages (for example, replacing
<,>,&,", and'with HTML entities). - Use templating systems or response builders that perform automatic escaping by default and require explicit opt-out for raw HTML.
- Normalize and constrain displayed names where possible, avoiding direct reflection of raw filesystem names into HTML when not strictly necessary.
- Consider restricting directory listings or disabling public listing features when they are not required for the application.
- Complement output encoding with strong upload controls: limit who can upload, enforce strict filename patterns, and strip or replace characters that are problematic in HTML contexts.
How teams detect issues like this
Organizations can identify similar XSS risks in directory and listing features using a combination of review and automation:
- Static analysis: Configure SAST rules to flag concatenation of untrusted data (such as filenames, query parameters, or headers) into HTML responses without passing through an HTML-escaping API.
- Code review focus: Examine handlers that:
- Generate index pages, directory listings, or file browsers, and
- Render raw filesystem metadata into templates or string-built HTML.
Look for direct inclusion of names in tags, attributes, or script-related contexts.
- Security testing: Use dynamic testing or fuzzing to upload files with script-like names and verify how they are rendered in directory listing pages.
- Policy enforcement: Establish guidelines requiring context-specific encoding for all user-controlled data in views, and optionally enforce these via pre-commit hooks or CI checks that look for unsafe rendering patterns.

