Skip to content

Commit cd53adb

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 2.4.0.0
2 parents b72763f + 55649a3 commit cd53adb

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/main/java/org/owasp/esapi/reference/validation/HTMLValidationRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private String invokeAntiSamy( String context, String input ) throws ValidationE
240240

241241
try {
242242
AntiSamy as = new AntiSamy();
243-
CleanResults test = as.scan(canonical, antiSamyPolicy);
243+
CleanResults test = as.scan(canonical, antiSamyPolicy); // Uses AntiSamy.DOM scanner.
244244

245245
List<String> errors = test.getErrorMessages();
246246
if ( !errors.isEmpty() ) {

src/test/java/org/owasp/esapi/reference/validation/HTMLValidationRuleCleanTest.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ public void testGetValidSafeHTML() throws Exception {
134134
//
135135
// This TBD CVE should arguably get the same CVSSv3 store as the AntiSamy
136136
// CVE-2021-35043 as the are very similar.
137+
//
138+
// Updated: Requested CVE from GitHub CNA on 4/23/2022. See
139+
// https://github.com/ESAPI/esapi-java-legacy/security/advisories/GHSA-q77q-vx4q-xx6q
140+
// (Which may not be published yet, but is remediated. Waiting on CVE ID to publish.)
137141
@Test
138142
public void testJavaScriptURL() throws Exception {
139143
System.out.println("testJavaScriptURL");
@@ -225,30 +229,31 @@ public void testOnfocusAfterStyleClosing() throws Exception {
225229
ValidationErrorList errors = new ValidationErrorList();
226230
String input = "<select<style/>k<input<</>input/onfocus=alert(1)>";
227231
assertTrue(instance.isValidSafeHTML("test10", input, 100, false, errors));
228-
String expected = "k&lt;input/onfocus=alert(1)&gt;"; // Suspicious??? Doesn't agree w/ AntiSamy test. FIXME?
232+
String expected = "k&lt;input/onfocus=alert(1)&gt;"; // Suspicious? Doesn't agree w/ AntiSamy test.
229233
String output = instance.getValidSafeHTML("escaping style tag attack with onfocus attribute", input, 250, false);
230234
assertEquals(expected, output);
231235
assertTrue(errors.size() == 0);
232236
}
233237

234-
// FIXME: This problem is a DoS issue that lies within Neko that is only available for Java 8 and later.
235-
// However, the latest version that is available for Java 7 is Neko 2.24. It is fixed in later versions
236-
// that are not available for JDK 7 though. The fix will just start using the one the latest Java 8 version
237-
// of AntiSamy is using and remove our <exclusion> and specific 2.24 dependency from our pom.xml and use whatever
238-
// AntiSamy provides. All we should need to do is that and remove the @Ignore annotation here.
238+
// This test was a DoS issue (CVE-2022-28366) within a transitive dependency (Neko-HtmlUnit) that AntiSamy uses.
239+
// It is fixed only in Neko-HtmlUnit 2.27 and later, but all those releases are only available for Java 8 and later.
240+
//
241+
// When the input here is called with AntiSamy.scan().getCleanHtml(), AntiSamy throws a ScanException.
242+
// (For details, see the AntiSamy JUnit test case "testMalformedPIScan" in
243+
// https://github.com/nahsra/antisamy/blob/main/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java.)
244+
//
239245
@Test
240-
@Ignore
241246
public void testNekoDOSWithAnHTMLComment() throws Exception {
242-
/**
243-
* FIXME: This unit test needs to pass before the next ESAPI release once ESAPI starts using JDK 8 as min JDK.
244-
*/
247+
System.out.println("testNekoDOSWithAnHTMLComment");
248+
245249
Validator instance = ESAPI.validator();
246250
ValidationErrorList errors = new ValidationErrorList();
247251
String input = "<!--><?a/";
248-
assertTrue(instance.isValidSafeHTML("test11", input, 100, false, errors));
249-
String expected = "&#x3C;!--&#x3E;&#x3C;?a/";
252+
assertTrue(instance.isValidSafeHTML("test11", input, 100, false, errors)); // Safe bc "" gets returned!!!
253+
254+
String expectEmpty = "";
250255
String output = instance.getValidSafeHTML("escaping style tag attack", input, 250, false);
251-
assertEquals(expected, output);
256+
assertEquals(expectEmpty, output); // Because AntiSamy's CleanResults.getCleanHTML() should throw and is caught.
252257
assertTrue(errors.size() == 0);
253258
}
254259
}

0 commit comments

Comments
 (0)