SCANPY-181 Only use the the filter parameter of tarfile.extractall if supported#201
Merged
SCANPY-181 Only use the the filter parameter of tarfile.extractall if supported#201
Conversation
|
Seppli11
commented
May 26, 2025
| if sys.version_info >= (3, 12): | ||
| tar_ref.extractall(target_dir, filter="data") | ||
| else: | ||
| tar_ref.extractall(target_dir) |
Contributor
Author
There was a problem hiding this comment.
There is a security risk of tar bombs here.
I see two possible attacks:
- An attacker compromises the SQ server and sends a malicious tar
- Since checking the checksum of the tar and actually untarring it are done in separate steps, an attacker could change the content of the tar between the two steps. However, for this, an attacker would have to be able to execute arbitrary commands
Overall, the security risk seems low to me, but it is still a risk.
Link to the sonar security rule: https://next.sonarqube.com/sonarqube/security_hotspots?id=SonarSource_sonar-scanner-python&hotspots=9ec9486e-0271-4c5f-820f-b780ab5863d0&pullRequest=201
joke1196
approved these changes
May 27, 2025
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.




SCANPY-181
So far, pysonar has used the
filterparameter oftarfile.extractall(...), which was introduced in Python 3.12. However, the parameter was backported to 3.9.17, 3.10.12, 3.11.4, which all released on 06.06.2023. Because we used up to date Python versions, which had the backport, in our ITs, they didn't fail and we didn't notice.