Restrict exception-node deserialization to BaseException subclasses (validate before import)#68511
Open
potiuk wants to merge 2 commits into
Open
Restrict exception-node deserialization to BaseException subclasses (validate before import)#68511potiuk wants to merge 2 commits into
potiuk wants to merge 2 commits into
Conversation
3baa424 to
0e8d29d
Compare
…GER) The DAT.BASE_TRIGGER encode/decode (serializing a BaseTrigger instance via BaseSerialization) is a vestige of AIP-44's Internal API. Live deferral uses the structured DeferTask/TIDeferredStatePayload (classpath+kwargs); the execution API stores the classpath opaquely; the triggerer imports it from the DB row. No external producer/consumer of DAT.BASE_TRIGGER remains. Keeps generic AirflowException serialization (live). Generated-by: Claude Opus 4.8 (1M context)
…validate before import) Stacked on apache#68528, which removed the dead AIP-44 BASE_TRIGGER path; the remaining hardening here is for the exception nodes. When a serialized DAG carries an exception node (AIRFLOW_EXC_SER / BASE_EXC_SER), deserialization called import_string on the stored class path and instantiated whatever it resolved to, without validating the path or the resulting type. Add _safe_import_for_deserialize, which validates the class path against a trusted-namespace prefix list (airflow., plus builtins. for the BASE_EXC_SER builtin case) before importing, and then confirms the resolved object is a BaseException subclass. A path outside the trusted namespaces is rejected without being imported.
0e8d29d to
653105f
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