Skip to content

Restrict BASE_TRIGGER deserialization to trusted classes (validate before import)#67926

Closed
potiuk wants to merge 2 commits into
apache:mainfrom
potiuk:validate-base-trigger-deserialization-type
Closed

Restrict BASE_TRIGGER deserialization to trusted classes (validate before import)#67926
potiuk wants to merge 2 commits into
apache:mainfrom
potiuk:validate-base-trigger-deserialization-type

Conversation

@potiuk

@potiuk potiuk commented Jun 2, 2026

Copy link
Copy Markdown
Member

When loading a serialized DAG, the BASE_TRIGGER deserialization branch in BaseSerialization.deserialize imported the stored class path and instantiated it without checking it is actually a BaseTrigger subclass. This restricts that path to BaseTrigger subclasses (raising ValueError otherwise), matching the encode side which only emits BASE_TRIGGER for BaseTrigger instances.

Tests

  • Added test_base_trigger_deserialization_rejects_non_trigger_class — a non-BaseTrigger class path is rejected.
  • Existing test_trigger_kwargs_not_deserialised_through_serdag still passes.
Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.8 (1M context)

Generated-by: Claude Opus 4.8 (1M context) following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

@potiuk potiuk requested review from ashb and bolkedebruin as code owners June 2, 2026 22:50
@potiuk potiuk added this to the Airflow 3.3.0 milestone Jun 2, 2026
@potiuk potiuk force-pushed the validate-base-trigger-deserialization-type branch from 13a6c44 to d185f59 Compare June 5, 2026 14:07
@ashb

ashb commented Jun 12, 2026

Copy link
Copy Markdown
Member

Why exactly does this matter? Its user code operating in the triggerer - if they want to play silly games let them?

@potiuk potiuk changed the title Restrict BASE_TRIGGER deserialization to BaseTrigger subclasses Restrict BASE_TRIGGER deserialization to trusted classes (validate before import) Jun 12, 2026
potiuk added 2 commits June 14, 2026 03:51
When loading a serialized DAG, the BASE_TRIGGER deserialization branch
imported the stored class path and instantiated it without checking it
is a BaseTrigger subclass. Restrict it to BaseTrigger subclasses,
matching the encode side which only emits BASE_TRIGGER for BaseTrigger
instances.

Generated-by: Claude Opus 4.8 (1M context) following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
Resolve the trigger class through a trusted-namespace allowlist that is
checked before import_string runs, rather than importing first and checking
the type afterward. A shared _safe_import_for_deserialize helper validates
the class-path string against the trusted prefixes, then imports and
verifies the subclass.

Generated-by: Claude Opus 4.8 (1M context) following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
@potiuk potiuk force-pushed the validate-base-trigger-deserialization-type branch from 62bbec6 to 233e42a Compare June 14, 2026 01:51
@potiuk potiuk marked this pull request as draft June 14, 2026 08:37
@potiuk potiuk closed this Jun 14, 2026
@potiuk

potiuk commented Jun 14, 2026

Copy link
Copy Markdown
Member Author

#68528 is a better fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants