Restrict BASE_TRIGGER deserialization to trusted classes (validate before import)#67926
Closed
potiuk wants to merge 2 commits into
Closed
Restrict BASE_TRIGGER deserialization to trusted classes (validate before import)#67926potiuk wants to merge 2 commits into
potiuk wants to merge 2 commits into
Conversation
13a6c44 to
d185f59
Compare
Member
|
Why exactly does this matter? Its user code operating in the triggerer - if they want to play silly games let them? |
Open
4 tasks
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
62bbec6 to
233e42a
Compare
Member
Author
|
#68528 is a better fix. |
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.
When loading a serialized DAG, the
BASE_TRIGGERdeserialization branch inBaseSerialization.deserializeimported the stored class path and instantiated it without checking it is actually aBaseTriggersubclass. This restricts that path toBaseTriggersubclasses (raisingValueErrorotherwise), matching the encode side which only emitsBASE_TRIGGERforBaseTriggerinstances.Tests
test_base_trigger_deserialization_rejects_non_trigger_class— a non-BaseTriggerclass path is rejected.test_trigger_kwargs_not_deserialised_through_serdagstill passes.Was 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