Skip to content

Fix s3 recursive download parent-dir escape guard missing bare '..' key - #10580

Open
Adityaj0 wants to merge 1 commit into
aws:developfrom
Adityaj0:fix/s3-recursive-download-bare-parent-dir-escape
Open

Fix s3 recursive download parent-dir escape guard missing bare '..' key#10580
Adityaj0 wants to merge 1 commit into
aws:developfrom
Adityaj0:fix/s3-recursive-download-bare-parent-dir-escape

Conversation

@Adityaj0

Copy link
Copy Markdown

Summary

Fixes #10579.

_warn_parent_reference (awscli/customizations/s3/s3handler.py), the guard that warns and skips S3 objects during aws s3 cp/aws s3 sync --recursive when their key would make the local destination escape the target directory, only matched keys that normalize to '../something'. Keys that normalize to exactly '..' (e.g. a legal S3 key like prefix/..) slipped past the check, bypassing the intended warning and causing an unhandled OS error (e.g. IsADirectoryError) during the download instead of a graceful skip.

Fix: also treat a normalized path of exactly '..' as escaping the destination.

escapes_cwd = normalized == '..' or normalized.startswith(parent_prefix)

Test plan

  • Added two unit tests to tests/unit/customizations/s3/test_s3handler.py:
    • test_warn_and_ignore_on_bare_parent_reference — key ..
    • test_warn_and_ignore_on_bare_parent_reference_with_prefix — key a/../..
    • Both fail (hang, since no warning is enqueued) against the pre-fix code, and pass after the fix.
  • Ran the full tests/unit/customizations/s3/test_s3handler.py suite: 64 passed, no regressions.
  • Added a changelog entry under .changes/next-release/.

🤖 Generated with Claude Code

_warn_parent_reference only detected S3 keys that normalize to
'../something', missing keys that normalize to exactly '..' (e.g. a
legal key like 'prefix/..'). Such keys bypassed the intended
warn-and-skip protection and crashed the download with an unhandled
OS error instead.

Fixes aws#10579
@Adityaj0
Adityaj0 requested a review from a team as a code owner August 18, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

s3 cp/sync --recursive: parent-directory-escape guard misses bare '..' key, causing unhandled crash

1 participant