This is a denial-of-service (CWE-400/CWE-407) vulnerability in Django REST framework's content negotiation. The root cause is that DRF parses each Accept header token multiple times per request (roughly six times with the default two renderers, including the forced 406 re-negotiation) and never limits the number of tokens or their total size. Each parse delegates to Django's parse_header_parameters, which exhibits quadratic time complexity when a quoted parameter value is packed with semicolons.
The vulnerable code path is:
- get_accept_list() splits the Accept header on commas with no cap on token count or total size.
- select_renderer() loops over each token and calls media_type_matches() once per renderer.
- media_type_matches() builds fresh _MediaType objects for both sides on every call.
- _MediaType.init unconditionally calls parse_header_parameters, the quadratic hot spot.
- order_by_precedence() re-parses each token again to compute precedence.
- When nothing matches, finalize_response() re-runs the entire negotiation via perform_content_negotiation(force=True), doubling the cost.
The fix (commit 148ab6523922d5a0c110f76615935e5220b63029) addresses this by: adding max_accept_header_length (8192), max_accept_tokens (64), and max_media_type_length (256) limits in get_accept_list(); parsing each Accept token once per request via _get_parsed_accept_list() and caching on the request; pre-parsing renderer media types once; and replacing order_by_precedence with order_parsed_by_precedence that operates on already-parsed objects. The _MediaType constructor also now degrades gracefully on ValueError instead of surfacing a 500.
The functions identified are those that existed in the vulnerable version and were modified by the patch to add the missing limits and eliminate redundant re-parsing. They are the functions that would appear in a runtime profile during exploitation.