Skip to content

sec(l7): reject duplicate Content-Length headers to prevent request smuggling (CWE-444)#660

Closed
latenighthackathon wants to merge 1 commit intoNVIDIA:mainfrom
latenighthackathon:sec/l7-reject-duplicate-content-length
Closed

sec(l7): reject duplicate Content-Length headers to prevent request smuggling (CWE-444)#660
latenighthackathon wants to merge 1 commit intoNVIDIA:mainfrom
latenighthackathon:sec/l7-reject-duplicate-content-length

Conversation

@latenighthackathon
Copy link
Copy Markdown
Contributor

Summary

  • Both parse_body_length() in rest.rs and try_parse_http_request() in inference.rs silently accepted multiple Content-Length headers, overwriting with the last value
  • Per RFC 7230 Section 3.3.3, differing Content-Length values must be rejected to prevent HTTP request smuggling (CWE-444)
  • rest.rs: Detect duplicate CL headers with differing values and return Err before forwarding
  • inference.rs: Add ParseResult::Invalid variant; detect duplicate CL headers and return Invalid
  • proxy.rs: Handle ParseResult::Invalid by sending HTTP 400 and denying the connection

Test plan

  • Send a request with a single Content-Length header — verify it passes through normally
  • Send a request with two identical Content-Length headers (e.g., Content-Length: 10 twice) — verify it is accepted (idempotent duplicate is OK per RFC)
  • Send a request with two differing Content-Length headers (e.g., Content-Length: 0 and Content-Length: 50) — verify it is rejected with HTTP 400
  • Existing CL+TE rejection test still passes
  • Run cargo test for the crate

Closes #637

…muggling

Both parse_body_length() in rest.rs and try_parse_http_request() in
inference.rs silently accepted multiple Content-Length headers,
overwriting with the last value seen. Per RFC 7230 Section 3.3.3,
a message with multiple Content-Length headers with differing values
must be rejected to prevent HTTP request smuggling (CWE-444).

An attacker could send conflicting Content-Length values causing the
proxy and downstream server to disagree on message boundaries.

Fix:
- rest.rs: detect duplicate CL headers with differing values and
  return an error before forwarding
- inference.rs: add ParseResult::Invalid variant; detect duplicate
  CL headers and return Invalid with a descriptive reason
- proxy.rs: handle ParseResult::Invalid by sending HTTP 400 and
  denying the connection

Closes NVIDIA#637
@latenighthackathon latenighthackathon requested a review from a team as a code owner March 29, 2026 19:58
@github-actions
Copy link
Copy Markdown

Thank you for your interest in contributing to OpenShell, @latenighthackathon.

This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer.

To get vouched:

  1. Open a Vouch Request discussion.
  2. Describe what you want to change and why.
  3. Write in your own words — do not have an AI generate the request.
  4. A maintainer will comment /vouch if approved.
  5. Once vouched, open a new PR (preferred) or reopen this one after a few minutes.

See CONTRIBUTING.md for details.

@github-actions github-actions bot closed this Mar 29, 2026
@github-actions
Copy link
Copy Markdown

Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text:


I have read the DCO document and I hereby sign the DCO.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot.

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.

sec(sandbox): L7 proxy accepts multiple Content-Length headers — enables HTTP request smuggling (CWE-444)

1 participant