fix(aws): preserve multi-value response headers in Lambda gateway#915
Open
tom-groves wants to merge 1 commit intonitrictech:mainfrom
Open
fix(aws): preserve multi-value response headers in Lambda gateway#915tom-groves wants to merge 1 commit intonitrictech:mainfrom
tom-groves wants to merge 1 commit intonitrictech:mainfrom
Conversation
handleHttpProxyRequest and handleApiGatewayRequest were flattening response headers into map[string]string, silently dropping all but one value for multi-value headers (most visibly Set-Cookie). Switch to APIGatewayV2HTTPResponse with a shared lambdaHeaders helper that routes Set-Cookie to the dedicated Cookies []string field and comma-folds all other multi-value headers per RFC 9110 §5.3. MultiValueHeaders is not viable — API Gateway v2 format 2.0 silently ignores it (CVE-2024-24753). Relates to nitrictech#140
|
@tom-groves is attempting to deploy a commit to the Nitric Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Fixes #140 — multi-value response headers (most visibly
Set-Cookie) are silently dropped in the AWS Lambda gateway.handleHttpProxyRequestandhandleApiGatewayRequestflatten response headers intomap[string]string, so Go map key uniqueness silently discards all but one value per header nameAPIGatewayProxyResponse(v1), which is the wrong type for Nitric's v2 HTTP API integration (payload format 2.0)MultiValueHeadersis not viable — API Gateway v2 format 2.0 silently ignores it (CVE-2024-24753)Fix
lambdaHeadershelper that routesSet-Cookievalues to the dedicatedCookies []stringfield and comma-folds all other multi-value headers per RFC 9110 §5.3APIGatewayProxyResponsetoAPIGatewayV2HTTPResponseNot affected
GCP/Azure use the common HTTP gateway (
cloud/common/runtime/gateway/http.go) which correctly callsHeader.Add(k, val)in a nested loop.Test plan
lambdaHeadershelper: multiple Set-Cookie, comma-folded multi-value, single-value unchanged, mixed-case normalisationgo test ./cloud/aws/runtime/gateway/...)