Skip to content

Fix destination path validation in GCS-to-SFTP transfers - #74186

Merged
potiuk merged 1 commit into
apache:mainfrom
drewrukin:fix/air-20261004-12-sftp-relative-base
Oct 5, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
drewrukin:fix/air-20261004-12-sftp-relative-base

Conversation

@drewrukin

Copy link
Copy Markdown
Contributor

Configured destinations such as ../shared currently reject valid uploads because parent components in the base path are treated as an escape. Compare normalized remote POSIX paths relative to the configured base while continuing to reject paths outside it.

Add regression tests for valid parent-relative destinations and rejection of paths outside the configured base.


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-6)

Generated-by: Codex (GPT-6) following the guidelines

Check GCS-to-SFTP destination containment relative to the normalized remote base. Allow configured parent-relative destinations while retaining rejection of paths outside that base.
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Oct 4, 2026
@drewrukin
drewrukin marked this pull request as ready for review October 4, 2026 12:19
@drewrukin
drewrukin requested a review from shahar1 as a code owner October 4, 2026 12:19

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Since this relaxes the destination-path check added in #67667, I checked that its security properties still hold.

The trusted input is destination_path, set by the Dag author. The untrusted input is the GCS object name, written by whoever can write to the bucket. The new check normalises both, requires the result to be inside the base (PurePosixPath.relative_to), and treats any remaining .. as an escape. So every object-name escape is still refused:

  • ../x under dir, and ../../x under ..;
  • .. under the login directory (.);
  • an absolute object name under a relative base;
  • a look-alike sibling (../shared-other/... when the base is ../shared), because paths are compared part by part, not as string prefixes.

The only behaviour change is on the trusted side: a configured base with parent components, such as ../shared, now works as intended. As before, the check is lexical, so symlinks on the remote SFTP server are out of scope, as they were for #67667.


Drafted-by: Claude Code (Opus 5.5); reviewed by @potiuk before posting

@potiuk
potiuk merged commit bfe8459 into apache:main Oct 5, 2026
168 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants