Skip to content

Validate GCSToSambaOperator destination path stays within destination_path#67857

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:samba-gcs-to-smb-destination-path-containment
Jun 2, 2026
Merged

Validate GCSToSambaOperator destination path stays within destination_path#67857
potiuk merged 1 commit into
apache:mainfrom
potiuk:samba-gcs-to-smb-destination-path-containment

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented Jun 1, 2026

GCS object names are read from the source bucket and may contain .. path segments. GCSToSambaOperator._resolve_destination_path joined the object name onto the configured destination_path without normalisation, so a crafted object name (e.g. ../../elsewhere/file) could resolve an SMB write target outside the intended directory.

This normalises the resolved path and raises AirflowException when it would fall outside destination_path, so transfers always write within the configured destination.

Tests

  • test_resolve_destination_path_rejects_traversal.. object names raise
  • test_resolve_destination_path_allows_contained_object — normal objects still resolve under destination_path
  • existing operator tests unchanged (25 passed)
Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.8 (1M context)

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

Comment thread providers/samba/src/airflow/providers/samba/transfers/gcs_to_samba.py Outdated
Comment thread scripts/ci/prek/known_airflow_exceptions.txt Outdated
Copy link
Copy Markdown
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

Approving to un-block assuming you consider notes.

…_path

GCS object names are read from the source bucket and may contain ".."
segments. GCSToSambaOperator._resolve_destination_path joined the object
name onto the configured destination_path without normalisation, so a
crafted object name could resolve an SMB write target outside the intended
directory. Normalise the resolved path and refuse to write when it falls
outside destination_path.

Generated-by: Claude Opus 4.8 (1M context)
@potiuk potiuk force-pushed the samba-gcs-to-smb-destination-path-containment branch from 637871e to 4bbaa5b Compare June 2, 2026 17:20
@potiuk potiuk merged commit bc1df02 into apache:main Jun 2, 2026
92 checks passed
@potiuk potiuk deleted the samba-gcs-to-smb-destination-path-containment branch June 2, 2026 18:08
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

Backport successfully created: v3-2-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test PR Link

@jscheffl jscheffl removed the backport-to-v3-2-test Mark PR with this label to backport to v3-2-test branch label Jun 2, 2026
@jscheffl
Copy link
Copy Markdown
Contributor

jscheffl commented Jun 2, 2026

I assume no backport needed---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants