fix: reframe request body forwarded upstream in serverless plugins - #13798
Open
shreemaan-abhishek wants to merge 2 commits into
Open
fix: reframe request body forwarded upstream in serverless plugins#13798shreemaan-abhishek wants to merge 2 commits into
shreemaan-abhishek wants to merge 2 commits into
Conversation
The openfunction, aws-lambda and azure-functions plugins share generic-upstream.lua, which forwarded every inbound client header verbatim, including Transfer-Encoding, while supplying the request body already de-chunked by nginx. resty.http then kept Transfer-Encoding: chunked and wrote the unframed body raw, so the upstream request advertised chunked framing over a body that had none, letting the upstream misread the message length. Drop transfer-encoding and content-length before forwarding so the http client reframes the body with a correct Content-Length. Adds an end-to-end test that a chunked client body reaches the upstream reframed.
shreemaan-abhishek
force-pushed
the
fix/serverless-request-smuggling
branch
from
August 10, 2026 11:18
cca5583 to
8d9df64
Compare
AlinsRan
previously approved these changes
Aug 11, 2026
…est-smuggling # Conflicts: # apisix/plugins/serverless/generic-upstream.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
openfunction,aws-lambdaandazure-functionsplugins shareapisix/plugins/serverless/generic-upstream.lua. It forwarded every inbound client header verbatim, includingTransfer-Encoding, while supplying the request body already de-chunked by nginx (ngx.req.get_body_data()).resty.httpthen keepsTransfer-Encoding: chunked, dropsContent-Length, and writes the now-unframed body raw without re-chunking. The forwarded upstream request advertised chunked framing over a body that had none, so a keep-alive upstream could misread where the message ends.Fix: strip the client's
Transfer-EncodingandContent-Lengthbefore forwarding, so the HTTP client recomputes a correctContent-Lengthfrom the actual body and never emits chunked framing over an unframed body. The strip runs before each plugin's request processor, soaws-lambdaSigV4 signs a clean header set.Added an end-to-end case in
t/plugin/aws-lambda.t: a chunked client request through the plugin, asserting the upstream receives a reframed body with a correctContent-Lengthand noTransfer-Encoding.Checklist