feat: Add Lambda-Runtime-Invocation-Id support for cross-wiring protection#221
feat: Add Lambda-Runtime-Invocation-Id support for cross-wiring protection#221vip-amzn wants to merge 1 commit into
Conversation
c5ac8ea to
9462974
Compare
There was a problem hiding this comment.
here I think we need the invocation id as well, failing to do it will result in "" being passed?
There was a problem hiding this comment.
Thanks a lot for catching this, updated.
There was a problem hiding this comment.
same here, we need the invocation_id as well?
| EXPECT_TRUE(req.cognito_identity.empty()); | ||
| EXPECT_TRUE(req.function_arn.empty()); | ||
| EXPECT_TRUE(req.tenant_id.empty()); | ||
| EXPECT_TRUE(req.invocation_id.empty()); |
There was a problem hiding this comment.
do we expect it to be empty? or does it reflect the missing req.invocation_id being passed in run_handler?
There was a problem hiding this comment.
this test asserts the default-constructed state of invocation_request (all fields empty before get_next() populates them)
9462974 to
6ab9992
Compare
…ction Parse the invocation ID from /next response headers, store in invocation_request, and echo it back on /response and /error via do_post. Header only sent when non-empty (backward compatible).
6ab9992 to
3a639bf
Compare
| post_outcome post_failure( | ||
| std::string const& request_id, | ||
| invocation_response const& handler_response, | ||
| std::string const& invocation_id = ""); |
There was a problem hiding this comment.
Please don't use default argument values. Instead, add an overload and make this one call it with a default value.
Parameters with default values make it hard to change this API without breaking backwards compatibility.
There was a problem hiding this comment.
same comment goes for post_success
There was a problem hiding this comment.
thanks for your input, you're right, let's do that
Summary
Add
Lambda-Runtime-Invocation-Idheader support for cross-wiring protection.The runtime now parses the invocation ID from RAPID's
/nextresponse headers and echoes it back on/responseand/error, enabling RAPID to detect and reject stale responses from timed-out invocations.Problem
On Lambda Managed Instances (LMI) and On-Demand (OD), when an invoke times out, the runtime process continues running in the background. If a new invoke arrives with the same
requestId, RAPID accepts it. The still-running old invocation eventually posts its response, and RAPID delivers the wrong response to the new invoke (cross-wiring).Solution
RAPID sends a unique per-invoke identifier via
Lambda-Runtime-Invocation-Idheader on/next. The runtime echoes it back on/responseand/error. RAPID validates the match before accepting the response.Backward Compatibility
Fully backward compatible in both directions:
Related PRs