Skip to content

Commit

Permalink
- increase limit to 1024 to account for large ZMI forms
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Feb 18, 2025
1 parent 456bb6e commit 4f01f26
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ https://github.com/zopefoundation/Zope/blob/4.x/CHANGES.rst
-------------------

- Add configuration switch for the maximum allowed number of form fields.
``multipart`` version 1.2.1 introduced a default value of 128.
``multipart`` version 1.2.1 introduced a default value of 128, Zope now
sets it to 1024.

- Update to newest compatible versions of dependencies.

Expand Down
2 changes: 1 addition & 1 deletion src/ZPublisher/HTTPRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

# DOS attack protection -- limiting the amount of memory for forms
# probably should become configurable
FORM_PART_LIMIT = 2 ** 7 # limit for individual form parts
FORM_PART_LIMIT = 2 ** 10 # limit for individual form parts
FORM_MEMORY_LIMIT = 2 ** 20 # memory limit for forms
FORM_DISK_LIMIT = 2 ** 30 # disk limit for forms
FORM_MEMFILE_LIMIT = 2 ** 12 # limit for `BytesIO` -> temporary file switch
Expand Down
7 changes: 5 additions & 2 deletions src/Zope2/Startup/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,15 @@ def test_dos_protection(self):
form-memory-limit 1KB
form-disk-limit 1KB
form-memfile-limit 1KB
form-part-limit 1024
form-part-limit 2048
</dos_protection>
""")
handleWSGIConfig(None, handler)
for name in params:
self.assertEqual(getattr(HTTPRequest, name), 1024)
if name == 'FORM_PART_LIMIT':
self.assertEqual(getattr(HTTPRequest, name), 2048)
else:
self.assertEqual(getattr(HTTPRequest, name), 1024)
finally:
for name in params:
setattr(HTTPRequest, name, defaults[name])
2 changes: 1 addition & 1 deletion src/Zope2/Startup/wsgischema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</description>
</key>

<key name="form-part-limit" datatype="integer" default="128">
<key name="form-part-limit" datatype="integer" default="1024">
<description>
Limits the maximum number of parameters or form fields. Larger
forms are blocked by the underlying field parser.
Expand Down
2 changes: 1 addition & 1 deletion src/Zope2/utilities/skel/etc/zope.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,6 @@ instancehome $INSTANCE
# The maximum number of form parameters / fields in a request.
# Larger forms are blocked by the underlying field parser.
# Example:
# form-part-limit 128
# form-part-limit 1024

</dos_protection>

0 comments on commit 4f01f26

Please sign in to comment.