Skip to content

quote remote job paths in posix ssh command builders#70091

Open
Samin061 wants to merge 1 commit into
apache:mainfrom
Samin061:posix-path-quoting
Open

quote remote job paths in posix ssh command builders#70091
Samin061 wants to merge 1 commit into
apache:mainfrom
Samin061:posix-path-quoting

Conversation

@Samin061

Copy link
Copy Markdown
Contributor

The POSIX builders in remote_job.py interpolate RemoteJobPaths values into single-quoted shell words without escaping, so a single quote anywhere in remote_base_dir closes the quote and the rest of the value is parsed as commands that run on the remote host as the SSH connection user. remote_base_dir is a template field, but _validate_base_dir runs in __init__ against the un-rendered Jinja literal and never looks for shell metacharacters, so a value like {{ dag_run.conf['dir'] }} reaches the shell unchecked and someone who can only trigger a Dag run with config gets a shell on the target host. Quoting with shlex.quote at each site matches what the Windows builders already do via ps_escape.

All six POSIX builders are affected. The _validate_job_dir prefix check on cleanup does not help, since a base dir that starts with /tmp/airflow-ssh-jobs/ and then contains a quote still passes it:

base_dir = "/tmp/airflow-ssh-jobs/x'; touch /tmp/pwned; :'"
build_posix_cleanup_command(paths.job_dir)
# rm -rf '/tmp/airflow-ssh-jobs/x'; touch /tmp/pwned; :'/job_123'

Added a parametrized regression that runs each builder's output through sh and asserts the injected marker is never created; it fails on all six before this change.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code (Opus 4.8) following the guidelines

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:ssh ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants