Skip to content
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

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

Draft
wants to merge 1 commit into
base: dev_1.19.2
Choose a base branch
from

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.33%. Comparing base (8c1214e) to head (d07b536).

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.40%   85.33%   -0.07%     
==============================================
  Files             334      334              
  Lines           31002    31005       +3     
  Branches         5300     5302       +2     
==============================================
- Hits            26476    26457      -19     
- Misses           3056     3077      +21     
- Partials         1470     1471       +1     
Files with missing lines Coverage Δ
art/utils.py 79.38% <33.33%> (-0.20%) ⬇️

... and 2 files with indirect coverage changes

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