XSS Vulnerability in jsoup: Inadequate Sanitization of javascript: URLs

jsoup Updated 02 Oct 2025

Summary

29/08/2022
N/A
No i
Medium
6.1

CVE-2022-36033: jsoup is a Java HTML parser, built for HTML editing, cleaning, scraping, and cross-site scripting (XSS) safety. Affects jsoup versions < c5964172763e1495786ad584c368ac3346d0ca8c. 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

jsoup is a Java HTML parser designed for HTML editing, cleaning, scraping, and ensuring cross-site scripting (XSS) safety. It allows developers to manipulate and extract data from HTML documents easily. However, jsoup has a vulnerability that can lead to XSS attacks due to improper sanitization of certain URL expressions, particularly those starting with 'javascript:'. This issue arises when the non-default option 'SafeList.preserveRelativeLinks' is enabled, allowing potentially harmful URLs to be processed without adequate filtering.

Vulnerability Detail

The vulnerability (CVE-2022-36033) in jsoup stems from its failure to properly sanitize HTML that includes 'javascript:' URL expressions. When this option is enabled, crafted URLs containing control characters may bypass sanitization, leading to potential XSS attacks if the content is published on a site lacking a proper Content Security Policy (CSP). This flaw can allow attackers to execute malicious scripts in the context of a user's session, compromising user data and application integrity.

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

If immediate upgrading is not feasible, users can disable the 'SafeList.preserveRelativeLinks' option in jsoup. This will prevent the rewriting of input URLs as absolute URLs. Furthermore, it is crucial to implement a robust Content Security Policy (CSP) to mitigate the risk of XSS attacks. Example of disabling the option in code:

jsoup.safelist().preserveRelativeLinks(false);

Conclusion

The jsoup vulnerability CVE-2022-36033 highlights the importance of proper sanitization of user inputs, particularly in web applications. By upgrading to the latest version and implementing security best practices, developers can protect their applications from potential XSS attacks.

See every vulnerability recorded for jsoup →

Share this vulnerability

FAQ

The CVSS score of this vulnerability is 6.1, indicating a moderate severity level.

All versions of jsoup prior to 1.15.3 are affected by this vulnerability.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.

A Content Security Policy (CSP) is a security feature that helps prevent XSS attacks by controlling which resources can be loaded and executed in a web application.

If you cannot upgrade immediately, disable the 'SafeList.preserveRelativeLinks' option and ensure a proper Content Security Policy is in place.

Related vulnerabilities

Recent vulnerabilities recorded for jsoup.

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