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

Fix code scanning alert no. 7: Arbitrary file access during archive extraction ("Zip Slip") #3250

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

hazendaz
Copy link
Member

Fixes https://github.com/mybatis/mybatis-3/security/code-scanning/7

To fix the problem, we need to ensure that the paths extracted from the JAR entries are validated to prevent directory traversal attacks. This can be done by normalizing the paths and ensuring they remain within the intended directory.

  1. Normalize the path: Convert the path to its canonical form to resolve any .. sequences.
  2. Check the path: Ensure that the normalized path starts with the intended base directory path.

We will implement these changes in the listResources method where the JAR entries are processed.

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

…xtraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@hazendaz hazendaz marked this pull request as ready for review September 26, 2024 00:03
@hazendaz hazendaz merged commit 45953df into master Sep 26, 2024
33 checks passed
@hazendaz hazendaz self-assigned this Sep 26, 2024
@coveralls
Copy link

Coverage Status

coverage: 87.113% (-0.05%) from 87.162%
when pulling ec07133 on autofix/alert-7-b48d877adc
into 7194767 on master.

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.

2 participants