ai-proxy forwards client `Transfer-Encoding: chunked` but sends an unchunked body (upstream 400)
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- lua, nginx
- 領域
- backend, networking
調査の方向性
apisix/plugins/ai-transport/http.lua の86~91行付近にあるブラックリストから始め、construct_forward_headers がクライアントヘッダーをどのように処理するかを追ってください。転送されたヘッダーに関するトランスポートテストを確認し、チャンク化されたクライアントリクエストのテストを追加してください。upstream が正しく再フレーミングされたボディヘッダーを受信し、回帰テストが成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
ai-proxy forwards the client's Transfer-Encoding: chunked header to the upstream, but the body it
sends is not chunked. content-length is explicitly stripped by the same blacklist, so the
upstream receives a framing contradiction and a real HTTP/1.1 server rejects it with 400.
Where (pin b6deb41; identical in release 3.19.0)
apisix/plugins/ai-transport/http.lua:86-91 — the blacklist that is supposed to remove hop-by-hop
framing headers:
local blacklist = {
"host",
"content-length",
"accept-encoding",
}
transfer-encoding is missing. Every other client header is copied
(apisix/plugins/ai-proxy/base.lua:291 → extra_opts.client_headers = core.request.headers(ctx),
merged at apisix/plugins/ai-providers/base.lua:237). The body is then a known Lua string, so the
transport sends it unchunked.
Repro (hard)
# transport client using the real construct_forward_headers, rawdump upstream on :8889
curl -s -X POST 'http://127.0.0.1:9083/poc?port=8889' -H 'Transfer-Encoding: chunked' -H 'X-Foo: a' -d 'xxxxxxxx'
# against a real nginx upstream that reads the body (:9082/echo)
curl -s -X POST 'http://127.0.0.1:9083/poc?port=9082' -H 'Transfer-Encoding: chunked' -d 'xxxxxxxx'
Observed on the rawdump:
POST /echo HTTP/1.1
transfer-encoding: chunked <-- and no Content-Length
...
<raw JSON body, not chunked>
→ real nginx upstream: status=400. Without the client header: Content-Length: 62 + raw body →
status=200.
Impact
Any client that legitimately uses chunked upload against an ai-proxy route can get a 400 from the
upstream, i.e. the request never reaches the model. CVSS 3.1
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L = 6.5.
CWE-436 / CWE-444.
Suggestion
Either add transfer-encoding to the blacklist (the body is re-framed anyway, so it should not be
forwarded verbatim), or actually chunk the body when the header is passed through. Adding it to the
blacklist matches the existing intent, since content-length is treated the same way.
Notes
Found while auditing b6deb41; apisix/plugins/ai-transport/http.lua is byte-identical to the
3.19.0 release commit and unchanged on main today. Introduced by be45f233 (three-layer AI proxy
refactor, #13170). A sibling report about the same forwarded-header path (ai-cache fingerprint)
is filed separately.
- 主要言語
- Lua
- スター
- 17.3k
- フォーク
- 3k
- 平均マージ
- 3日 2時間
- マージ済み PR(30日)
- 63
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/apisix のほかの issue
-
bug(body-transformer): runtime crash when request or response body is a JSON primitive対応中かも @bhuvan-somisetty が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
bug: openapi-to-mcp appends a second ? to a query-suffixed path template対応中かも @lordcheng10 が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 2 日以内に返信
-
As a user, I want the opa plugin to propagate trace context (traceparent) to OPA, so that OPA spans are linked to the APISIX request trace対応中かも @GitNimay が 18 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/apisix#14051 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
bug: splunk-hec-logging crashes with nil concatenation when error response json lacks text field対応中かも @LiteSun が 10 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
apache/apisix#14011 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
bug: tcp-logger attempts to send nil data and crashes when json encoding fails対応中かも @LiteSun が 10 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
apache/apisix#14003 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
似ている issue
-
bug forever
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
openmap-world/openmap#45 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
PrettyRS/prettyui#55 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
rcamera.h?オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
RobLoach/raylib-api#13 · コメント 4 件 ·
-
web
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
Good First Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信