Skip to content

Handle malformed RFC 2231 continuations in parse_options_header#270

Open
manunio wants to merge 4 commits intoKludex:mainfrom
manunio:fix-bugs-found-by-fuzz
Open

Handle malformed RFC 2231 continuations in parse_options_header#270
manunio wants to merge 4 commits intoKludex:mainfrom
manunio:fix-bugs-found-by-fuzz

Conversation

@manunio
Copy link
Copy Markdown
Contributor

@manunio manunio commented Apr 25, 2026

Summary

  • handle both ValueError (oversized RFC 2231 index) and TypeError (mixed continuation forms) from Message.get_params()
  • add regression tests covering oversized index and mixed RFC 2231 continuation inputs to prevent fuzz-found crashes

Why

parse_options_header relied on stdlib email parsing that can raise different exception types for malformed parameter continuations. These changes keep existing behavior while making parser failure handling robust and preventing constant fuzzer crashes(improves its performance)

Validation

  • uv run pytest -q
  • uv run ruff check python_multipart/exceptions.py python_multipart/multipart.py tests/test_multipart.py

@manunio manunio changed the title Fix bugs found by fuzz Fix parse_options_header to handle ValueError and TypeError Apr 25, 2026
@Kludex Kludex changed the title Fix parse_options_header to handle ValueError and TypeError Handle malformed RFC 2231 continuations in parse_options_header Apr 25, 2026
@Kludex Kludex changed the title Handle malformed RFC 2231 continuations in parse_options_header Handle malformed RFC 2231 continuations in parse_options_header Apr 25, 2026
@Kludex
Copy link
Copy Markdown
Owner

Kludex commented Apr 25, 2026

Thanks @manunio 🙏

@manunio
Copy link
Copy Markdown
Contributor Author

manunio commented Apr 25, 2026

I’m returning the header as is to avoid regex magic for parser differences between python versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants