Skip to content

Prevent tasks from writing XComs as other task instances - #70969

Draft
shivaam wants to merge 1 commit into
apache:mainfrom
shivaam:refactor-70080-jwt-xcom
Draft

Prevent tasks from writing XComs as other task instances#70969
shivaam wants to merge 1 commit into
apache:mainfrom
shivaam:refactor-70080-jwt-xcom

Conversation

@shivaam

@shivaam shivaam commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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 403 response, and uses the resolved identity for both XComModel and TaskMap writes.

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

  • Focused Breeze validation: 70 passed (67 Execution API XCom route tests plus three in-process regressions covering unmapped writes, mapped writes, and missing task-instance rejection).
  • prek run ruff --from-ref upstream/main --to-ref HEAD
  • prek run ruff-format --from-ref upstream/main --to-ref HEAD
  • Regular pre-commit checks passed for the changed files; the aggregate run encountered an unrelated providers/common/sql mypy stub error on current main.
  • Final-revision Breeze daemon validation with PostgreSQL 14 and LocalExecutor: two real scheduler runs completed with 22/22 successful task instances, covering Task SDK XCom push/pull and mapped indexes 0-2.
  • Real JWT/API boundary probe: an own-task write returned 201; cross-task, cross-run, map-index mismatch, and missing-task-instance writes returned structured 403 access_denied responses; PostgreSQL contained no forbidden XCom rows.

Was generative AI tooling used to co-author this PR?
  • Yes (OpenAI Codex)

Generated-by: OpenAI Codex following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.

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.
@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:task-sdk labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:task-sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant