CVE-2019-10219: XSS Vulnerability in Hibernate-Validator
Summary
CVE-2019-10219: The SafeHtml annotation in Hibernate-Validator does not properly guard against XSS attacks. Affects org.hibernate.validator:hibernate-validator across 2 version ranges.
>= 6.0.0.Alpha1, < 6.0.18.Final
>= 6.1.0.Alpha1, < 6.1.0.Alpha6
Fixed in 6.0.18.Final or 6.1.0.Alpha6, depending on the release line you run. How to fix ↓
Also tracked for
- libhibernate-validator-java · Debian:11
The same CVE-2019-10219 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
Hibernate-Validator is a popular Java Bean Validation framework that provides a set of annotations to validate objects. It is commonly used in Java applications to ensure data integrity and security. The SafeHtml annotation in Hibernate-Validator is designed to sanitize user input and prevent cross-site scripting (XSS) attacks. However, a vulnerability has been discovered in the SafeHtml validator annotation that allows potentially malicious code to bypass the sanitization process and execute XSS attacks.
Vulnerability Detail
The SafeHtml validator annotation in Hibernate-Validator fails to properly sanitize payloads containing potentially malicious code in HTML comments and instructions. This vulnerability can be exploited by an attacker to inject and execute arbitrary JavaScript code in the context of a user's browser. The impact of an XSS attack can range from stealing sensitive user information to performing unauthorized actions on behalf of the user.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 6.0.0.Alpha1, < 6.0.18.Final6.0.18.Final -
>= 6.1.0.Alpha1, < 6.1.0.Alpha66.1.0.Alpha6
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If upgrading to the latest version of Hibernate-Validator is not immediately feasible, a temporary workaround is to manually sanitize user input before passing it to the SafeHtml validator annotation. This can be done by using a library or custom code that properly sanitizes HTML content and removes any potentially malicious code. Here is an example of how to sanitize user input using the OWASP Java HTML Sanitizer library:
import org.owasp.html.Sanitizers;
String userInput = "<script>alert('XSS')</script>";
String sanitizedInput = Sanitizers.BLOCKS.toFactory().sanitize(userInput);
Conclusion
The XSS vulnerability in Hibernate-Validator's SafeHtml validator annotation can be mitigated by upgrading to version 6.0.18 or later. Developers should ensure that their projects are using the latest version of Hibernate-Validator to prevent potential XSS attacks. If immediate upgrade is not possible, manually sanitizing user input using a library like the OWASP Java HTML Sanitizer can serve as a temporary workaround. For further support and assistance in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for org.hibernate.validator:hibernate-validator →
FAQ
Hibernate-Validator is a Java Bean Validation framework that provides a set of annotations to validate objects and ensure data integrity in Java applications.
Cross-Site Scripting (XSS) is a type of security vulnerability that allows attackers to inject and execute malicious scripts in web pages viewed by other users.
The SafeHtml validator annotation in Hibernate-Validator is designed to sanitize user input and prevent XSS attacks by removing or encoding potentially malicious HTML code.
An XSS attack can lead to the theft of sensitive user information, unauthorized actions performed on behalf of the user, or the spreading of malware to other users.
To protect your application, it is recommended to upgrade to the latest version of Hibernate-Validator or apply the provided workaround to manually sanitize user input.
References
Related vulnerabilities
Recent vulnerabilities recorded for org.hibernate.validator:hibernate-validator.