Skip to content

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

Closed
myworkside wants to merge 22 commits into
mainfrom
alert-autofix-1
Closed

Potential fix for code scanning alert no. 1: Arbitrary file access during archive extraction ("Zip Slip")#2
myworkside wants to merge 22 commits into
mainfrom
alert-autofix-1

Conversation

@myworkside

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/myworkside/UniversalFileEditorViewer/security/code-scanning/1

To fix this safely, validate the destination path after resolving it and normalizing/canonicalizing, and ensure it stays inside targetDir before writing. Do this for both ZIP and RAR branches, right where outFile is created (lines around 63 and 74).

Best approach here without changing functionality:

  1. Keep current filename behavior (basename extraction), so output naming remains unchanged.
  2. Add a private helper in ArchiveRepository:
    • Build canonical targetDir.
    • Resolve child file from requested name.
    • Canonicalize child file.
    • Verify child.toPath().startsWith(targetDir.toPath()).
    • Throw SecurityException if invalid.
  3. Replace direct File(targetDir, ...) creation in both extraction branches with this helper.
  4. No new dependency is needed.

This keeps behavior intact while adding robust containment validation required to prevent Zip Slip style path abuse.

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

Your Name and others added 22 commits June 11, 2026 09:26
Added comprehensive documentation for the Universal File Editor & Viewer application, detailing features, technology stack, project structure, installation instructions, development guide, common issues, roadmap, contributing guidelines, and licensing.
Added Instagram support link for updates and support.
Bumps the gradle group with 2 updates in the / directory: org.apache.poi:poi-ooxml and [com.github.junrar:junrar](https://github.com/junrar/junrar).


Updates `org.apache.poi:poi-ooxml` from 5.2.5 to 5.5.1

Updates `com.github.junrar:junrar` from 7.5.5 to 7.5.10
- [Release notes](https://github.com/junrar/junrar/releases)
- [Changelog](https://github.com/junrar/junrar/blob/master/CHANGELOG.md)
- [Commits](junrar/junrar@v7.5.5...v7.5.10)

---
updated-dependencies:
- dependency-name: org.apache.poi:poi-ooxml
  dependency-version: 5.5.1
  dependency-type: direct:production
  dependency-group: gradle
- dependency-name: com.github.junrar:junrar
  dependency-version: 7.5.10
  dependency-type: direct:production
  dependency-group: gradle
...

Signed-off-by: dependabot[bot] <support@github.com>
Removed link for LATEST V2.0 APK download from README.
…56a3

Bump the gradle group across 1 directory with 2 updates
…ring archive extraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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