9 Commits
Author SHA1 Message Date
EyJunge1 0c38368c3d feat(http_parser): expose HTTP_PARSER_HAS_QUERY for compile-time detection
HTTP_QUERY is an enumerator, so #ifdef HTTP_QUERY does not work.
Add a feature macro so downstream can optionally map QUERY.
2026-10-14 16:55:28 +08:00
Mahavir Jain b300721a57 Merge branch 'contrib/github_pr_19140' into 'master'
fix(http_parser): validate every byte of header values (GitHub PR)

Closes IDFGH-18351

See merge request espressif/esp-idf!53246
2026-10-12 18:06:13 +05:30
Ashish Sharma 4e72a5c13d fix(http_parser): fixes pre-commit failures 2026-09-29 14:11:00 +08:00
Stefan SlivinskiandCopilot 157b5346ff fix(http_parser): validate every byte of header values
In strict mode http_parser rejects header-value bytes that fail
IS_HEADER_CHAR (CTLs other than HTAB, DEL, NUL), but for general header
values most bytes never reached that check:

- s_header_value_start consumed the first byte without IS_HEADER_CHAR
- after the second byte, the h_general fast path memchr()ed straight to
  CR/LF, skipping every byte in between

So "a\x15b" was rejected with HPE_INVALID_HEADER_TOKEN while "\x15",
"ab\x15" and "abc\x00def" were accepted, and the result for a given
request could change with how it was split across recv() calls. RFC 9110
section 5.5 requires a recipient to reject or replace NUL, and strict
mode already means to reject the other CTLs too.

Check the first byte in s_header_value_start, and replace the memchr()
fast path with the validating loop upstream adopted in
nodejs/http-parser#469 ("revert memchr() optimization"), which fixed the
fast-path half of this there. Lenient mode is unchanged.

Add two [security] tests to esp_http_server test_apps over a shared table
of valid (HTAB, SP, obs-text) and invalid (CTL, DEL, NUL at several
positions) values: a parser-level test that splits each request at every
offset and byte by byte, and an end-to-end test that expects 200/400.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-25 14:13:22 -07:00
EyJunge1 4fb3dd1afc feat(http_parser): add HTTP QUERY method (RFC 10008)
Register QUERY in HTTP_METHOD_MAP and accept a leading 'Q' in the
request-line matcher so esp_http_server can parse safe, idempotent
queries with a body.

Document HTTP_QUERY on the server API and cover a bodied QUERY request
in the esp_http_server test app.
2026-09-23 09:33:01 +02:00
nilesh.kale edb3f9daf1 fix(esp_http_client): check http_parser errno after execute to avoid DoS loop 2026-07-13 12:10:15 +05:30
Harshit Malpani d3d15fb53f feat(http_parser): Add sbom manifest file 2023-09-25 16:09:32 +05:30
Mahavir Jain 77929ec0ac docs/en: Add entry for http_parser in copyrights page 2022-01-11 10:26:25 +05:30
Mahavir Jain d2956f208b http_parser: Split nghttp port and create new http_parser component
Note: nghttp will be moved to IDF component manager
2022-01-11 10:26:24 +05:30