{"id":"GHSA-rjf8-2wcw-f6mp","summary":"Salvo is vulnerable to reflected XSS in the list_html function","details":"# Summary\n\nThe function `list_html` generates an file view of a folder which includes a render of the current path, in which its inserted in the HTML without proper sanitation, leading to reflected XSS. The request path is decoded and normalized in the matching stage but is not inserted raw in the HTML view (current.path). The only constraint here is for the root path (e.g., /files in the PoC example) to have a subdirectory (e. g., common ones like styles/scripts/etc.) so that the matching returns the list HTML page instead of the Not Found page.\n\n# Details\n\nThe vulnerable snippet of code is the following:\n[**dir.rs**](https://github.com/salvo-rs/salvo/blob/16efeba312a274739606ce76366d921768628654/crates/serve-static/src/dir.rs#L593)\n\n```rust\n// ... fn list_html(...\n    let mut ftxt = format!(\n        r#\"\u003c!DOCTYPE html\u003e\u003chtml\u003e\u003chead\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003cmeta name=\"viewport\" content=\"width=device-width\"\u003e\n        \u003ctitle\u003e{}\u003c/title\u003e\n        \u003cstyle\u003e{}\u003c/style\u003e\u003c/head\u003e\u003cbody\u003e\u003cheader\u003e\u003ch3\u003eIndex of: {}\u003c/h3\u003e\u003c/header\u003e\u003chr/\u003e\"#,\n        current.path,\n        HTML_STYLE,\n        header_links(&current.path)\n    );\n// ...\n```\n\nAs seen here `\u003ctitle\u003e{}\u003c/title\u003e` it is inserted unsafely.\n\n# PoC\n\nhttps://github.com/user-attachments/assets/92a29a67-547b-40a5-af26-f1b0dd332702\n\nHere is the example app, note this doesn’t need an upload feature (e.g to the other reported vulnerability), only the sub-folder is required.\n\n`main.rs`\n```rust\nuse salvo::prelude::*;\nuse salvo::serve_static::StaticDir;\nuse tokio::fs;\n\n#[tokio::main]\nasync fn main() {\n    tracing_subscriber::fmt().init();\n    fs::create_dir_all(\"uploads\").await.expect(\"create uploads dir\");\n\n    let router = Router::new()\n        .push(\n            Router::with_path(\"files/{**rest_path}\")\n                .get(StaticDir::new(\"uploads\").auto_list(true)),\n        );\n\n    let acceptor = TcpListener::new(\"127.0.0.1:5800\").bind().await;\n    Server::new(acceptor).serve(router).await;\n}\n```\n\n`Cargo.toml`\n```rust\n[package]\nname = \"salvo-staticdir-xss-poc\"\nversion = \"0.1.0\"\nedition = \"2024\"\n\n[dependencies]\nsalvo = { version = \"0.85.0\", features = [\"serve-static\"] }\ntokio = { version = \"1\", features = [\"macros\", \"rt-multi-thread\", \"fs\"] }\ntracing-subscriber = \"0.3\"\n```\n\nSetup commands:\n```bash\nmkdir uploads\nmkdir uploads/bla\n```\n\n# Impact\n\nJavaScript execution, most likely leading to an account takeover, depending on the site's constraint (CSP, etc…).","aliases":["CVE-2026-22256"],"modified":"2026-02-03T03:15:26.215442Z","published":"2026-01-08T21:22:18Z","database_specific":{"nvd_published_at":"2026-01-08T19:16:00Z","cwe_ids":["CWE-79"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-01-08T21:22:18Z"},"references":[{"type":"WEB","url":"https://github.com/salvo-rs/salvo/security/advisories/GHSA-rjf8-2wcw-f6mp"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-22256"},{"type":"PACKAGE","url":"https://github.com/salvo-rs/salvo"},{"type":"WEB","url":"https://github.com/salvo-rs/salvo/blob/16efeba312a274739606ce76366d921768628654/crates/serve-static/src/dir.rs#L593"}],"affected":[{"package":{"name":"salvo","ecosystem":"crates.io","purl":"pkg:cargo/salvo"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.88.1"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/01/GHSA-rjf8-2wcw-f6mp/GHSA-rjf8-2wcw-f6mp.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:L/A:L"}]}