Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[io]: HTTP header parser incorrectly accepts NUL within header values #56636

Closed
kenballus opened this issue Sep 2, 2024 · 3 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@kenballus
Copy link

From RFC 9110:

Field values containing CR, LF, or NUL characters are invalid and dangerous, due to the varying ways that implementations might parse and interpret those characters; a recipient of CR, LF, or NUL within a field value MUST either reject the message or replace each of those characters with SP before further processing or forwarding of that message.

dart:io does not enforce this rule for NUL. You can see this by running a simple example that echoes back header values (such as this), and sending it a request containing NUL within a header value:

printf 'GET / HTTP/1.1\r\nHost: whatever\r\nTest: \x00\r\n\r\n' \
  | timeout 1 ncat --no-shutdown localhost 80 \
  | grep '"headers"' \
  | jq '.["headers"][0][1]' \
  | xargs echo \
  | base64 -d \
  | xxd
00000000: 00                                       .
$ dart info
...
- Dart 3.6.0-edge.3cc6105316be32e2d48b1b9b253247ad4fc89698 (main) (Fri Aug 30 22:53:32 2024 +0000) on "linux_x64"
- on linux / Linux 6.10.2-arch1-2 #1 SMP PREEMPT_DYNAMIC Sat, 03 Aug 2024 17:56:17 +0000
- locale is en_US
@dart-github-bot
Copy link
Collaborator

Summary: The dart:io HTTP header parser incorrectly accepts NUL characters within header values, violating RFC 9110 which mandates rejection or replacement of such characters. This vulnerability could lead to unexpected behavior or security risks.

@dart-github-bot dart-github-bot added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Sep 2, 2024
@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Sep 2, 2024
@lrhn
Copy link
Member

lrhn commented Sep 2, 2024

Tentatively marking as dart:io-related. Maybe it's in dart:_http.

@a-siva a-siva added the triaged Issue has been triaged by sub team label Sep 4, 2024
@brianquinlan
Copy link
Contributor

I did some research here into different client (I realize that this is a server issue but dart:io should be consistent with its client and server header handling):

Client NUL CR/LF
Chrome Reject Treat as end-of-header
dart:io Preserve Reject
cronet Reject Treat as end-of-header
Apple NSURLSession Preserve Treat as end-of-header

So probably the right thing to do here is reject the request like Chrome and Cronet do.

copybara-service bot pushed a commit that referenced this issue Jan 2, 2025
Bug:#56636
Change-Id: I88c579cfaaf0884cb3b582084b8739b060d8f439
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402541
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-io triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants