fix: Secure tar archive extraction#15811
Open
chtruong814 wants to merge 2 commits into
Open
Conversation
8e66b10 to
f252b13
Compare
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
f252b13 to
a6b1957
Compare
Collaborator
Author
|
/ok to test a6b1957 |
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
Collaborator
Author
|
/ok to test 53c721a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do ?
Adds a shared safe tar extraction helper and replaces raw tar extraction in model, notebook, test-data, and dataset-processing paths to prevent path traversal when unpacking archives. It also validates
save_artifacts()artifact paths before extract/copy/rename and sanitizes ASR tokenizer rename targets so raw archive metadata cannot move files outside the intended output directory.Changelog
nemo.utils.tar_utils.safe_extract, which rejects absolute paths,..traversal, symlinks, and hardlinks by default.SaveRestoreConnector._safe_extract()through the shared helper while preserving its legacy skip-and-warn behavior withskip_unsafe=True.tar.extract()/tar.extractall()usage across affected model utilities, notebook dataset download, test-data setup, dataset-processing scripts, and the torchaudio conversion script.save_artifacts()artifact paths before constructing extract, copy, or rename paths.os.rename().Verification
MPLCONFIGDIR=.pytest_cache/matplotlib UV_CACHE_DIR=.uv-cache uv run pytest tests/utils/test_tar_utils.py -vtests/core/test_save_restore.pysave/restore compatibility casesUV_CACHE_DIR=.uv-cache uv run isort --check <changed files>UV_CACHE_DIR=.uv-cache uv run --with black==24.10.0 black --check <changed files>rg -n "tar\\.extract(all)?\\(" nemo tests scripts