Skip to content

Potential fix for code scanning alert no. 1: Arbitrary file access during archive extraction ("Zip Slip") #1

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 1 commit into from
Jun 13, 2025

Conversation

mimz-devops
Copy link
Owner

Potential fix for https://github.com/mimz-devops/code-scanning-javascript-demo/security/code-scanning/1

To fix the issue, we need to validate header.linkname to ensure it does not contain directory traversal elements (..) or other malicious constructs before using it to construct srcpath. The best approach is to use a validation function that checks whether the resolved path remains within the intended root directory (cwd). This ensures that even if header.linkname contains malicious elements, they cannot escape the intended directory.

The fix involves:

  1. Adding a validation step for header.linkname before constructing srcpath.
  2. Using path.resolve to normalize the path and ensure it is within the cwd directory.
  3. Rejecting or skipping entries with invalid paths.

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

…ring archive extraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@mimz-devops mimz-devops marked this pull request as ready for review June 13, 2025 19:03
@mimz-devops mimz-devops merged commit fd45dcb into main Jun 13, 2025
2 checks passed
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