Summary
Apache Airflow's XCom PATCH endpoint (PATCH /api/v2/xcomEntries/{key}) allowed authenticated users with XCom write permission on a DAG to store serialized payloads under reserved keys, such as return_value, that should have been blocked.
Because the triggerer deserializer treated these payloads as code when deferred tasks resumed, an attacker with such permissions could achieve remote code execution (RCE) on the triggerer component in affected deployments.
Affected context
This vulnerability arises in Apache Airflow environments that:
- Expose the REST API or Web UI to users who are not fully trusted
- Grant those users XCom write permissions on DAGs that make use of deferrable operators or otherwise defer to the triggerer
- Rely on XCom entries with reserved keys (e.g.,
return_value) to be protected by validation
The issue affects the PATCH endpoint for XCom entries, which did not enforce the FORBIDDEN_XCOM_KEYS validation already present on the corresponding POST/set path. When a deferred task resumes, the triggerer deserializes certain XCom values and can be tricked into executing attacker-controlled code.
Exploit preconditions
- Attack surface: Airflow REST API and Web UI, specifically the
PATCH /api/v2/xcomEntries/{key}endpoint. - Required access: Authenticated Airflow user with XCom write permission on at least one DAG that uses deferrable tasks or otherwise interacts with the triggerer.
- Trigger point: The vulnerable XCom PATCH is used to:
- Write a crafted serialized payload under a reserved key name (e.g.,
return_value). - Allow the corresponding task to defer and later resume, causing the triggerer to deserialize the XCom value.
- Why exploitation is possible:
- The PATCH path did not enforce
FORBIDDEN_XCOM_KEYS, enabling writes to keys that are trusted by the triggerer. - The triggerer's deserializer accepts payload shapes that are interpreted as executable code rather than inert data.
- Combined, this lets an attacker influence both the key and the serialized content consumed by a privileged component.
Why this happens
The core bug is a combination of unsafe deserialization and incomplete validation of security-sensitive keys:
- The XCom subsystem allows arbitrary serialized payloads to be stored and later deserialized by the triggerer.
- Reserved XCom keys (such as
return_value) are treated specially by downstream logic and are not meant to be user-controlled, so they are guarded byFORBIDDEN_XCOM_KEYS. - A prior fix added validation for these forbidden keys on the POST/set endpoint but did not apply the same validator to the PATCH endpoint, creating a fix-bypass path.
- When a deferred task resumes, the triggerer deserializer processes XCom values associated with these special keys using a mechanism that can instantiate or evaluate objects instead of treating them as plain data.
This maps directly to CWE-502: Unsafe Deserialization, where untrusted data is passed into a deserializer capable of interpreting it as code, made more severe by the bypass of key-level protections that were assumed to be universal.
Potential impact
- Remote code execution on the Airflow triggerer process with its effective runtime privileges
- Full compromise of task orchestration for affected DAGs, including alteration or injection of results
- Lateral movement within the Airflow deployment, depending on the triggerer's network and credential access
- Tampering with workflow outputs, leading to data integrity issues and downstream pipeline poisoning
- Potential use of the triggerer as a foothold for broader infrastructure compromise
General mitigation guidance
Effective mitigation focuses on removing unsafe deserialization paths from untrusted control and tightening XCom key handling:
- Apply uniform validation: ensure that all endpoints capable of creating or modifying XCom entries (POST, PATCH, PUT, bulk operations) consistently enforce forbidden/reserved key policies.
- Constrain deserialization: prefer deserialization mechanisms that operate on strictly typed, schema-validated data structures and cannot instantiate arbitrary code or objects.
- Reduce trust in XCom inputs: treat any user-supplied or indirectly user-influenced XCom data as untrusted; avoid using such values in code paths that support executable constructs.
- Harden triggerer privileges: run the triggerer with least-privilege OS and platform permissions, limiting the blast radius if code execution is achieved.
- Enforce role separation: avoid granting XCom write permissions on deferrable DAGs to users who are not fully trusted operators; separate operational and untrusted roles.
- Centralize security checks: design API layers so that key-level and payload validation lives in shared components, minimizing the chance that one HTTP method or path omits a critical guard.
How teams detect issues like this
Detection typically combines code-level review with runtime monitoring:
- Static analysis & code review:
- Flag deserialization calls that operate on data reachable from HTTP handlers, UI inputs, or multi-tenant workflows.
- Search for duplicated or inconsistent validation logic across similar endpoints (e.g., POST vs PATCH for the same resource).
- Identify code paths where special/reserved keys or magic values receive different treatment and confirm all input paths enforce the same rules.
- Policy enforcement:
- Introduce CI checks that verify that every XCom write operation passes through common validation utilities (including forbidden-key checks).
- Maintain internal security guidelines requiring safe deserializers or schema-driven formats for any value that can be user-controlled.
- Runtime monitoring:
- Log and alert on XCom writes using reserved or unexpected keys, especially when modified through PATCH.
- Monitor triggerer logs for deserialization errors or anomalous exceptions that could reflect exploitation attempts.
- Automated tooling:
- Use SAST and API security scanners configured with rules for unsafe deserialization and inconsistent validation across REST endpoints.

