Skip to content

Fixing path traversal/arbitrary out-of-directory file read via sharde…#14182

Open
buffett0323 wants to merge 3 commits into
huggingface:mainfrom
buffett0323:fix/shard-weight-map-path-traversal
Open

Fixing path traversal/arbitrary out-of-directory file read via sharde…#14182
buffett0323 wants to merge 3 commits into
huggingface:mainfrom
buffett0323:fix/shard-weight-map-path-traversal

Conversation

@buffett0323

Copy link
Copy Markdown

What does this PR do?

Fixes a path-traversal vulnerability in sharded-checkpoint loading. Validate every shard filename right after parsing the index by rejecting any value where os.path.basename(f) != f. This can reject absolute paths, ../ traversal, and subdirectory components in one guard.

Fixes #14175

Before submitting

Who can review?

@yiyixuxu @DN6 @sayakpaul

@sayakpaul sayakpaul requested a review from DN6 July 14, 2026 03:32
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path traversal / arbitrary out-of-directory file read via sharded-checkpoint weight_map in _get_checkpoint_shard_files

3 participants