Skip to content

feat: Add Lambda-Runtime-Invocation-Id support for cross-wiring protection#214

Open
vip-amzn wants to merge 1 commit into
mainfrom
feat/invocation-id-cross-wiring
Open

feat: Add Lambda-Runtime-Invocation-Id support for cross-wiring protection#214
vip-amzn wants to merge 1 commit into
mainfrom
feat/invocation-id-cross-wiring

Conversation

@vip-amzn

Copy link
Copy Markdown

Summary

Add Lambda-Runtime-Invocation-Id header support for cross-wiring protection.

The RIC now echoes the invocation ID received from RAPID on /next back on /response and /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 matches it to the new invoke — delivering the wrong response (cross-wiring).

Solution

RAPID sends a unique per-invoke nonce via Lambda-Runtime-Invocation-Id header on /next. The runtime echoes it back on /response and /error. RAPID validates the match before accepting the response.

Changes

  • runtime_client.cpp: Parse Lambda-Runtime-Invocation-Id from /next response, pass to post_success/post_failure via z format (accepts Nonenullptr)
  • lambda_runtime_client.py: Thread invocation_id through to native client
  • bootstrap.py: Pass invocation_id from event request to response/error posting
  • deps/: Patch aws-lambda-cpp to support invocation_id in get_next/do_post
  • Unit tests: 6 new invocation-id specific tests + fix existing assertions for the new parameter

Backward Compatibility

Fully backward compatible in both directions:

  • If RAPID doesn't send the header → RIC doesn't see it → doesn't echo → no behavior change
  • If RIC doesn't echo it (old version) → RAPID skips validation → no behavior change

Testing

  • 95 unit tests pass (includes 6 new invocation-id tests)
  • E2E tested with updated RIE binary (validates invocation-id echo) and stock RIE (backward compat verified)

@vip-amzn vip-amzn requested review from maxday and trivenay July 16, 2026 14:38
@vip-amzn vip-amzn force-pushed the feat/invocation-id-cross-wiring branch from c39ec23 to 61ca64f Compare July 16, 2026 14:43
…ction

Echo the invocation ID received from RAPID on /next back on /response
and /error, enabling RAPID to detect and reject stale responses from
timed-out invocations. Fully backward compatible — header only sent
when received.
@vip-amzn vip-amzn force-pushed the feat/invocation-id-cross-wiring branch from 61ca64f to 39f026b Compare July 16, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant