CVE-2022-25847: Cross-site Scripting (XSS) in serve-lite

serve-lite Updated 02 Oct 2025

Summary

26/01/2023
No i
Moderate
5.4

CVE-2022-25847: Cross-site Scripting (XSS) in serve-lite. Affects serve-lite versions < 1.1.0. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

serve-lite is an npm package that provides a lightweight server for serving static files. It is commonly used to quickly set up a local development server or to serve static files in production environments. The package is vulnerable to Cross-site Scripting (XSS) attacks due to a lack of sanitization or output encoding when rendering a file listing of a directory. This allows an attacker to inject malicious scripts into the rendered HTML, potentially leading to the execution of arbitrary code in the context of the victim's browser.

Vulnerability Detail

The vulnerability in serve-lite arises from its behavior when it detects a request to a directory. Instead of properly sanitizing or encoding the file names, it includes them as links in the rendered file listing. This allows an attacker to craft a malicious file name that includes JavaScript code, which will be executed when the victim clicks on the link. The impact of this vulnerability can range from stealing sensitive information, such as session cookies, to performing actions on behalf of the victim within the context of the vulnerable application.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a temporary workaround, developers can manually sanitize or encode the file names before passing them to serve-lite for rendering. This can be done using libraries or functions that provide HTML encoding capabilities. Here's an example of how to sanitize the file names using the 'he' library in JavaScript:

const he = require('he');

const sanitizedFileNames = fileNames.map(fileName => he.encode(fileName));

Conclusion

serve-lite is vulnerable to Cross-site Scripting (XSS) attacks due to a lack of sanitization or output encoding when rendering a file listing of a directory. This can allow an attacker to inject malicious scripts into the rendered HTML, potentially leading to the execution of arbitrary code in the victim's browser. To mitigate this vulnerability, it is important to update to the latest version of serve-lite and implement proper sanitization or output encoding when rendering file listings. For further support on vulnerability remediation, you can contact DevNack.com.

See every vulnerability recorded for serve-lite →

Share this vulnerability

FAQ

serve-lite is an npm package that provides a lightweight server for serving static files. It is commonly used in web development to quickly set up a local server for testing and debugging purposes.

Cross-site Scripting (XSS) is a type of security vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. This can lead to the theft of sensitive information or the execution of arbitrary code in the context of the victim's browser.

The serve-lite vulnerability occurs when it renders a file listing of a directory without properly sanitizing or encoding the file names. This allows an attacker to inject malicious scripts into the rendered HTML, which can be executed when the victim interacts with the file listing.

The consequences of the serve-lite vulnerability can vary depending on the attacker's intentions. It can range from stealing sensitive information, such as session cookies, to performing actions on behalf of the victim within the context of the vulnerable application.

To protect your application from the serve-lite vulnerability, it is recommended to update to the latest version of the serve-lite package, which includes a fix for this issue. Additionally, you should regularly review and update any dependencies your application relies on to ensure they are not vulnerable to known security issues.

Related vulnerabilities

Recent vulnerabilities recorded for serve-lite.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback