File tree Expand file tree Collapse file tree 3 files changed +28
–0
lines changed
Expand file tree Collapse file tree 3 files changed +28
–0
lines changed Original file line number Diff line number Diff line change @@ -240,6 +240,8 @@ def parse(self):
240240 remaining = len (stripped_chunk ) % 4
241241 while remaining != 0 :
242242 over_chunk = field_stream .read (4 - remaining )
243+ if not over_chunk :
244+ break
243245 stripped_chunk += b"" .join (over_chunk .split ())
244246 remaining = len (stripped_chunk ) % 4
245247
Original file line number Diff line number Diff line change @@ -15,3 +15,9 @@ posing an XSS attack vector.
1515In order to avoid this vulnerability, ``{% debug %}`` no longer outputs an
1616information when the ``DEBUG`` setting is ``False``, and it ensures all context
1717variables are correctly escaped when the ``DEBUG`` setting is ``True``.
18+
19+ CVE-2022-23833: Denial-of-service possibility in file uploads
20+ =============================================================
21+
22+ Passing certain inputs to multipart forms could result in an infinite loop when
23+ parsing files.
Original file line number Diff line number Diff line change @@ -142,6 +142,26 @@ def test_big_base64_upload(self):
142142 def test_big_base64_newlines_upload (self ):
143143 self ._test_base64_upload ("Big data" * 68000 , encode = base64 .encodebytes )
144144
145+ def test_base64_invalid_upload (self ):
146+ payload = client .FakePayload ('\r \n ' .join ([
147+ '--' + client .BOUNDARY ,
148+ 'Content-Disposition: form-data; name="file"; filename="test.txt"' ,
149+ 'Content-Type: application/octet-stream' ,
150+ 'Content-Transfer-Encoding: base64' ,
151+ ''
152+ ]))
153+ payload .write (b'\r \n !\r \n ' )
154+ payload .write ('--' + client .BOUNDARY + '--\r \n ' )
155+ r = {
156+ 'CONTENT_LENGTH' : len (payload ),
157+ 'CONTENT_TYPE' : client .MULTIPART_CONTENT ,
158+ 'PATH_INFO' : '/echo_content/' ,
159+ 'REQUEST_METHOD' : 'POST' ,
160+ 'wsgi.input' : payload ,
161+ }
162+ response = self .client .request (** r )
163+ self .assertEqual (response .json ()['file' ], '' )
164+
145165 def test_unicode_file_name (self ):
146166 with sys_tempfile .TemporaryDirectory () as temp_dir :
147167 # This file contains Chinese symbols and an accented char in the name.
You can’t perform that action at this time.
0 commit comments