Skip to content

[release/8.0] Remove unused artifact package extractor - #17332

Merged
missymessa merged 6 commits into
release/8.0from
users/mjanecke/fix-archive-zip-slip-8.0
Aug 20, 2026
Merged

missymessa merged 6 commits into
release/8.0from
users/mjanecke/fix-archive-zip-slip-8.0

Conversation

@missymessa

@missymessa missymessa commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • delete the unused custom artifact package extractor
  • remove its Extract Blob Artifacts and Extract Package Artifacts steps from the legacy SDL job template

Evidence

  • no remaining source references exist outside the legacy template
  • recent official main builds for dnceng-shared (3047362), Crank (3050085), install-scripts (3050277), and Sign (3050147) use the 1ES SDLSources stage
  • none of those generated Run SDL tool, Extract Blob Artifacts, or Extract Package Artifacts tasks
  • recent public main builds checked for the same repositories likewise did not generate those tasks

Validation

  • Build.cmd -configuration Release

Tracking: https://dev.azure.com/dnceng/internal/_workitems/edit/12199

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-ValidatedArchiveEntryPath to canonicalize and validate extraction targets and reject unsafe archive entry paths.
  • Updates extract-artifact-packages.ps1 to 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
Copilot AI review requested due to automatic review settings August 13, 2026 18:32
@missymessa
missymessa requested review from hoyosjs and mmitche August 13, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-Path is 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'

Copilot AI review requested due to automatic review settings August 13, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • ExtractArtifacts waits/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 a try/finally and Remove-Job the 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 ...nupkg is unsafe on all platforms, but Get-ValidatedArchiveEntryPath has 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.'
  }

@missymessa
missymessa enabled auto-merge (squash) August 13, 2026 19:31
Co-authored-by: Copilot <[email protected]>

Copilot-Session: 80f6a0c6-7947-4200-bb78-7f0fc01d671a
@missymessa missymessa changed the title [release/8.0] Reject unsafe package extraction paths [release/8.0] Remove unused artifact package extractor Aug 18, 2026
…lip-8.0' into users/mjanecke/fix-archive-zip-slip-8.0
Copilot AI review requested due to automatic review settings August 18, 2026 16:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@missymessa
missymessa merged commit a2796e8 into release/8.0 Aug 20, 2026
12 of 14 checks passed
@missymessa
missymessa deleted the users/mjanecke/fix-archive-zip-slip-8.0 branch August 20, 2026 15:17
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.

3 participants