feat: bound request and response body buffering in plugins#13705
Open
shreemaan-abhishek wants to merge 1 commit into
Open
feat: bound request and response body buffering in plugins#13705shreemaan-abhishek wants to merge 1 commit into
shreemaan-abhishek wants to merge 1 commit into
Conversation
Add max_req_body_size to plugins that read the request body into memory (request-validation, oas-validator, authz-keycloak, degraphql, grpc-web, cas-auth, openwhisk, http-dubbo, serverless, body-transformer, and the ai-prompt-*/ai-request-rewrite plugins) and max_resp_body_size to plugins that buffer the response body (response-rewrite, body-transformer, proxy-cache, grpc-transcode), matching the existing bound in forward-auth and hmac-auth. Both default to 64MiB.
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
Several plugins read the request or response body fully into worker memory without a plugin-local size limit, relying entirely on the gateway-wide
client_max_body_size(which defaults to0, i.e. unlimited). This adds an explicit, configurable bound to those plugins, matching themax_req_body_sizefield already present inforward-authandhmac-auth.max_req_body_size(default64MiB) added to plugins that buffer the request body:request-validation,oas-validator,authz-keycloak,degraphql,grpc-web,cas-auth,openwhisk,http-dubbo, the serverless plugins (aws-lambda,azure-functions,openfunction),body-transformer, and the AI pluginsai-prompt-guard,ai-prompt-decorator,ai-prompt-template,ai-request-rewrite. Requests whose body exceeds the limit are rejected.max_resp_body_size(default64MiB) added to plugins that buffer the response body:response-rewrite,body-transformer,proxy-cache(memory strategy),grpc-transcode. Larger responses are truncated;proxy-cachestreams them through uncached to avoid caching a truncated body.Both fields reuse the existing
core.request.get_body(max_size)/core.response.hold_body_chunk(..., max_resp_body_bytes)primitives.Which issue(s) this PR fixes:
Fixes #
Checklist