ai-proxy forwards client `Transfer-Encoding: chunked` but sends an unchunked body (upstream 400)
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- lua, nginx
- Ambito
- backend, networking
Direzione di ricerca
Inizia dalla blacklist in apisix/plugins/ai-transport/http.lua, intorno alle righe 86–91, e segui come construct_forward_headers gestisce gli header del client. Controlla i test del trasporto per gli header inoltrati e aggiungi una copertura per una richiesta client a blocchi. Il lavoro è completato quando l’upstream riceve gli header del body correttamente riformattati e il test di regressione passa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Lua
- Stelle
- 17.3k
- Fork
- 3k
- Merge medio
- 3g 6h
- PR unite (30g)
- 68
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/apisix
-
bug(body-transformer): runtime crash when request or response body is a JSON primitiveForse già presa @bhuvan-somisetty l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
bug: openapi-to-mcp appends a second ? to a query-suffixed path templateForse già presa @lordcheng10 l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 2 giorni
-
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 traceForse già presa @GitNimay l’ha presa 17 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/apisix#14051 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
bug: splunk-hec-logging crashes with nil concatenation when error response json lacks text fieldForse già presa @LiteSun l’ha presa 9 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/apisix#14011 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
bug: tcp-logger attempts to send nil data and crashes when json encoding failsForse già presa @LiteSun l’ha presa 9 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/apisix#14003 · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di apache/apisix
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Balatro-Multiplayer/BalatroMultiplayerAPI#67 ·
I maintainer di solito rispondono entro 2 giorni
-
Unconfirmed bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
luanti-org/luanti#17736 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(bufdelete): all()/other() abort with "Invalid buffer id" when a buffer is wiped during the loopAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
folke/snacks.nvim#2986 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
PlotJuggler/PlotJuggler#1464 ·