Fix transitive MessagePack vulnerability in AI template AppHost projects#7561
Conversation
…rability (GHSA-hv8m-jj95-wg3x) The Aspire.Hosting.AppHost package transitively depends on MessagePack (via StreamJsonRpc). Version 13.0.0 pulled in MessagePack 2.5.192 which has a known high severity vulnerability. Updating to Aspire 13.4.3 resolves this by using a patched transitive dependency chain. Also updates CommunityToolkit.Aspire packages from 13.0.0-beta.444 to 13.4.0 (stable).
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot the CI keeps failing, have you run the tests locally?
Microsoft.Extensions.AI.Templates.Tests.AIChatWebExecutionTests.TestAllSupportedConfigurations
dotnet restore
Working Directory: D:\a_work\1\s\artifacts\ProjectTemplates\Microsoft.Extensions.AI.Templates\Sandbox\aichatweb\projects\AIChatWeb_oai_q_A_T_ID_F_net10\AIChatWeb_oai_q_A_T_ID_F_net10.AppHost
Local Shipping Path: D:\a_work\1\s\artifacts\packages\Release\Shipping
NuGet Packages Path: D:\a_work\1\s\artifacts\ProjectTemplates\Microsoft.Extensions.AI.Templates\Sandbox\packages
Command failed with non-zero exit code: 1
Standard Output:
Determining projects to restore...
Restored D:\a_work\1\s\artifacts\ProjectTemplates\Microsoft.Extensions.AI.Templates\Sandbox\aichatweb\projects\AIChatWeb_oai_q_A_T_ID_F_net10\AIChatWeb_oai_q_A_T_ID_F_net10.Web\AIChatWeb_oai_q_A_T_ID_F_net10.Web.csproj (in 575 ms).
Restored D:\a_work\1\s\artifacts\ProjectTemplates\Microsoft.Extensions.AI.Templates\Sandbox\aichatweb\projects\AIChatWeb_oai_q_A_T_ID_F_net10\AIChatWeb_oai_q_A_T_ID_F_net10.ServiceDefaults\AIChatWeb_oai_q_A_T_ID_F_net10.ServiceDefaults.csproj (in 575 ms).
D:\a_work\1\s\artifacts\ProjectTemplates\Microsoft.Extensions.AI.Templates\Sandbox\aichatweb\projects\AIChatWeb_oai_q_A_T_ID_F_net10\AIChatWeb_oai_q_A_T_ID_F_net10.AppHost\AIChatWeb_oai_q_A_T_ID_F_net10.AppHost.csproj : error NU1903: Warning As Error: Package 'MessagePack' 2.5.192 has a known high severity vulnerability, https://github.com/advisories/GHSA-hv8m-jj95-wg3x
Failed to restore D:\a_work\1\s\artifacts\ProjectTemplates\Microsoft.Extensions.AI.Templates\Sandbox\aichatweb\projects\AIChatWeb_oai_q_A_T_ID_F_net10\AIChatWeb_oai_q_A_T_ID_F_net10.AppHost\AIChatWeb_oai_q_A_T_ID_F_net10.AppHost.csproj (in 1.07 sec).
@copilot fix it, also post which package exactly depends on the vulnerable MessagePack
…ty warning The transitive dependency chain is: Aspire.Hosting.AppHost → Aspire.Hosting → StreamJsonRpc >= 2.22.23 → MessagePack >= 2.5.192 StreamJsonRpc 2.22.23 declares a floor of MessagePack 2.5.192 which is vulnerable (GHSA-hv8m-jj95-wg3x). Adding a direct PackageReference to MessagePack 2.5.301 forces NuGet to resolve the patched version.
The vulnerable
Fixed by adding a direct |
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot Since the first commit does not help at all, revert it.
Reverted the Aspire version bumps from the first commit. The PR now only contains the MessagePack 2.5.301 pin which is what actually fixes the NU1903 vulnerability. See commit |
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464515&view=codecoverage-tab |
adamsitnik
left a comment
There was a problem hiding this comment.
Merging to unblock the CI, will use microsoft/aspire#18204 once it's available.
There was a problem hiding this comment.
Pull request overview
This PR addresses a restore-blocking NU1903 vulnerability warning in template-generated AI AppHost projects by forcing NuGet to resolve a patched MessagePack version instead of the vulnerable transitive minimum pulled in via StreamJsonRpc.
Changes:
- Added
MessagePack2.5.301to the project-templates package version map (eng/packages/ProjectTemplates.props). - Pinned
MessagePackas a direct dependency in the AI Chat Web AppHost template to override the transitive resolution. - Updated AI template integration test snapshots to reflect the new
MessagePackpackage reference.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| eng/packages/ProjectTemplates.props | Defines MessagePack 2.5.301 for template version substitution. |
| src/ProjectTemplates/Microsoft.Extensions.AI.Templates/templates/AIChatWeb-CSharp/AIChatWeb-CSharp.AppHost/AIChatWeb-CSharp.AppHost.csproj-in | Adds a direct MessagePack PackageReference to pin a non-vulnerable version. |
| test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/aichatweb/aichatweb.o_q.verified/aichatweb/aichatweb.AppHost/aichatweb.AppHost.csproj | Snapshot updated to include MessagePack reference. |
| test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/aichatweb/aichatweb.A.verified/aichatweb/aichatweb.AppHost/aichatweb.AppHost.csproj | Snapshot updated to include MessagePack reference. |
| test/ProjectTemplates/Microsoft.Extensions.AI.Templates.IntegrationTests/Snapshots/aichatweb/aichatweb.A_aoai_aais.verified/aichatweb/aichatweb.AppHost/aichatweb.AppHost.csproj | Snapshot updated to include MessagePack reference. |
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1464769&view=codecoverage-tab |
Set SkipTests=true on Microsoft.Extensions.AI.Templates.Tests.csproj. The generated AppHost projects fail 'dotnet restore' with NU1903 because the transitive MessagePack 2.5.192 has a known vulnerability (GHSA-hv8m-jj95-wg3x). Tracked by #7562; fixed on main by #7561. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Set release branch to stable versioning * Skip AI.Templates integration tests in release branch Set SkipTests=true on Microsoft.Extensions.AI.Templates.Tests.csproj. The generated AppHost projects fail 'dotnet restore' with NU1903 because the transitive MessagePack 2.5.192 has a known vulnerability (GHSA-hv8m-jj95-wg3x). Tracked by #7562; fixed on main by #7561. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Template-generated AppHost projects fail restore with
NU1903becauseAspire.Hosting.AppHosttransitively pulls inMessagePack2.5.192 (viaStreamJsonRpc), which has a known high-severity vulnerability (GHSA-hv8m-jj95-wg3x).The transitive dependency chain is:
StreamJsonRpc2.22.23 declares a minimum floor of[2.5.192, )for MessagePack, so NuGet resolves exactly 2.5.192 unless overridden. Upgrading Aspire alone doesn't fix this.Changes
eng/packages/ProjectTemplates.props: AddedMessagePack2.5.301(patched version)AIChatWeb-CSharp.AppHost.csproj-in: Added directPackageReferencetoMessagePack2.5.301 to force NuGet to resolve the safe version over the vulnerable transitive minimumMessagePackreference in 3 verified snapshot.csprojfilesMicrosoft Reviewers: Open in CodeFlow
fixes #7562