/

CVE-2026-22256

Severity:

HIGH RISK

(8.8)

XSS in Salvo list_html Directory Listing View

CVE-2026-22256

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Cross-Site Scripting leading to session theft, account impersonation, and unauthorized actions in the context of the affected web application

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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_html HTML 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_html for patterns like:
  • Direct insertion of current.path or 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.

Sources

SourceLink
github.comgithub.com/salvo-rs/salvo/blob/16efeba312a274739606ce76366d921768628654/crates/serve-static/src/dir.rs#L593
github.comgithub.com/salvo-rs/salvo/security/advisories/GHSA-rjf8-2wcw-f6mp

Frequently asked

questions

Yes. An attacker can exploit the vulnerability remotely by sending or sharing a specially crafted URL that targets an affected list_html directory listing endpoint. When a victim's browser loads that URL, the attacker-controlled path is reflected and can execute in the victim's session.

Not inherently. If the directory listing endpoint is publicly accessible, any remote user can attempt exploitation. If it is protected behind authentication, an attacker would need a way to make an authenticated victim access a crafted URL, or would need their own access to test and refine an exploit.

The most robust fix is to ensure that all request-derived data used in HTML—especially paths and query parameters—is passed through context-appropriate escaping before rendering. In practice, this means relying on template engines with auto-escaping enabled, avoiding raw HTML output routines, and explicitly encoding current.path (and similar values) when displayed.

Adopt a defensive development strategy that treats all inbound data as untrusted, uses output encoding by default, and avoids mixing string concatenation with HTML generation. Complement this with security-focused code review, automated testing for XSS patterns, and, where practical, deployment of a strict Content Security Policy to limit the consequences of any remaining injection points.

Find out what's already
exploitable in your codebase.