Summary
Apache Airflow deserializes task-controlled next_kwargs before checking that the decoded value is a dictionary. A DAG author who can set this value may cause constructors for allow-listed classes to run in the scheduler or, under certain API conditions, the API server.
Affected context
The issue concerns Airflow's handling of stored task next_kwargs values. The type check added in Airflow 3.3.1 happens after deserialization, so it cannot prevent constructors for permitted nested classes from running first. The scheduler may encounter the value during an awaiting_input timeout sweep; the API server may also encounter it when serving a task instance to a worker using an older Execution API version. No non-default configuration is required.
Exploit preconditions
- Attack surface: Task data processed by the Airflow scheduler or, in the specified compatibility scenario, the API server
- Required access: Ability to author a DAG and control its task's
next_kwargsthrough the task execution API - Trigger point: The scheduler processes the task during an
awaiting_inputtimeout sweep, or the API server serves the task instance to a worker using an older Execution API version - Why exploitation is possible: Deserialization constructs allow-listed nested objects before the subsequent dictionary-type check can reject the value
Why this happens
The underlying flaw is unsafe deserialization (CWE-502) combined with validation performed too late. The application reconstructs objects from stored data before establishing that the decoded value has the expected type. Because permitted classes can have constructors that run during reconstruction, a later type check does not prevent constructor execution.
Potential impact
- Allow-listed constructors may run inside the scheduler or API server process
- Constructor side effects could compromise the affected service process
- Depending on the permitted classes and their behavior, this may enable code execution or affect service availability
General mitigation guidance
Mitigation patterns focus on preventing untrusted data from triggering object construction:
- Prefer data-only serialization formats and restricted deserializers that do not instantiate application objects
- Validate the serialized structure and enforce strict schemas before any object reconstruction
- Minimize the classes permitted by deserialization allow-lists and avoid constructors with side effects
- Treat task-supplied values as untrusted, even when stored internally
- Apply least privilege and process isolation to scheduler and API service components
- Keep compatibility paths subject to the same validation and deserialization safeguards
How teams detect issues like this
- Use static analysis to identify deserialization APIs that reconstruct objects from task-controlled or otherwise untrusted data
- Review code paths where validation occurs only after parsing or object construction
- Check allow-lists for classes with constructor side effects or broad behavior
- Enforce policies requiring data-only parsing and schema validation before use
- Monitor task-processing services for unexpected constructor activity or anomalous process behavior
- Automated code review tools may help flag unsafe deserialization and validation-order patterns

