From b0804efef084f0e7544bbf72c6126c65ef5c0d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Passaro?= Date: Thu, 12 Nov 2020 19:48:52 -0300 Subject: [PATCH 1/2] Improve onsiteURL regex to prevent phishing - It actually prevents jumping out the origin domain. - Updated on every policy. --- src/main/resources/antisamy-anythinggoes.xml | 2 +- src/main/resources/antisamy-ebay.xml | 2 +- src/main/resources/antisamy-myspace.xml | 2 +- src/main/resources/antisamy-slashdot.xml | 2 +- src/main/resources/antisamy-tinymce.xml | 2 +- src/main/resources/antisamy.xml | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/resources/antisamy-anythinggoes.xml b/src/main/resources/antisamy-anythinggoes.xml index 8a98c284..8d86bd67 100644 --- a/src/main/resources/antisamy-anythinggoes.xml +++ b/src/main/resources/antisamy-anythinggoes.xml @@ -50,7 +50,7 @@ http://www.w3.org/TR/html401/struct/global.html - + diff --git a/src/main/resources/antisamy-ebay.xml b/src/main/resources/antisamy-ebay.xml index 9f4ef15d..61033dee 100644 --- a/src/main/resources/antisamy-ebay.xml +++ b/src/main/resources/antisamy-ebay.xml @@ -48,7 +48,7 @@ http://www.w3.org/TR/html401/struct/global.html - + diff --git a/src/main/resources/antisamy-myspace.xml b/src/main/resources/antisamy-myspace.xml index e3adbab6..897f220e 100644 --- a/src/main/resources/antisamy-myspace.xml +++ b/src/main/resources/antisamy-myspace.xml @@ -50,7 +50,7 @@ http://www.w3.org/TR/html401/struct/global.html - + diff --git a/src/main/resources/antisamy-slashdot.xml b/src/main/resources/antisamy-slashdot.xml index 4e32d028..b479dd66 100644 --- a/src/main/resources/antisamy-slashdot.xml +++ b/src/main/resources/antisamy-slashdot.xml @@ -34,7 +34,7 @@ Slashdot allowed tags taken from "Reply" page: --> - + diff --git a/src/main/resources/antisamy-tinymce.xml b/src/main/resources/antisamy-tinymce.xml index d565628a..fd47c968 100644 --- a/src/main/resources/antisamy-tinymce.xml +++ b/src/main/resources/antisamy-tinymce.xml @@ -29,7 +29,7 @@ - + diff --git a/src/main/resources/antisamy.xml b/src/main/resources/antisamy.xml index 7c5a1522..448f47ee 100644 --- a/src/main/resources/antisamy.xml +++ b/src/main/resources/antisamy.xml @@ -54,19 +54,19 @@ http://www.w3.org/TR/html401/struct/global.html - + - + - + - + From ccdf3196a5a6178c228c1e3c1dd75f8ed7f843f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Passaro?= Date: Thu, 12 Nov 2020 19:49:51 -0300 Subject: [PATCH 2/2] Add test for onsiteURL and dangling markup attack --- .../validator/html/test/AntiSamyTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java b/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java index b37e6591..376bcd59 100644 --- a/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java +++ b/src/test/java/org/owasp/validator/html/test/AntiSamyTest.java @@ -1425,4 +1425,37 @@ public void testGithubIssue40() throws ScanException, PolicyException { assertThat(as.scan(test40, policy, AntiSamy.DOM).getCleanHTML(), not(containsString("" + + "You must click me"; + + // Output: You must click me + + assertThat(as.scan(phishingAttempt, policy, AntiSamy.SAX).getCleanHTML(), not(containsString("//evilactor.com/"))); + assertThat(as.scan(phishingAttempt, policy, AntiSamy.DOM).getCleanHTML(), not(containsString("//evilactor.com/"))); + + // This ones never failed, they're just to prove a dangling markup attack on the following resulting HTML won't work. + // Less probable case (steal more tags): + final String danglingMarkup = "