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. 57: Arbitrary file access during archive extraction ("Zip Slip") #4604

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

kevwan
Copy link
Contributor

@kevwan kevwan commented Jan 25, 2025

Potential fix for https://github.com/zeromicro/go-zero/security/code-scanning/57

To fix the problem, we need to ensure that the file paths extracted from the zip archive do not contain any directory traversal elements (e.g., ..). This can be done by validating the file paths before using them in file system operations.

  1. Modify the fileCopy function to check for directory traversal elements in the file paths.
  2. Ensure that the destination path is within the intended directory.

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

…uring archive extraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@kevwan kevwan marked this pull request as ready for review January 25, 2025 16:42
@kevwan kevwan requested a review from kesonan January 25, 2025 16:44
Copy link
Collaborator

@kesonan kesonan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevwan kevwan added this pull request to the merge queue Jan 27, 2025
Merged via the queue into master with commit c71829c Jan 27, 2025
5 checks passed
@kevwan kevwan deleted the alert-autofix-57 branch January 27, 2025 03:53
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