Repository navigation
[release/8.0] Remove unused artifact package extractor - #17332
Conversation
Canonicalize package and archive entry destinations before extraction, reject paths outside their configured roots, and add regression coverage for traversal, absolute paths, separator variants, prefix confusion, and malicious package names. Co-authored-by: Copilot <[email protected]> Copilot-Session: e890b71a-c1aa-416c-a15c-be8da9fdd9b4
There was a problem hiding this comment.
Pull request overview
This PR hardens Arcade’s artifact package extraction to prevent writing files outside the intended extraction root by canonicalizing and validating both package extraction roots and individual archive entry destinations prior to extraction, and adds regression coverage in PR validation.
Changes:
- Introduces
Get-ValidatedArchiveEntryPathto canonicalize and validate extraction targets and reject unsafe archive entry paths. - Updates
extract-artifact-packages.ps1to validate the full archive before extracting any relevant files and to use the new helper for both package root and entry paths. - Adds a focused PowerShell regression test and runs it in the Windows PR pipeline.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/PowerShell/archive-extraction-path.Tests.ps1 | Adds regression tests covering traversal/absolute/mixed-separator cases and validates “reject before extract” behavior. |
| eng/common/sdl/extract-artifact-packages.ps1 | Uses validated paths for package/entry extraction and validates all entries before extracting relevant ones. |
| eng/common/sdl/archive-extraction-path.ps1 | Adds central path canonicalization/validation helper for safe extraction. |
| azure-pipelines-pr.yml | Runs the new PowerShell regression test in the Windows PR job. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Reject NTFS alternate data streams, use a portable package file filter, add platform-specific regression coverage, and exempt the pure path helper from the eng/common telemetry-output check. Co-authored-by: Copilot <[email protected]> Copilot-Session: e890b71a-c1aa-416c-a15c-be8da9fdd9b4
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
tests/PowerShell/archive-extraction-path.Tests.ps1:6
Join-Pathis being given Windows-style\segments ('..\..','eng\common\...'). On non-Windows PowerShell, backslash is a valid filename character (not a separator), so these resolve to incorrect paths and the test won’t run cross-platform.
$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
$ArchivePathHelper = Join-Path $RepoRoot 'eng\common\sdl\archive-extraction-path.ps1'
$Extractor = Join-Path $RepoRoot 'eng\common\sdl\extract-artifact-packages.ps1'
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (3)
tests/PowerShell/archive-extraction-path.Tests.ps1:6
- The test builds repo-relative paths using Windows-style
\separators (and..\..), which will break if this script is run on non-Windows PowerShell because backslashes are treated as literal filename characters. Use portable../..and forward-slash child paths (or Join-Path per segment) so the test can run cross-platform.
$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..\..'))
$ArchivePathHelper = Join-Path $RepoRoot 'eng\common\sdl\archive-extraction-path.ps1'
$Extractor = Join-Path $RepoRoot 'eng\common\sdl\extract-artifact-packages.ps1'
eng/common/sdl/extract-artifact-packages.ps1:30
ExtractArtifactswaits/receives background jobs but never removes them. If this function runs multiple times in a long-lived PowerShell session, completed jobs accumulate and can consume resources. Wrap the wait/receive in atry/finallyandRemove-Jobthe job objects.
Wait-Job -Job $Jobs | Out-Null
foreach ($Job in $Jobs) {
Receive-Job -Job $Job -ErrorAction Stop
}
tests/PowerShell/archive-extraction-path.Tests.ps1:172
- The "malicious package name" regression case assumes
...nupkgis unsafe on all platforms, butGet-ValidatedArchiveEntryPathhas no non-Windows-specific rejection for...and that name is typically safe on Unix filesystems. If the intent is to cover Windows path normalization/prefix-confusion behavior, gate this test to Windows to avoid a deterministic failure when run on non-Windows agents.
$InvalidPackageNameInput = Join-Path $TestRoot 'invalid-package-name-input'
$InvalidPackageNameOutput = Join-Path $TestRoot 'invalid-package-name-output'
[System.IO.Directory]::CreateDirectory($InvalidPackageNameInput) | Out-Null
New-TestPackage -Path (Join-Path $InvalidPackageNameInput '...nupkg') -EntryNames @(
'safe.dll'
)
$InvalidPackageNameRunOutput = & (Get-Process -Id $PID).Path -NoLogo -NoProfile `
-File $Extractor -InputPath $InvalidPackageNameInput -ExtractPath $InvalidPackageNameOutput 2>&1
if ($LASTEXITCODE -eq 0) {
throw "A package name resolving outside the extraction root should fail. Output: $($InvalidPackageNameRunOutput -join [Environment]::NewLine)"
}
if (Test-Path (Join-Path $TestRoot 'safe.dll')) {
throw 'A malicious package name created a file outside the extraction directory.'
}
Co-authored-by: Copilot <[email protected]> Copilot-Session: 80f6a0c6-7947-4200-bb78-7f0fc01d671a
…lip-8.0' into users/mjanecke/fix-archive-zip-slip-8.0
Summary
Extract Blob ArtifactsandExtract Package Artifactssteps from the legacy SDL job templateEvidence
3047362), Crank (3050085), install-scripts (3050277), and Sign (3050147) use the 1ESSDLSourcesstageRun SDL tool,Extract Blob Artifacts, orExtract Package ArtifactstasksValidation
Build.cmd -configuration ReleaseTracking: https://dev.azure.com/dnceng/internal/_workitems/edit/12199