Описание
Salvo is vulnerable to reflected XSS in the list_html function
Summary
The 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.
Details
The vulnerable snippet of code is the following: dir.rs
As seen here <title>{}</title> it is inserted unsafely.
PoC
https://github.com/user-attachments/assets/92a29a67-547b-40a5-af26-f1b0dd332702
Here 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.
main.rs
Cargo.toml
Setup commands:
Impact
JavaScript execution, most likely leading to an account takeover, depending on the site's constraint (CSP, etc…).
Пакеты
salvo
< 0.88.1
0.88.1
Связанные уязвимости
Salvo is a Rust web backend framework. Prior to version 0.88.1, the function list_html generate an file view of a folder which include a render of the current path, in which its inserted in the HTML without proper sanitation, this leads to reflected XSS using the fact that request path is decoded and normalized in the matching stage but not is inserted raw in the html view (current.path), the only constraint here is for the root path (eg. /files in the PoC example) to have a sub directory (e.g common ones styles/scripts/etc…) so that the matching return the list HTML page instead of the Not Found page. This issue has been patched in version 0.88.1.