Skip to content

Restrict exception-node deserialization to known classes without importing the stored name#68511

Open
potiuk wants to merge 1 commit into
apache:mainfrom
potiuk:restrict-exception-node-deserialization
Open

Restrict exception-node deserialization to known classes without importing the stored name#68511
potiuk wants to merge 1 commit into
apache:mainfrom
potiuk:restrict-exception-node-deserialization

Conversation

@potiuk

@potiuk potiuk commented Jun 13, 2026

Copy link
Copy Markdown
Member

When deserializing AIRFLOW_EXC_SER / BASE_EXC_SER nodes, the exception class was resolved by import_string() on a name taken from the serialized blob. This resolves it against in-memory classes instead, so deserializing a stored DAG never imports a class named in the blob:

  • AIRFLOW_EXC_SER — looked up in a map of loaded AirflowException subclasses, built once from the in-memory subclass tree and never rebuilt; a name that isn't a registered AirflowException subclass is rejected.
  • BASE_EXC_SER — resolved against the fixed {KeyError, AttributeError} set, which is all the encoder ever emits for this node type.

Unknown or disallowed names raise DeserializationError instead of being imported. The trigger-node branch is handled separately in #67926.

Tests

  • AIRFLOW_EXC_SER name that isn't a registered AirflowException subclass is rejected (not imported)
  • genuine AirflowException subclass round-trips via the registry
  • BASE_EXC_SER name outside {KeyError, AttributeError} (e.g. eval, ValueError) rejected
  • KeyError / AttributeError still round-trip
Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.8

Generated-by: Claude Opus 4.8 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 13, 2026 17:14
@potiuk potiuk force-pushed the restrict-exception-node-deserialization branch from 3baa424 to 0e8d29d Compare June 14, 2026 01:51
@potiuk potiuk force-pushed the restrict-exception-node-deserialization branch from 0e8d29d to 653105f Compare June 15, 2026 03:00
@potiuk potiuk added this to the Airflow 3.3.0 milestone Jun 17, 2026
@potiuk

potiuk commented Jun 21, 2026

Copy link
Copy Markdown
Member Author

@ashb - would that be a good enough check ?

@potiuk potiuk force-pushed the restrict-exception-node-deserialization branch from 653105f to 2523f45 Compare June 28, 2026 17:15
@potiuk potiuk changed the title Restrict exception-node deserialization to BaseException subclasses (validate before import) Restrict exception-node deserialization to known classes without importing the stored name Jun 28, 2026
@potiuk potiuk force-pushed the restrict-exception-node-deserialization branch from 2523f45 to 8719b77 Compare June 28, 2026 17:31
… name

When deserializing AIRFLOW_EXC_SER / BASE_EXC_SER nodes, BaseSerialization
resolved the exception class with import_string() on a name taken from the
serialized blob. Resolve it against in-memory classes instead, so a stored
DAG never imports a class named in the blob:

- AIRFLOW_EXC_SER: look the name up in a map of loaded AirflowException
  subclasses, built once from the in-memory subclass tree; a name that is
  not a registered AirflowException subclass is rejected.
- BASE_EXC_SER: resolve against the fixed {KeyError, AttributeError} set
  that the encoder is the only producer of.

Unknown or disallowed names raise DeserializationError instead of being
imported. The trigger-node branch is handled separately.

Generated-by: Claude Opus 4.8 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 restrict-exception-node-deserialization branch from 8719b77 to 83485d9 Compare June 28, 2026 18:43
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