Author xtreak
Recipients eric.snow, jaraco, mcepl, ned.deily, orsenthil, tburke, webknjaz, xtreak
Date 2019-09-18.08:42:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Is there a reason why cherrypy doesn't URL encode the null byte in this test as per comment : ?

The original fix was adopted from golang ( and as per the cherrypy test the golang client also should be forbidding invalid control character :

Also as per the discussion one of our own stdlib tests were depending on this behavior in the http client and had to be changed :

The change made in Issue30458 also affects urllib3 test in 3.7.4 causing CI failure and the related discussion to encode URLs : . urllib3 issue : . 

IIRC urllib3 was also patched for this vulnerability in similar manner as part of larger refactor : . I didn't verify yet, it's unreleased and how urllib3 client behaves before and after patch for the CRLF characters and similar tests that use urllib3 as client.

Applying the URL encoding patch to cherrypy I can verify that the behavior is also tested

diff --git a/cherrypy/test/ b/cherrypy/test/
index cdd821ae..85a51cf3 100644
--- a/cherrypy/test/
+++ b/cherrypy/test/
@@ -398,7 +398,8 @@ class StaticTest(helper.CPWebCase):
         self.assertInBody("I couldn't find that thing")

     def test_null_bytes(self):
-        self.getPage('/static/\x00')
+        from urllib.parse import quote
+        self.getPage(quote('/static/\x00'))
         self.assertStatus('404 Not Found')


After patch the test passes and ValueError is also raised properly as the null byte is decoded in the server and using it in os.stat to resolve null byte path.

Breakages were expected in the discussion as adopting the fix from golang. Giving an option like a parameter to bypass the validation was also discussed in the linked but giving an option would also mean it could be abused or missed.
Date User Action Args
2019-09-18 08:42:16xtreaksetrecipients: + xtreak, jaraco, orsenthil, ned.deily, mcepl, eric.snow, webknjaz, tburke
2019-09-18 08:42:16xtreaksetmessageid: <>
2019-09-18 08:42:16xtreaklinkissue36274 messages
2019-09-18 08:42:15xtreakcreate