[xabt] Validate extracted zip entry paths in ExtractJarsFromAar#11212
Merged
simonrozsival merged 1 commit intomainfrom Apr 28, 2026
Merged
[xabt] Validate extracted zip entry paths in ExtractJarsFromAar#11212simonrozsival merged 1 commit intomainfrom
ExtractJarsFromAar#11212simonrozsival merged 1 commit intomainfrom
Conversation
This is just for correctness; there's no security enforcement here. Add `IsUnderDirectory` check at both extraction points (jars and annotations) to silently skip zip entries whose resolved path escapes the target directory. Logs a debug message when an entry is skipped. Add `ExtractJarsFromAarTests` with cases for jar traversal, annotations traversal, and a valid jar entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds path validation when extracting jar and annotations entries from .aar archives to avoid writing files outside the intended output directories, and introduces tests covering traversal and non-traversal cases.
Changes:
- Added an
IsUnderDirectorycheck before extractingannotations.zipand*.jarentries to skip entries whose resolved path escapes the target directory. - Logged a debug message when an entry is skipped due to escaping the target directory.
- Added
ExtractJarsFromAarTestsfor jar traversal, annotations traversal, and a valid jar entry scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Tasks/ExtractJarsFromAar.cs |
Adds a helper to validate resolved extraction paths are under the intended output directories and skips invalid entries. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ExtractJarsFromAarTests.cs |
Introduces tests intended to validate traversal skipping and successful extraction behavior. |
simonrozsival
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is just for correctness; there's no security enforcement here.
Add
IsUnderDirectorycheck at both extraction points (jars and annotations) to silently skip zip entries whose resolved path escapes the target directory. Logs a debug message when an entry is skipped.Add
ExtractJarsFromAarTestswith cases for jar traversal, annotations traversal, and a valid jar entry.