VYPR
Moderate severityNVD Advisory· Published Nov 8, 2019· Updated Jul 7, 2025

CVE-2019-10219

CVE-2019-10219

Description

A vulnerability was found in Hibernate-Validator. The SafeHtml validator annotation fails to properly sanitize payloads consisting of potentially malicious code in HTML comments and instructions. This vulnerability can result in an XSS attack.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
org.hibernate.validator:hibernate-validatorMaven
>= 6.1.0.Alpha1, < 6.1.0.Alpha66.1.0.Alpha6
org.hibernate.validator:hibernate-validatorMaven
>= 6.0.0.Alpha1, < 6.0.18.Final6.0.18.Final
org.hibernate:hibernate-validatorMaven
>= 6.1.0.Alpha1, < 6.1.0.Alpha66.1.0.Alpha6
org.hibernate:hibernate-validatorMaven
>= 6.0.0.Alpha1, < 6.0.18.Final6.0.18.Final

Affected products

1

Patches

3
124b7dd6d9a4

HV-1739 Fix CVE-2019-10219 Security issue with @SafeHtml

https://github.com/hibernate/hibernate-validatorDavide D'AltoOct 18, 2019via ghsa
2 files changed · +43 5
  • engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/SafeHtmlValidator.java+5 5 modified
    @@ -6,15 +6,15 @@
      */
     package org.hibernate.validator.internal.constraintvalidators.hv;
     
    -import java.util.Iterator;
    +import java.util.List;
     
     import javax.validation.ConstraintValidator;
     import javax.validation.ConstraintValidatorContext;
     
     import org.hibernate.validator.constraints.SafeHtml;
     import org.jsoup.Jsoup;
     import org.jsoup.nodes.Document;
    -import org.jsoup.nodes.Element;
    +import org.jsoup.nodes.Node;
     import org.jsoup.parser.Parser;
     import org.jsoup.safety.Cleaner;
     import org.jsoup.safety.Whitelist;
    @@ -91,9 +91,9 @@ private Document getFragmentAsDocument(CharSequence value) {
     		Document document = Document.createShell( baseURI );
     
     		// add the fragment's nodes to the body of resulting document
    -		Iterator<Element> nodes = fragment.children().iterator();
    -		while ( nodes.hasNext() ) {
    -			document.body().appendChild( nodes.next() );
    +		List<Node> childNodes = fragment.childNodes();
    +		for ( Node node : childNodes ) {
    +			document.body().appendChild( node.clone() );
     		}
     
     		return document;
    
  • engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/SafeHtmlValidatorTest.java+38 0 modified
    @@ -57,6 +57,44 @@ public void testInvalidScriptTagIncluded() throws Exception {
     		assertFalse( getSafeHtmlValidator().isValid( "Hello<script>alert('Doh')</script>World !", null ) );
     	}
     
    +	@Test
    +	// A "downlevel revealed" conditional 'comment' is not an (X)HTML comment at all,
    +	// despite the misleading name, it is default Microsoft syntax.
    +	// The tag is unrecognized by therefore executed
    +	public void testDownlevelRevealedConditionalComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<![if !IE]>\n<SCRIPT>alert{'XSS'};</SCRIPT>\n<![endif]>", null ) );
    +	}
    +
    +	@Test
    +	public void testDownlevelHiddenConditionalComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<!--[if gte IE 4]>\n<SCRIPT>alert{'XSS'};</SCRIPT>\n<![endif]-->", null ) );
    +	}
    +
    +	@Test
    +	public void testSimpleComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<!-- Just a comment -->", null ) );
    +	}
    +
    +	@Test
    +	public void testServerSideIncludesSSI() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<? echo{'<SCR}'; echo{'IPT>alert{\"XSS\"}</SCRIPT>'}; ?>", null ) );
    +	}
    +
    +	@Test
    +	public void testPHPScript() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<? echo{'<SCR}'; echo{'IPT>alert{\"XSS\"}</SCRIPT>'}; ?>", null ) );
    +	}
    +
     	@Test
     	public void testInvalidIncompleteImgTagWithScriptIncluded() {
     		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    
20d729548511

HV-1739 Fix CVE-2019-10219 Security issue with @SafeHtml

https://github.com/hibernate/hibernate-validatorDavide D'AltoOct 18, 2019via ghsa
2 files changed · +43 5
  • engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/SafeHtmlValidator.java+5 5 modified
    @@ -6,15 +6,15 @@
      */
     package org.hibernate.validator.internal.constraintvalidators.hv;
     
    -import java.util.Iterator;
    +import java.util.List;
     
     import javax.validation.ConstraintValidator;
     import javax.validation.ConstraintValidatorContext;
     
     import org.hibernate.validator.constraints.SafeHtml;
     import org.jsoup.Jsoup;
     import org.jsoup.nodes.Document;
    -import org.jsoup.nodes.Element;
    +import org.jsoup.nodes.Node;
     import org.jsoup.parser.Parser;
     import org.jsoup.safety.Cleaner;
     import org.jsoup.safety.Whitelist;
    @@ -91,9 +91,9 @@ private Document getFragmentAsDocument(CharSequence value) {
     		Document document = Document.createShell( baseURI );
     
     		// add the fragment's nodes to the body of resulting document
    -		Iterator<Element> nodes = fragment.children().iterator();
    -		while ( nodes.hasNext() ) {
    -			document.body().appendChild( nodes.next() );
    +		List<Node> childNodes = fragment.childNodes();
    +		for ( Node node : childNodes ) {
    +			document.body().appendChild( node.clone() );
     		}
     
     		return document;
    
  • engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/SafeHtmlValidatorTest.java+38 0 modified
    @@ -57,6 +57,44 @@ public void testInvalidScriptTagIncluded() throws Exception {
     		assertFalse( getSafeHtmlValidator().isValid( "Hello<script>alert('Doh')</script>World !", null ) );
     	}
     
    +	@Test
    +	// A "downlevel revealed" conditional 'comment' is not an (X)HTML comment at all,
    +	// despite the misleading name, it is default Microsoft syntax.
    +	// The tag is unrecognized by therefore executed
    +	public void testDownlevelRevealedConditionalComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<![if !IE]>\n<SCRIPT>alert{'XSS'};</SCRIPT>\n<![endif]>", null ) );
    +	}
    +
    +	@Test
    +	public void testDownlevelHiddenConditionalComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<!--[if gte IE 4]>\n<SCRIPT>alert{'XSS'};</SCRIPT>\n<![endif]-->", null ) );
    +	}
    +
    +	@Test
    +	public void testSimpleComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<!-- Just a comment -->", null ) );
    +	}
    +
    +	@Test
    +	public void testServerSideIncludesSSI() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<? echo{'<SCR}'; echo{'IPT>alert{\"XSS\"}</SCRIPT>'}; ?>", null ) );
    +	}
    +
    +	@Test
    +	public void testPHPScript() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<? echo{'<SCR}'; echo{'IPT>alert{\"XSS\"}</SCRIPT>'}; ?>", null ) );
    +	}
    +
     	@Test
     	public void testInvalidIncompleteImgTagWithScriptIncluded() {
     		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    
124b7dd6d9a4

HV-1739 Fix CVE-2019-10219 Security issue with @SafeHtml

https://github.com/hibernate/hibernate-validatorDavide D'AltoOct 18, 2019via ghsa
2 files changed · +43 5
  • engine/src/main/java/org/hibernate/validator/internal/constraintvalidators/hv/SafeHtmlValidator.java+5 5 modified
    @@ -6,15 +6,15 @@
      */
     package org.hibernate.validator.internal.constraintvalidators.hv;
     
    -import java.util.Iterator;
    +import java.util.List;
     
     import javax.validation.ConstraintValidator;
     import javax.validation.ConstraintValidatorContext;
     
     import org.hibernate.validator.constraints.SafeHtml;
     import org.jsoup.Jsoup;
     import org.jsoup.nodes.Document;
    -import org.jsoup.nodes.Element;
    +import org.jsoup.nodes.Node;
     import org.jsoup.parser.Parser;
     import org.jsoup.safety.Cleaner;
     import org.jsoup.safety.Whitelist;
    @@ -91,9 +91,9 @@ private Document getFragmentAsDocument(CharSequence value) {
     		Document document = Document.createShell( baseURI );
     
     		// add the fragment's nodes to the body of resulting document
    -		Iterator<Element> nodes = fragment.children().iterator();
    -		while ( nodes.hasNext() ) {
    -			document.body().appendChild( nodes.next() );
    +		List<Node> childNodes = fragment.childNodes();
    +		for ( Node node : childNodes ) {
    +			document.body().appendChild( node.clone() );
     		}
     
     		return document;
    
  • engine/src/test/java/org/hibernate/validator/test/internal/constraintvalidators/hv/SafeHtmlValidatorTest.java+38 0 modified
    @@ -57,6 +57,44 @@ public void testInvalidScriptTagIncluded() throws Exception {
     		assertFalse( getSafeHtmlValidator().isValid( "Hello<script>alert('Doh')</script>World !", null ) );
     	}
     
    +	@Test
    +	// A "downlevel revealed" conditional 'comment' is not an (X)HTML comment at all,
    +	// despite the misleading name, it is default Microsoft syntax.
    +	// The tag is unrecognized by therefore executed
    +	public void testDownlevelRevealedConditionalComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<![if !IE]>\n<SCRIPT>alert{'XSS'};</SCRIPT>\n<![endif]>", null ) );
    +	}
    +
    +	@Test
    +	public void testDownlevelHiddenConditionalComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<!--[if gte IE 4]>\n<SCRIPT>alert{'XSS'};</SCRIPT>\n<![endif]-->", null ) );
    +	}
    +
    +	@Test
    +	public void testSimpleComment() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<!-- Just a comment -->", null ) );
    +	}
    +
    +	@Test
    +	public void testServerSideIncludesSSI() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<? echo{'<SCR}'; echo{'IPT>alert{\"XSS\"}</SCRIPT>'}; ?>", null ) );
    +	}
    +
    +	@Test
    +	public void testPHPScript() throws Exception {
    +		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    +
    +		assertFalse( getSafeHtmlValidator().isValid( "<? echo{'<SCR}'; echo{'IPT>alert{\"XSS\"}</SCRIPT>'}; ?>", null ) );
    +	}
    +
     	@Test
     	public void testInvalidIncompleteImgTagWithScriptIncluded() {
     		descriptorBuilder.setAttribute( "whitelistType", WhiteListType.BASIC );
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

28

News mentions

0

No linked articles in our index yet.