Uh oh!
There was an error while loading. Please reload this page.
fix: block path traversal via ".." in dag_id and run_id - #63296
Conversation
potiuk
left a comment
There was a problem hiding this comment.
This is extremely risky change if we do not have a mechanism to allow those.
If we merge thius change, suddenly all the Dags of someone who has .. in their name will fail and they will have to manually convert their Dags. People migh have weird conventions for names and
potiuk
commented
Mar 10, 2026
cc: @ferruzzi -> did you think how to handle the case if someone already uses |
ferruzzi
commented
Mar 10, 2026
I'm not honestly sure how big of a risk it is, in the end, but it did seem like a reasonable concern. IMHO, we can have a flag to allow it, set to false. That way we're "safe by default" and the user has to explicitly allow it? It's still breaking, but with some allowance?? |
YoannAbriel
commented
Mar 10, 2026
Good point — will add a config flag (default: block) so existing users with |
ferruzzi
commented
Mar 10, 2026
Since this is a breaking change, it will also need a newsfragment |
4897b94 to
1e0378dCompare
ferruzzi
left a comment
There was a problem hiding this comment.
Still pending the config flag to enable/disable the feature, but nice progress. Ping me when you are ready for a re-review.
Uh oh!
There was an error while loading. Please reload this page.
507874d to
1c42375CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
validate_key() and validate_run_id() allow ".." which can be used for path traversal when these values end up in log file paths. Reject any key or run_id containing ".." early in validation. Closes: apache#63295
… in create_dagrun - Add [core] allow_dotdot_in_ids config flag (default: False) so existing users with '..' in their IDs can opt out of the blocking behavior - Add '..' check in SerializedDAG.create_dagrun() before the regex check, fixing the test_dag_run_id_rejects_path_traversal failure where create_dagrun raised a regex mismatch error before the traversal check - Collapse multi-line raise ValueError in dagrun.py to fix static check - Make all '..' checks conditional on allow_dotdot_in_ids config
… version_added to 3.3.0
1c42375 to
1333ab4Compare
ferruzzi
left a comment
There was a problem hiding this comment.
I wonder if we might want to make and import a constant like DOUBLE_DOT - ".." rather than littering magic strings around, but I'm fine with it as-is... that may be overkill.
potiuk
commented
Mar 24, 2026
Yeah.. It's longer than ".." and |
Uh oh!
There was an error while loading. Please reload this page.
* fix: block path traversal via ".." in dag_id and run_id validate_key() and validate_run_id() allow ".." which can be used for path traversal when these values end up in log file paths. Reject any key or run_id containing ".." early in validation. Closes: #63295 * Add newsfragment for breaking change * fix: add config flag allow_dotdot_in_ids and fix path traversal check in create_dagrun - Add [core] allow_dotdot_in_ids config flag (default: False) so existing users with '..' in their IDs can opt out of the blocking behavior - Add '..' check in SerializedDAG.create_dagrun() before the regex check, fixing the test_dag_run_id_rejects_path_traversal failure where create_dagrun raised a regex mismatch error before the traversal check - Collapse multi-line raise ValueError in dagrun.py to fix static check - Make all '..' checks conditional on allow_dotdot_in_ids config * refactor: rename allow_dotdot_in_ids to allow_double_dot_in_ids, bump version_added to 3.3.0
* fix: block path traversal via ".." in dag_id and run_id validate_key() and validate_run_id() allow ".." which can be used for path traversal when these values end up in log file paths. Reject any key or run_id containing ".." early in validation. Closes: apache#63295 * Add newsfragment for breaking change * fix: add config flag allow_dotdot_in_ids and fix path traversal check in create_dagrun - Add [core] allow_dotdot_in_ids config flag (default: False) so existing users with '..' in their IDs can opt out of the blocking behavior - Add '..' check in SerializedDAG.create_dagrun() before the regex check, fixing the test_dag_run_id_rejects_path_traversal failure where create_dagrun raised a regex mismatch error before the traversal check - Collapse multi-line raise ValueError in dagrun.py to fix static check - Make all '..' checks conditional on allow_dotdot_in_ids config * refactor: rename allow_dotdot_in_ids to allow_double_dot_in_ids, bump version_added to 3.3.0
* fix: block path traversal via ".." in dag_id and run_id validate_key() and validate_run_id() allow ".." which can be used for path traversal when these values end up in log file paths. Reject any key or run_id containing ".." early in validation. Closes: apache#63295 * Add newsfragment for breaking change * fix: add config flag allow_dotdot_in_ids and fix path traversal check in create_dagrun - Add [core] allow_dotdot_in_ids config flag (default: False) so existing users with '..' in their IDs can opt out of the blocking behavior - Add '..' check in SerializedDAG.create_dagrun() before the regex check, fixing the test_dag_run_id_rejects_path_traversal failure where create_dagrun raised a regex mismatch error before the traversal check - Collapse multi-line raise ValueError in dagrun.py to fix static check - Make all '..' checks conditional on allow_dotdot_in_ids config * refactor: rename allow_dotdot_in_ids to allow_double_dot_in_ids, bump version_added to 3.3.0
* fix: block path traversal via ".." in dag_id and run_id validate_key() and validate_run_id() allow ".." which can be used for path traversal when these values end up in log file paths. Reject any key or run_id containing ".." early in validation. Closes: apache#63295 * Add newsfragment for breaking change * fix: add config flag allow_dotdot_in_ids and fix path traversal check in create_dagrun - Add [core] allow_dotdot_in_ids config flag (default: False) so existing users with '..' in their IDs can opt out of the blocking behavior - Add '..' check in SerializedDAG.create_dagrun() before the regex check, fixing the test_dag_run_id_rejects_path_traversal failure where create_dagrun raised a regex mismatch error before the traversal check - Collapse multi-line raise ValueError in dagrun.py to fix static check - Make all '..' checks conditional on allow_dotdot_in_ids config * refactor: rename allow_dotdot_in_ids to allow_double_dot_in_ids, bump version_added to 3.3.0
apache#63296 added a check that blocks `..` in IDs to prevent path traversal in airflow.utils.helpers.validate_key, gated by [core] allow_double_dot_in_ids. Dag and task authoring now use the Task SDK validate_key, which never got that check, so IDs like a..b are accepted even when the flag is off. Add the same check to the Task SDK validator so the two validators agree.
Problem
validate_key()andvalidate_run_id()both allow..in their values. Sincedag_idandrun_idare used in log file paths (e.g.dag_id=.../run_id=.../), a crafted value containing..could theoretically traverse outside the intended log directory.Root Cause
KEY_REGEX(^[\w.-]+$) matches..as valid consecutive dots.validate_run_iduses a configurableallowed_run_id_patternthat could also permit... Neither function checks for path traversal sequences.Fix
Added an explicit
..check in bothvalidate_key()(raisesAirflowException) andvalidate_run_id()(raisesValueError) before any other validation. Added corresponding unit tests for both functions.Closes: #63295
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines