Restrict exception-node deserialization to BaseException subclasses (validate before import)#68511
Open
potiuk wants to merge 3 commits into
Open
Restrict exception-node deserialization to BaseException subclasses (validate before import)#68511potiuk wants to merge 3 commits into
potiuk wants to merge 3 commits into
Conversation
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
3baa424 to
0e8d29d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #67926 — applies the same pre-import class-path validation to the
AIRFLOW_EXC_SER/BASE_EXC_SERexception branches that #67926 adds forBASE_TRIGGER, reusing the shared_safe_import_for_deserializehelper. 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 asBaseExceptionsubclasses. Builtins stay allowed for standard exceptions; the subclass check rejects non-exception builtins.Tests
AIRFLOW_EXC_SERpath outside trusted namespaces rejected before importBASE_EXC_SERnon-exception builtin (e.g.eval) rejectedWas generative AI tooling used to co-author this PR?
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