You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2026/09/10 17:05:56 UTC

(allura) branch master updated (981bd98f4 -> 98bc2afb3)

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git


    from 981bd98f4 [#8617] Update User's set_tool_data to store encrypted tool data values
     new b71f771a1 [#8621] test for FTP redirect bypassing internal-host protection
     new 203736649 [#8619] test for iframe followed by script
     new 623230735 [#8619] test for SVG blocked, MathML allowed
     new bea428ded [#8619] test for iframe body mXSS via math/svg reparse
     new 3aed169fb [#8619] test for class/id sanitization on void elements
     new 98bc2afb3 [#8619] test for text_contains_hostname substring bypass

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Allura/allura/tests/test_globals.py | 56 +++++++++++++++++++++++++++++++++++++
 Allura/allura/tests/test_helpers.py | 14 ++++++++++
 Allura/allura/tests/test_utils.py   |  2 ++
 3 files changed, 72 insertions(+)


(allura) 03/06: [#8619] test for SVG blocked, MathML allowed

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 623230735c8934ff3130c4162d5fff464111c99b
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 16:31:03 2026 -0400

    [#8619] test for SVG blocked, MathML allowed
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
    Claude-Session: https://claude.ai/code/session_018KZ3wfWGSAzjfQj3neMfG3
---
 Allura/allura/tests/test_globals.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 6445270d7..668880c5b 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -395,6 +395,26 @@ def test_iframe_no_src_with_scripts(self):
             '</div>'
         )
 
+    def test_svg_blocked(self):
+        # SVG's <animate>/<set> can set an ancestor's href to an unchecked javascript: URI
+        r = g.markdown.convert('<svg><circle cx="5" cy="5" r="3"/></svg>')
+        assert r == '<div class="markdown_content"><p>&lt;svg&gt;&lt;circle cx="5" cy="5" r="3"&gt;&lt;/circle&gt;&lt;/svg&gt;</p></div>'
+
+        r = g.markdown.convert(
+            '<svg><a><animate attributeName="href" values="javascript:alert(1)"/>'
+            '<text x="20" y="20">CLICK ME</text></a></svg>')
+        assert r == ('<div class="markdown_content"><p>&lt;svg&gt;&lt;a&gt;'
+                      '&lt;animate attributeName="href" values="javascript:alert(1)"&gt;&lt;/animate&gt;'
+                      '&lt;text x="20" y="20"&gt;CLICK ME&lt;/text&gt;&lt;/a&gt;&lt;/svg&gt;</p></div>')
+
+    def test_mathml_allowed(self):
+        r = g.markdown.convert('<math><mi>x</mi><mo>+</mo><mn>1</mn></math>')
+        assert r == '<div class="markdown_content"><math><mi>x</mi><mo>+</mo><mn>1</mn></math>\n</div>'
+
+        # xlink:href is still URI-scheme-checked, e.g. the old maction statusline XSS
+        r = g.markdown.convert('<math><maction actiontype="statusline" xlink:href="javascript:alert(1)">click</maction></math>')
+        assert r == '<div class="markdown_content"><math><maction actiontype="statusline">click</maction></math>\n</div>'
+
     def test_macro_embed_notsupported(self):
         r = g.markdown_wiki.convert('[[embed url=http://vimeo.com/46163090]]')
         assert (


(allura) 04/06: [#8619] test for iframe body mXSS via math/svg reparse

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit bea428ded93c481cb7b26cb6ccb579f63399e1a6
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 16:31:56 2026 -0400

    [#8619] test for iframe body mXSS via math/svg reparse
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
    Claude-Session: https://claude.ai/code/session_018KZ3wfWGSAzjfQj3neMfG3
---
 Allura/allura/tests/test_globals.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 668880c5b..e91929be7 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -377,12 +377,10 @@ def test_macro_embed_video_error(self, oembed_fetch):
                 'http://www.youtube.com/watch?v=6YbBmqUnoQM</p></div>')
 
     def test_iframe_src_ok_with_scripts(self):
-        # an allowed iframe's body is always dropped (never emitted, even escaped): its
-        # rawtext content is only safe to serialize unescaped if it stays HTML-namespace
-        # content on reparse, which isn't guaranteed (see test_utils.py's mXSS coverage)
+        # an allowed iframe's body is always dropped, see test_iframe_body_dropped_prevents_mxss
         r = g.markdown_wiki.convert('<iframe src="https://www.youtube.com/embed/x"><script>alert(1)</script></iframe><script>alert(2)</script>')
         assert r == (
-            '<div class="markdown_content"><iframe src="https://www.youtube.com/embed/x">&lt;script&gt;alert(1)&lt;/script&gt;</iframe>\n'
+            '<div class="markdown_content"><iframe src="https://www.youtube.com/embed/x"></iframe>\n'
             '&lt;script&gt;alert(2)&lt;/script&gt;\n'
             '</div>'
         )
@@ -395,6 +393,17 @@ def test_iframe_no_src_with_scripts(self):
             '</div>'
         )
 
+    def test_iframe_body_dropped_prevents_mxss(self):
+        # an escaped ancestor like <math><ms> can leave an allowed iframe as a direct child of
+        # <math> on reparse, where it's not rawtext, so a "text" body would run as live markup
+        r = g.markdown.convert('<math><ms><iframe src="https://www.youtube.com/embed/y"><img src=x onerror=alert(1)>')
+        assert r == ('<div class="markdown_content"><math>&lt;ms&gt;'
+                      '<iframe src="https://www.youtube.com/embed/y"></iframe>&lt;/ms&gt;</math></div>')
+
+        r = g.markdown.convert('<svg><foreignObject><iframe src="https://www.youtube.com/embed/y"><p><script>alert(1)</script>')
+        assert r == ('<div class="markdown_content"><p>&lt;svg&gt;&lt;foreignObject&gt;'
+                      '<iframe src="https://www.youtube.com/embed/y"></iframe>&lt;/foreignObject&gt;&lt;/svg&gt;</p></div>')
+
     def test_svg_blocked(self):
         # SVG's <animate>/<set> can set an ancestor's href to an unchecked javascript: URI
         r = g.markdown.convert('<svg><circle cx="5" cy="5" r="3"/></svg>')


(allura) 05/06: [#8619] test for class/id sanitization on void elements

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 3aed169fbb9cff274483eb64de380f04951684aa
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 16:32:52 2026 -0400

    [#8619] test for class/id sanitization on void elements
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
    Claude-Session: https://claude.ai/code/session_018KZ3wfWGSAzjfQj3neMfG3
---
 Allura/allura/tests/test_globals.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index e91929be7..0edaee7e4 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -404,6 +404,14 @@ def test_iframe_body_dropped_prevents_mxss(self):
         assert r == ('<div class="markdown_content"><p>&lt;svg&gt;&lt;foreignObject&gt;'
                       '<iframe src="https://www.youtube.com/embed/y"></iframe>&lt;/foreignObject&gt;&lt;/svg&gt;</p></div>')
 
+    def test_class_id_sanitized_on_void_element(self):
+        r = g.markdown.convert('<img src="http://x/y.png" class="evilclass btn" id="page-body">')
+        assert r == ('<div class="markdown_content"><p>'
+                      '<img class="" id="user-content-page-body" rel="nofollow" src="http://x/y.png"/></p></div>')
+
+        r = g.markdown.convert('<br class="pwn" id="pwn2">')
+        assert r == '<div class="markdown_content"><p><br class="" id="user-content-pwn2"/></p></div>'
+
     def test_svg_blocked(self):
         # SVG's <animate>/<set> can set an ancestor's href to an unchecked javascript: URI
         r = g.markdown.convert('<svg><circle cx="5" cy="5" r="3"/></svg>')


(allura) 01/06: [#8621] test for FTP redirect bypassing internal-host protection

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit b71f771a1ddcdc80bcd96b2000133b6d55b43f97
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 17:03:37 2026 -0400

    [#8621] test for FTP redirect bypassing internal-host protection
    
    NonPrivateUrl is only checked by our http/https handlers. A redirect
    to ftp:// reaches urllib's default FTPHandler, which has no such
    check, so it can reach internal/private hosts unvalidated.
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
---
 Allura/allura/tests/test_helpers.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 5ea729e59..fbee314fe 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -16,6 +16,7 @@
 #       under the License.
 
 import io
+import urllib.request
 from unittest import skipIf
 from os import path
 from datetime import datetime, timedelta
@@ -535,6 +536,19 @@ def test_internal_invalid(self, url):
     def test_ok(self, url):
         h.urlopen(url)
 
+    @pytest.mark.parametrize('url', [
+        f'https://{httpbin_domain}/redirect-to?url=ftp://127.0.0.1/',
+        f'https://{httpbin_domain}/redirect-to?url=ftp://localhost/',
+    ])
+    def test_internal_invalid_ftp_redirect(self, url):
+        # our opener has no ftp handler at all, so a redirect to ftp:// can't be used to bypass NonPrivateUrl
+        with pytest.raises(urllib.error.URLError, match='unknown url type'):
+            h.urlopen(url)
+
+    def test_ftp_not_supported(self):
+        with pytest.raises(urllib.error.URLError, match='unknown url type'):
+            urllib.request.urlopen('ftp://127.0.0.1/some/file')  # noqa: S310
+
     @patch('urllib.request.urlopen')
     @patch.dict(config, {'urlopen_allow_internal_hostnames': 'true'})
     def test_no_error(self, urlopen):


(allura) 02/06: [#8619] test for iframe followed by script

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 2037366491d532a3948d815775c517622f17c8c7
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 16:12:24 2026 -0400

    [#8619] test for iframe followed by script
---
 Allura/allura/tests/test_globals.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 34c242202..6445270d7 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -376,6 +376,25 @@ def test_macro_embed_video_error(self, oembed_fetch):
         assert (r == '<div class="markdown_content"><p>Could not embed: '
                 'http://www.youtube.com/watch?v=6YbBmqUnoQM</p></div>')
 
+    def test_iframe_src_ok_with_scripts(self):
+        # an allowed iframe's body is always dropped (never emitted, even escaped): its
+        # rawtext content is only safe to serialize unescaped if it stays HTML-namespace
+        # content on reparse, which isn't guaranteed (see test_utils.py's mXSS coverage)
+        r = g.markdown_wiki.convert('<iframe src="https://www.youtube.com/embed/x"><script>alert(1)</script></iframe><script>alert(2)</script>')
+        assert r == (
+            '<div class="markdown_content"><iframe src="https://www.youtube.com/embed/x">&lt;script&gt;alert(1)&lt;/script&gt;</iframe>\n'
+            '&lt;script&gt;alert(2)&lt;/script&gt;\n'
+            '</div>'
+        )
+
+    def test_iframe_no_src_with_scripts(self):
+        r = g.markdown_wiki.convert('<iframe><script>alert(1)</script></iframe><script>alert(2)</script>')
+        assert r == (
+            '<div class="markdown_content">&lt;iframe&gt;&lt;script&gt;alert(1)&lt;/script&gt;&lt;/iframe&gt;\n'
+            '&lt;script&gt;alert(2)&lt;/script&gt;\n'
+            '</div>'
+        )
+
     def test_macro_embed_notsupported(self):
         r = g.markdown_wiki.convert('[[embed url=http://vimeo.com/46163090]]')
         assert (


(allura) 06/06: [#8619] test for text_contains_hostname substring bypass

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 98bc2afb34a2b6b0996833c35506bdc2c69bbb36
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Tue Aug 25 16:43:40 2026 -0400

    [#8619] test for text_contains_hostname substring bypass
    
    Co-Authored-By: Claude Sonnet 5 <no...@anthropic.com>
    Claude-Session: https://claude.ai/code/session_018KZ3wfWGSAzjfQj3neMfG3
---
 Allura/allura/tests/test_utils.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Allura/allura/tests/test_utils.py b/Allura/allura/tests/test_utils.py
index 0d88dde95..6deb7dbe2 100644
--- a/Allura/allura/tests/test_utils.py
+++ b/Allura/allura/tests/test_utils.py
@@ -417,6 +417,8 @@ def test_text_contains_hostname():
     assert utils.text_contains_hostname('click here', 'example.com') is False
     assert utils.text_contains_hostname('visit sub.example.com for info', 'sub.example.com') is True
     assert utils.text_contains_hostname('visit example.com/path/ for info', 'example.com') is True
+    # substring match isn't good enough: 'pal.com' is a substring of 'paypal.com' but not the same host
+    assert utils.text_contains_hostname('https://paypal.com/login', 'pal.com') is False
 
 
 def test_ip_address():