Skip to content

Potential fix for code scanning alert no. 703: Arbitrary file write during tarfile extraction #2586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025

Conversation

beat-buesser
Copy link
Collaborator

Potential fix for https://github.com/Trusted-AI/adversarial-robustness-toolbox/security/code-scanning/703

To fix the problem, we need to ensure that the paths within the tar archive do not contain any directory traversal elements (..). This can be achieved by validating each entry in the tar archive before extracting it. Specifically, we should check that the entry name is not an absolute path and does not contain any .. elements.

  1. Modify the _extract function to include validation for each entry in the tar archive.
  2. Raise an error if any entry is found to be unsafe.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…uring tarfile extraction

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@beat-buesser beat-buesser self-assigned this Feb 28, 2025
@beat-buesser beat-buesser changed the base branch from main to dev_1.19.2 February 28, 2025 08:59
@beat-buesser beat-buesser added this to the ART 1.19.2 milestone Feb 28, 2025
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.40%. Comparing base (8c1214e) to head (4df299d).
Report is 4 commits behind head on dev_1.19.2.

Files with missing lines Patch % Lines
art/utils.py 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff               @@
##           dev_1.19.2    #2586      +/-   ##
==============================================
- Coverage       85.41%   85.40%   -0.02%     
==============================================
  Files             334      334              
  Lines           31002    31005       +3     
  Branches         5300     5302       +2     
==============================================
- Hits            26481    26479       -2     
- Misses           3053     3056       +3     
- Partials         1468     1470       +2     
Files with missing lines Coverage Δ
art/utils.py 79.38% <33.33%> (-0.20%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Beat Buesser <beat.buesser@ibm.com>
Signed-off-by: Beat Buesser <beat.buesser@ibm.com>
@beat-buesser beat-buesser marked this pull request as ready for review May 21, 2025 14:01
@beat-buesser beat-buesser merged commit 512e08c into dev_1.19.2 May 21, 2025
34 of 35 checks passed
@beat-buesser beat-buesser deleted the alert-autofix-703 branch May 21, 2025 16:49
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.

1 participant