Prevent tasks from writing XComs as other task instances - #70969
Draft
shivaam wants to merge 1 commit into
Draft
Conversation
Execution API task tokens identify a single task instance, but XCom writes previously trusted the URL coordinates independently. A valid task token could therefore write under another task instance identity within its allowed team boundary.
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.
Execution API JWTs identify a single task instance, but the existing XCom POST route also accepts the Dag, run, task, and map identity in the URL and query parameters. Previously, a valid task token could supply different coordinates and write an XCom under another task instance identity within its permitted team boundary.
This change keeps the existing route for Task SDK and API server compatibility while making the JWT-resolved task instance authoritative for writes. The endpoint rejects a missing token task instance or any Dag, run, task, or map-index mismatch with a structured
403response, and uses the resolved identity for bothXComModelandTaskMapwrites.The in-process Execution API used by local task supervisors has no worker JWT. It overrides the write-identity dependency and resolves the task instance from the trusted route coordinates, preserving
dag.test()and related in-process XCom behavior for both mapped and unmapped tasks.This is intentionally the smallest compatible first slice of #70080. XCom reads retain explicit source identifiers because cross-task, cross-Dag, historical, and mapped pulls need to address task instances other than the authenticated caller. Removing identifiers from the write URL can follow through an API-versioned endpoint once mixed Task SDK/API server compatibility is designed.
Related: #70080
Testing
prek run ruff --from-ref upstream/main --to-ref HEADprek run ruff-format --from-ref upstream/main --to-ref HEADproviders/common/sqlmypy stub error on currentmain.201; cross-task, cross-run, map-index mismatch, and missing-task-instance writes returned structured403 access_deniedresponses; PostgreSQL contained no forbidden XCom rows.Was generative AI tooling used to co-author this PR?
Generated-by: OpenAI Codex following the guidelines