Skip to content

Limit Request Size? #4760

@cristianocoelho

Description

@cristianocoelho

Django uses the settings DATA_UPLOAD_MAX_NUMBER_FIELDS and DATA_UPLOAD_MAX_MEMORY_SIZE to help against denial of service of large suspicious requests.

Django-Rest-Framework's parsers do not honor DATA_UPLOAD_MAX_MEMORY_SIZE setting in any way since it never uses request.body directly but instead request.read(). DATA_UPLOAD_MAX_NUMBER_FIELDS is probably not honored as well but this one is not that important.

Since the setting is not honored, a valid huge json request can cause an unhandled MemoryError on the parsers which is quite ugly.

I'm wondering if there's an easy way to honor this flag, or should we manually write/override the existing parsers to check this flag?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions