Skip to content

Add Attack Surface Analyzer test in Windows container to Windows packaging workflow for x64/stable#26246

Closed
Copilot wants to merge 34 commits into
masterfrom
copilot/add-attack-surface-analyzer-test
Closed

Add Attack Surface Analyzer test in Windows container to Windows packaging workflow for x64/stable#26246
Copilot wants to merge 34 commits into
masterfrom
copilot/add-attack-surface-analyzer-test

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 19, 2025

Summary

This PR adds Microsoft's Attack Surface Analyzer (ASA) as a security test to the Windows packaging workflow. ASA helps identify potential security vulnerabilities and unexpected system changes introduced during PowerShell package installation.

ASA runs in a clean Windows container for the x64/stable matrix configuration only to eliminate noise from pre-installed PowerShell 7, build/packaging/testing activities, and other running tasks on the GitHub Actions runner.

Changes

Modified .github/workflows/windows-packaging-reusable.yml to integrate Attack Surface Analyzer testing using Windows containers:

  1. Added x64/stable matrix configuration - New matrix entry with runASA: true flag
  2. Build MSI on Host - Runs Invoke-CIFinish on the normal GitHub Actions runner to build packages
  3. Container-Based ASA Testing - Launches a clean Windows container (mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022) to run ASA:
    • Installs Attack Surface Analyzer .NET global tool (pinned to version 2.3.328) in container
    • Takes baseline snapshot of clean container state (no pre-installed PowerShell)
    • Installs only the PowerShell MSI in container (no build/packaging/testing noise)
    • Takes post-installation snapshot
    • Exports comparison results with SARIF format
    • Copies results back to host for artifact upload
  4. Upload Results - Uploads ASA output files (summary, detailed results, SARIF, database, and install log) as artifacts for later analysis
  5. Conditional Execution - All ASA steps include if: matrix.runASA == true condition to skip execution for all other matrix configurations

Modified .github/actions/infrastructure/path-filters/action.yml:

  • Added .github/workflows/windows-packaging-reusable.yml to the packagingChanged filter

How It Works

Attack Surface Analyzer performs a differential analysis in an isolated Windows container by:

  • Launching a clean Windows Server Core container with .NET SDK 9.0
  • Installing ASA and taking a baseline snapshot (clean container, no PowerShell installed)
  • Installing the PowerShell MSI that was built on the host
  • Taking a post-installation snapshot
  • Comparing the snapshots to identify changes to:
    • File system (PowerShell installation directories)
    • Registry
    • Services
    • Network ports
    • User accounts
    • Windows event logs
  • Uploading all analysis results as GitHub Actions artifacts

This container-based approach eliminates noise from:

  • Pre-installed PowerShell 7 on GitHub Actions runners
  • Build, packaging, and testing processes
  • Other running tasks and processes on the host

The MSI is built on the normal GitHub Actions runner where all build tools are available, then copied into a clean container for isolated testing.

Performance Optimizations

To ensure fast execution and reduce noise, ASA is configured with:

  • Container Isolation: Runs in clean mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022 container without pre-installed PowerShell
  • Single Configuration: Only runs for x64/stable matrix configuration (skips x64/preview, x86/stable, x86/preview, arm64/preview)
  • Targeted Collectors: Only uses collectors relevant to package installation (File, Service, Registry, User, Port, EventLog)
  • Limited Filesystem Scanning: Scans only PowerShell installation directories (C:\Program Files\PowerShell and C:\Program Files (x86)\PowerShell)
  • Excluded Collectors: Skips slow collectors not relevant to package testing (WiFi, TPM, Cryptographic Keys, Firewall, COM, Certificates)
  • Process Isolation: Uses --isolation process for better performance on Windows runners

Benefits

  • Enhanced Security: Automatically detects unexpected system changes during package installation
  • Early Detection: Identifies potential security issues before packages are released
  • Clean Baseline: Container provides pristine Windows environment without pre-installed software
  • No Build Noise: Eliminates false positives from build, packaging, and testing processes
  • Isolated Testing: Container isolation ensures only MSI installation changes are captured
  • Compliance: Provides audit trail of system changes for security reviews
  • CI Integration: Runs automatically as part of the packaging workflow
  • Reproducible: Version pinned to 2.3.328 and uses specific container image for consistent behavior
  • Fast Execution: Optimized collector configuration and container isolation reduces execution time
  • Analysis Ready: All results uploaded as artifacts including install logs for troubleshooting

Matrix Configuration

ASA execution status by configuration:

  • x64/stable - ASA enabled in Windows container (newly added)
  • ❌ x64/preview - ASA disabled
  • ❌ x86/stable - ASA disabled
  • ❌ x86/preview - ASA disabled
  • ❌ arm64/preview - ASA disabled

Testing

  • YAML syntax validated with yamllint
  • CodeQL security analysis passed with no vulnerabilities
  • Implementation follows GitHub Actions best practices
  • Path filters updated to ensure the workflow triggers correctly on changes
  • Container-based approach tested with volume mounts and PowerShell script execution

References

Original prompt

Add @microsoft/AttackSurfaceAnalyzer as a test to the windows package github workflow


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copilot AI changed the title [WIP] Add AttackSurfaceAnalyzer to Windows package GitHub workflow Add Attack Surface Analyzer test to Windows packaging workflow Oct 19, 2025
Copilot AI requested a review from TravisEz13 October 19, 2025 19:18
Comment thread .github/workflows/windows-packaging-reusable.yml Outdated
…alls MSI

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copilot AI requested a review from TravisEz13 October 19, 2025 19:26
@TravisEz13 TravisEz13 marked this pull request as ready for review October 19, 2025 19:33
@TravisEz13 TravisEz13 requested review from a team and jshigetomi as code owners October 19, 2025 19:33
Copilot AI review requested due to automatic review settings October 19, 2025 19:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 integrates Microsoft's Attack Surface Analyzer (ASA) into the Windows packaging workflow to perform security testing by detecting system changes during PowerShell package installation.

  • Adds ASA as a .NET global tool to capture system state before and after package building/testing
  • Implements differential analysis to identify security-relevant system changes
  • Leverages existing MSI installation from packaging tests to avoid redundant installations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread .github/workflows/windows-packaging-reusable.yml Outdated
Comment thread .github/workflows/windows-packaging-reusable.yml Outdated
Comment thread .github/workflows/windows-packaging-reusable.yml Outdated
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copilot AI requested a review from TravisEz13 October 20, 2025 18:23
@TravisEz13 TravisEz13 added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Oct 20, 2025
@TravisEz13
Copy link
Copy Markdown
Member

@copilot TravisEz13 reviewed .github/workflows/windows-packaging-reusable.yml
suggestion

dotnet tool install -g Microsoft.CST.AttackSurfaceAnalyzer.CLI --version 2.4.176

Pin the version.
If possible, pin in a way that dependabot can open PRs to update the version.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Oct 31, 2025
@TravisEz13
Copy link
Copy Markdown
Member

@copilot This is working but it is too noisy because ASA is running, 1 - against the build, packaging, and testing of the MSI, 2 - on a machine with the MSI already installed. Can we use a windows container that doesn't use the powershell MSI, such as mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022, to run the ASA, just install the MSI, and record the final snapshot and generate the reports? But still build on the normal agent.

Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 3, 2025

@copilot This is working but it is too noisy because ASA is running, 1 - against the build, packaging, and testing of the MSI, 2 - on a machine with the MSI already installed. Can we use a windows c...

Implemented Windows container-based ASA testing. The workflow now:

  1. Builds MSI on the normal agent
  2. Runs ASA in a clean mcr.microsoft.com/dotnet/sdk:9.0-windowsservercore-ltsc2022 container
  3. Takes baseline snapshot in clean container (no pre-installed PowerShell)
  4. Installs only the MSI in the container
  5. Takes post-install snapshot and generates reports
  6. Copies results back to host for artifact upload

This eliminates noise from build/packaging/testing and pre-installed PowerShell. (commit: will follow)

@microsoft-github-policy-service microsoft-github-policy-service Bot removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Nov 3, 2025
Copilot AI changed the title Add Attack Surface Analyzer test to Windows packaging workflow for x64/stable Add Attack Surface Analyzer test in Windows container to Windows packaging workflow for x64/stable Nov 3, 2025
…pdate scripts to use the static Dockerfile for building the Attack Surface Analyzer container.
…ild for optimized result extraction in Run-AttackSurfaceAnalyzer.ps1
…Dockerfile: standardize SARIF file naming and improve logging for file operations
Comment thread .github/workflows/windows-packaging-reusable.yml Outdated
Comment thread .github/workflows/windows-packaging-reusable.yml Outdated
@TravisEz13
Copy link
Copy Markdown
Member

replaced by #26379

@TravisEz13 TravisEz13 closed this Nov 4, 2025
@jshigetomi jshigetomi deleted the copilot/add-attack-surface-analyzer-test branch April 21, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants