Repository navigation
Conversation
Propagate an end-user JWT from a client, through a caller Workflow, to a Nexus Operation handler without exposing it in history or headers. Each credential header is encrypted with Tink HPKE to the receiving hop and bound to the hop's context and to a digest of the exact argument ciphertexts it accompanies, so no sender-side key can decrypt or repurpose it and no input needs deterministic serialization. The handler validates the JWT, authorizes the input against a client-sealed intent, derives the backing Workflow ID from the principal and business identity, and signs its operation tokens. Includes end-to-end tests against the test server, covering start-path, continue-as-new, replay, substitution, and authorization cases, plus unit tests of the cryptographic components.
bergundy
requested review from
a team,
antmendoza and
tsurdilo
as code owners
October 13, 2026 16:54
bergundy
marked this pull request as draft
October 13, 2026 16:55
Public HPKE keys need not be secret: they only let a holder seal a header around a token they already have. Document that sender authentication requires a signature, and that the client-sealed intent does not replace server-side authorization.
VerifyCredentialBinding reads a Workflow history and, for each credential header, recomputes the args digest from the event's input ciphertexts (or uses firstExecutionRunId for continue-as-new headers), opens the header with that context, and confirms that a context with one bit changed is rejected and that the digest is not present in the header bytes. It prints only the credential's subject and issuer and exits non-zero on failure.
Tink's HybridEncrypt passes contextInfo to HPKE as the info parameter, which is mixed into key derivation, and seals with empty associated data. The docs called the context authenticated associated data, which is inaccurate. Describe it as HPKE info and state that it is never transmitted, only rebuilt by the receiver.
The intent only protected an honest caller Worker from being steered into sending a different Nexus input. It adds nothing against a compromised Worker or a user acting with their own token, and an action-scoped token from the identity provider covers the same ground more strongly. It also added a third of the sample's authorization surface. The credential envelope now carries only the JWT, and the handler authorizes the principal against the input through an AuthorizationPolicy. The README explains that each header is bound to its own hop's args digest, that nothing links the start arguments to the Nexus input, and points to action-scoped tokens and the other mechanisms for steering.
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.
What changed?
Adds
core/src/main/java/io/temporal/samples/nexussecurecredentialpropagation, a sample that propagates an end-user JWT from a client, through a caller Workflow, to a Nexus Operation handler without the JWT appearing in plaintext in history, Temporal headers, or Nexus headers.infobinds it to the hop's context and to a SHA-256 digest of that hop's transmitted argument ciphertexts, their positions, and count: the start header to the start arguments, the Nexus header to the Nexus input. The context is never transmitted: it is mixed into key derivation, and the receiver rebuilds it from the dispatched route, its Workflow info, and the ciphertexts it received. No input is canonicalized or re-serialized. The payload codec hands the digest to the interceptors through a thread local and knows nothing about credentials.firstExecutionRunId(the Java SDK builds that header before encoding arguments). Child Workflows never receive the credential.PayloadValidationErrorso the handler reportsBAD_REQUESTinstead of retrying.tools/VerifyCredentialBindingreads a Workflow's history and, for everyWorkflowExecutionStartedandNexusOperationScheduledevent with a credential header, recomputes the binding, opens the header with it, confirms a one-bit-changed context is rejected, and confirms the binding value is absent from the header bytes. It needs the receivers' private keys (only they can check the binding), prints only subject and issuer, and exits non-zero on failure.com.google.crypto.tink:tink:1.23.0tocore.The README documents the threat model, wire formats, key distribution, why the HPKE public keys need not be secret (and how to add sender authentication with signatures if needed), replay cases, why the args digests do not scope the credential to an action and the alternatives for that (action-scoped tokens and others), and the access-layer boundary for replayed cancels.
Why?
To show a replay-safe way to carry end-user identity across a Nexus call where neither history readers nor holders of sender-side keys can read or repurpose the credential.
Breaking changes?
None.
Testing
SecureCredentialPropagationTest(21 end-to-end tests against the test server): start / signal-with-start / update-with-start, continue-as-new to another type plus retry, child Workflows, cancellation, argument reorder/duplicate/truncate/substitute, copied continue-as-new header, key-less attacker replaying captured Nexus input and headers (exact replay, input swap, endpoint move, missing credential), subject check, wrong audience, a misordered interceptor, and the verifier on normal, continue-as-new, and substituted-argument histories.CryptoComponentsTest(18 unit tests): framing, header contexts and parsing, args digest, codec context binding, JWT validation, authorization policy, resource IDs, operation tokens.:core:testpasses.