From 354d69a7b397571e3845de13ecabbfeb9d7f100b Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 21 Aug 2023 14:43:12 -0400 Subject: fix: reject NUL character as path element See: https://github.com/Pylons/pyramid/security/advisories/GHSA-j8g2-6fc7-q8f8 --- tests/fixtures/index.html | 1 + tests/test_static.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/fixtures/index.html (limited to 'tests') diff --git a/tests/fixtures/index.html b/tests/fixtures/index.html new file mode 100644 index 000000000..a37df5790 --- /dev/null +++ b/tests/fixtures/index.html @@ -0,0 +1 @@ +

DON'T GO HERE

diff --git a/tests/test_static.py b/tests/test_static.py index af487fa24..97978f2a4 100644 --- a/tests/test_static.py +++ b/tests/test_static.py @@ -104,6 +104,19 @@ class Test_static_view_use_subpath_False(unittest.TestCase): self.assertRaises(HTTPNotFound, inst, context, request) + def test_oob_nul_char(self): + import os + + inst = self._makeOne(f'{os.getcwd()}/tests/fixtures/static') + dds = '..\x00/' + request = self._makeRequest( + {'PATH_INFO': f'/{dds}'} + ) + context = DummyContext() + from pyramid.httpexceptions import HTTPNotFound + + self.assertRaises(HTTPNotFound, inst, context, request) + def test_resource_doesnt_exist(self): inst = self._makeOne('tests:fixtures/static') request = self._makeRequest({'PATH_INFO': '/notthere'}) -- cgit v1.2.3