HTTP/2 error when parsing percent-encoded query string
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- scala
- Lĩnh vực
- backend, backend-api-design, networking
Hướng nghiên cứu
Bắt đầu với http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/UriParser.scala và luồng HTTP/2 trong http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/HeaderDecompression.scala, bao gồm parseAndEmit. Tái hiện query không hợp lệ %_D bằng curl qua HTTP/1.1 và HTTP/2, sau đó theo dõi cách ParsingException được xử lý. Công việc được xem là hoàn tất khi HTTP/2 trả về 400 Bad Request cùng với phần thân lỗi được ghi lại trong tài liệu thay vì đóng kết nối với HTTP/2 framing error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Very simple reproducer with explanation: https://github.com/mkurz/akka-http-percent-encoding-bug (that reproducer is still based on akka-http but should work 1:1 when applied to pekko-http)
Copy and pasted README (in case I ever delete that repo):
pekko-http's (experimental?) http2 support does not correctly handle URL parsing errors.
Specially when passing an invalid percent-encoded character in the path and/or query string (here %_D):
As reproducer the example from the akka docs can be used, but with HTTP/2 enabled:
- https://doc.akka.io/docs/akka-http/current/introduction.html#low-level-http-server-apis
- https://doc.akka.io/docs/akka-http/current/server-side/http2.html#enable-http-2-support
# Start the server
sbt run
# HTTP/1 works:
$ curl --http1.1 -v http://localhost:8080/?param=%_D
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /?param=%_D HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.87.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 400 Bad Request
< Server: akka-http/10.2.10
< Date: Wed, 15 Feb 2023 16:29:18 GMT
< Connection: close
< Content-Type: text/plain; charset=UTF-8
< Content-Length: 78
<
* Closing connection 0
Illegal request-target: Invalid input '_', expected HEXDIG (line 1, column 10)
# HTTP/2 gives error:
$ curl --http2-prior-knowledge -v http://localhost:8080/?param=%_D
* Trying 127.0.0.1:8080...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: GET]
* h2h3 [:path: /?param=%_D]
* h2h3 [:scheme: http]
* h2h3 [:authority: localhost:8080]
* h2h3 [user-agent: curl/7.87.0]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0xaaabd90f0dc0)
> GET /?param=%_D HTTP/2
> Host: localhost:8080
> user-agent: curl/7.87.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
* Closing connection 0
curl: (16) Error in the HTTP2 framing layer
At some point, no matter if using HTTP/1 or HTTP/2, the parser ends up here
As you can see it will (also) be looked for pct-encoded characters, which expect a % sign, followed by two HEXDIG signs:
Now if that fails...
- ...when using HTTP/1...
...then the method parseHttpRequestTarget fails with (=throws) an IllegalUriException, which will later be handled so a 400 Bad Request with following body will be send:
Illegal request-target: Invalid input '_', expected HEXDIG (line 1, column 10)
(There are various places in the http-core module where IllegalUriExceptions and ParsingExceptions are caught and handled)
- ...when using HTTP/2...
PathAndQuery.parse in following line throws an ParsingException which is never handled (this is in the org.apache.pekko.http.impl.engine.http2 package, so not used by HTTP/1):
A couple of lines later only an IOException gets caught:
If you see where the containing method parseAndEmit gets called, the ParsingException never gets handled.
Expected Result
When using HTTP/2 I would expect to also receive a 400 Bad Request with the body:
Illegal request-target: Invalid input '_', expected HEXDIG (line 1, column 10)
- Ngôn ngữ chính
- Scala
- Star
- 196
- Fork
- 56
- Merge trung bình
- 1 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 43
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/pekko-http
-
dependencies
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
apache/pekko-http#1354 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
apache/pekko-http#1273 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
HTTP/2 client ALPN fallback needs a handshake-complete signal that the TLS stage does not emitĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
apache/pekko-http#1249 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
apache/pekko-http#1248 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
apache/pekko-http#1180 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/pekko-http
Issue tương tự
-
AI Auto-validate
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ProjectSidewalk/SidewalkWebpage#5788 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
scalameta/metals-zed#99 ·
-
area:ops priority:P2 status:idea
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
KD5UJC-XYZ/scarab#112 ·
-
Bound wrong-magic P2P diagnostics to parsed header bytesCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ergoplatform/ergo#2736 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
perf: use extend when buffering partition row indices in the native shuffle writerCó thể đã có người làm @HarshilMital đã nhận 1 ngày trước. Đang mởarea:shuffle enhancement good first issue performance requires-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
apache/datafusion-comet#7072 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày