Skip to content

Make Zip Slip guard CodeQL-visible for cs/zipslip - #39

Merged
cursor[bot] merged 1 commit into
developmentfrom
cursor/zipslip-codeql-guard-60dd
Aug 3, 2026
Merged

Make Zip Slip guard CodeQL-visible for cs/zipslip#39
cursor[bot] merged 1 commit into
developmentfrom
cursor/zipslip-codeql-guard-60dd

Conversation

@Narehood

@Narehood Narehood commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

The Zip Slip CodeQL alert (cs/zipslip #1) stayed open after PR #38 because the custom ArchivePath helper was not recognized as a sanitizer.

Change

Align extraction with the CodeQL-recommended pattern:

  1. Path.GetFullPath(Path.Combine(dest, entryName))
  2. Path.GetFullPath(dest + DirectorySeparatorChar)
  3. StartsWith guard before any Directory.CreateDirectory / File.Create

Applied inline in ArchiveIterator.ExtractAllContents (dominates the filesystem sinks) and mirrored in ArchivePath.GetSafeExtractPath.

Validation

  • dotnet test … --filter ArchivePathTests — 8 passed
  • Prior Zip Slip hardening (unique temp extract dirs, leaf-name update unzip) unchanged

Follow-up

After merge + CodeQL on development, confirm alert #1 closes, then publish the shell release.

Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Improved archive extraction safeguards to prevent files from being written outside the selected destination.
    • Archive entries using traversal or rooted paths are now rejected with a clear error.
    • Strengthened path validation across supported platforms.

Inline the cs/zipslip recommended GetFullPath + StartsWith check in
ExtractAllContents, and align ArchivePath.GetSafeExtractPath with the
same pattern so CodeQL can clear the open alert.

Co-authored-by: Michael <Narehood@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c9cdd793-aba6-478a-9221-15000922504b

📥 Commits

Reviewing files that changed from the base of the PR and between 6a98c38 and 6fd8cd9.

📒 Files selected for processing (3)
  • XenCenterLib.Tests/ArchivePathTests.cs
  • XenCenterLib/Archive/ArchiveIterator.cs
  • XenCenterLib/Archive/ArchivePath.cs

📝 Walkthrough

Walkthrough

Archive extraction now canonicalizes destination paths and rejects traversal attempts. File creation uses the validated path. The path traversal test data removes the Windows-style case.

Changes

Archive path security

Layer / File(s) Summary
Canonical extraction path validation
XenCenterLib/Archive/ArchivePath.cs
GetSafeExtractPath now canonicalizes combined paths and checks the canonical destination prefix.
Validated archive extraction
XenCenterLib/Archive/ArchiveIterator.cs
ExtractAllContents validates each entry, throws InvalidDataException for escaping paths, and creates files using the validated path.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ArchiveIterator
  participant ArchivePath
  participant FileSystem
  ArchiveIterator->>ArchivePath: Validate canonical entry path
  ArchivePath-->>ArchiveIterator: Return validated path or InvalidDataException
  ArchiveIterator->>FileSystem: Create file at validated path
Loading

Suggested reviewers: cursoragent

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/zipslip-codeql-guard-60dd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor
cursor Bot marked this pull request as ready for review August 3, 2026 14:28
@cursor
cursor Bot merged commit 4660f78 into development Aug 3, 2026
6 checks passed
@cursor
cursor Bot deleted the cursor/zipslip-codeql-guard-60dd branch August 3, 2026 14:28
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