Commit 653105f
committed
Restrict exception-node deserialization to BaseException subclasses (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.1 parent 01b7563 commit 653105f
2 files changed
Lines changed: 67 additions & 2 deletions
File tree
- airflow-core
- src/airflow/serialization
- tests/unit/serialization
Lines changed: 31 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
238 | 265 | | |
239 | 266 | | |
240 | 267 | | |
| |||
659 | 686 | | |
660 | 687 | | |
661 | 688 | | |
662 | | - | |
| 689 | + | |
663 | 690 | | |
664 | | - | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
665 | 694 | | |
666 | 695 | | |
667 | 696 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2786 | 2786 | | |
2787 | 2787 | | |
2788 | 2788 | | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
2789 | 2825 | | |
2790 | 2826 | | |
2791 | 2827 | | |
| |||
0 commit comments