Harden CLI archive extraction in dotnet-tool packing
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
Follow-up from PR #16496 review: https://github.com/microsoft/aspire/pull/16496#discussion_r3157783041
The dotnet-tool packing target in `eng/clipack/Common.projitems` extracts the native CLI archive using command-line strings that interpolate MSBuild paths inside single quotes:
- `Expand-Archive -LiteralPath '$(_CliArchivePath)' -DestinationPath '$(_NativeBinaryArchiveExtractionDir)' -Force`\n- `tar -xzf '$(_CliArchivePath)' -C '$(_NativeBinaryArchiveExtractionDir)'`\n\nIf either generated path ever contains a single quote, the shell command can break. The current CI paths are controlled and do not hit this, but the extraction should be hardened so path quoting is robust.\n\nPossible approaches:\n\n1. Use an MSBuild/managed unzip task for the Windows zip path instead of `Expand-Archive` command composition.\n2. Escape shell arguments correctly for the tar path, or replace the tar invocation with a managed extraction path if practical.\n3. Add coverage or validation for archive paths containing quote characters if the chosen approach supports it.\n
Contributor guide
Assessment
This issue has not been assessed yet.