HTTP/2 error when parsing percent-encoded query string
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- scala
調査の方向性
http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/UriParser.scala と、http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/HeaderDecompression.scala の HTTP/2 のフロー(parseAndEmit を含む)から始めてください。curl を使って HTTP/1.1 と HTTP/2 で無効な %_D query を再現し、その後 ParsingException がどのように処理されるかを追跡してください。HTTP/2 が接続を HTTP/2 framing error で閉じるのではなく、ドキュメントに記載されたエラーボディーとともに 400 Bad Request を返すようになれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- Scala
- スター
- 196
- フォーク
- 56
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 43
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/pekko-http のほかの issue
-
dependencies
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
apache/pekko-http#1354 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
apache/pekko-http#1273 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
apache/pekko-http#1249 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
apache/pekko-http#1248 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
apache/pekko-http#1180 ·
メンテナーはふだん 1 日以内に返信
apache/pekko-http の issue をすべて見る
似ている issue
-
Bound wrong-magic P2P diagnostics to parsed header bytes対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ergoplatform/ergo#2736 ·
メンテナーはふだん 1 日以内に返信
-
area:shuffle enhancement good first issue performance requires-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/datafusion-comet#7072 ·
メンテナーはふだん 1 日以内に返信
-
bug 🐞 CI/CD ⚒️
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
valkey-io/valkey-glide#7370 ·
メンテナーはふだん 1 日以内に返信
-
Improve UI text on confirmation page (at registration)対応中かも @Arghyann が今日担当しました。 オープンgood first issue improvement
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
lichess-org/lila#22126 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[VL] Remove the unused ShuffleSchema.h対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信