Skip to content

Restrict exception-node deserialization to BaseException subclasses (validate before import)#68511

Open
potiuk wants to merge 3 commits into
apache:mainfrom
potiuk:restrict-exception-node-deserialization
Open

Restrict exception-node deserialization to BaseException subclasses (validate before import)#68511
potiuk wants to merge 3 commits into
apache:mainfrom
potiuk:restrict-exception-node-deserialization

Conversation

@potiuk

@potiuk potiuk commented Jun 13, 2026

Copy link
Copy Markdown
Member

Stacked on #67926 — applies the same pre-import class-path validation to the AIRFLOW_EXC_SER / BASE_EXC_SER exception branches that #67926 adds for BASE_TRIGGER, reusing the shared _safe_import_for_deserialize helper. Review the top commit; the first commit belongs to #67926 and drops out once it merges.

Exception classes are now resolved through the trusted-namespace allowlist (validated before import_string), then verified as BaseException subclasses. Builtins stay allowed for standard exceptions; the subclass check rejects non-exception builtins.

Tests

  • AIRFLOW_EXC_SER path outside trusted namespaces rejected before import
  • BASE_EXC_SER non-exception builtin (e.g. eval) rejected
  • genuine builtin exception still round-trips
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 added 3 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
Resolve exception classes through the same trusted-namespace allowlist used
for triggers: validate the class-path string before import_string runs, then
verify the BaseException subclass. Builtins are allowed for standard
exceptions, with the subclass check rejecting non-exception builtins.

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
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.

1 participant