Summary
A reflected cross-site scripting (XSS) vulnerability in Salvo's list_html directory listing view allows attacker-controlled URL path data to be injected into the generated HTML without proper sanitization.
When a crafted request path is rendered into the file browser HTML, malicious script content can execute in the victim's browser if they follow a specially crafted link to an affected endpoint.
Affected context
The vulnerability occurs in Salvo-based applications that use the list_html functionality to serve an HTML file listing for a directory (for example, under a path like /files).
In these setups, the current request path is decoded, normalized for routing, and then inserted directly into the HTML template as current.path without proper escaping.
The issue becomes relevant when the configured root path for the file browser has at least one subdirectory so that navigation to crafted paths returns the listing view instead of a generic 404 page.
Exploit preconditions
- Attack surface: HTTP endpoints that expose the
list_htmlHTML directory listing view. - Required access: Ability to make HTTP requests to the affected endpoint; no authenticated access is strictly required unless the endpoint itself is protected.
- Trigger point: Sending a request with a specially crafted path segment that, once decoded and normalized by Salvo's routing, is reflected into the HTML as part of the current path.
- Why exploitation is possible: The framework decodes and normalizes the path for route matching but then reuses the raw path value in the generated HTML response without HTML-encoding or context-aware output escaping, enabling execution of attacker-supplied script content in the browser.
Why this happens
This vulnerability stems from improper neutralization of untrusted input when generating HTML output, aligning with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).
In Salvo's list_html implementation, the current request path is treated as displayable text and inserted directly into the directory listing HTML markup.
Because the value is taken from user-controlled request data and is not HTML-escaped or sanitized according to its output context, an attacker can craft a path that includes HTML or JavaScript fragments which the browser interprets as active content.
The trust boundary is effectively crossed when routing logic normalizes the path but does not ensure it is safe for presentation, causing an injection point in the rendered view.
Potential impact
- Execution of arbitrary JavaScript in the victim's browser in the context of the vulnerable origin.
- Theft of cookies, tokens, or other sensitive data accessible through the browser for that application.
- Performance of unauthorized actions on behalf of the victim (e.g., changing account settings or triggering state-changing requests).
- Phishing or UI redressing within the trusted application page to trick users into revealing credentials or other sensitive data.
- Use of the vulnerable endpoint as part of a larger attack chain, such as pivoting to other in-app resources or abusing the user's authenticated session.
General mitigation guidance
Effective mitigation focuses on context-aware output encoding and reducing the trust placed in request-derived values that are rendered into HTML.
Recommended patterns include:
- Applying strict HTML-encoding (and JavaScript-encoding where relevant) to all untrusted data before inserting it into templates, especially values derived from URLs, query parameters, or headers.
- Using templating helpers or framework-provided escaping functions by default, and avoiding raw HTML insertion paths except where absolutely necessary and carefully reviewed.
- Treating the normalized request path as untrusted display data and passing it through a canonical encoding routine before rendering into the directory listing view.
- Minimizing how much user-controlled URL data is reflected to users (e.g., displaying only safe, canonicalized segments or labels).
- Applying Content Security Policy (CSP) to reduce the impact of potential XSS by disallowing inline scripts and restricting script sources where practical.
How teams detect issues like this
Detection typically involves a combination of code-level review and automated analysis:
- Static analysis: Configure SAST tools to flag instances where request path or URL components are used directly in HTML responses without escaping, particularly in handlers related to directory listing or file browsing.
- Code review: Examine handlers and middleware that render views such as
list_htmlfor patterns like: - Direct insertion of
current.pathor similar path variables into templates. - Use of string concatenation or manual HTML building with user-derived values.
- Bypassing or disabling template engine auto-escaping.
- Dynamic testing: Incorporate XSS payload probes into security testing and QA for endpoints that reflect request paths, including fuzzing of path segments and encoded characters.
- Policy enforcement: Establish secure coding guidelines for Salvo and other Rust web frameworks that mandate output encoding of all user-controlled data, and enforce them via pre-merge checks or linters where possible.

