Skip to content

After creating a Worker service project, "System.text.json" 8.0.0 was referenced and identified as a vulnerable package #105120

Description

@v-bennettyue

Repro steps

  1. dotnet new worker
  2. Open project in Visual Studio
  3. Right-client project > Manage NuGet Packages

Expected results

The project shouldn't have vulnerability warnings

Actual results

Check 'Show only vulnerable' checkbox, then you can see that the warning is because the following packages have a dependency on System.text.json 8.0.0, which has been detected as the vulnerable package

Original issue

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install Dev17.10.4 (Include Aspire 8.0.0) latest release build
    • Web workload

REPRO STEPS

  1. File > New project > .NET Aspire App Host > .NET 8.0 > Create
  2. Right-check project > Manage NuGet Packages

ACTUAL
Check 'Show only vulnerable' checkbox, then you can see that the warning is because the following packages have a dependency on System.text.json 8.0.0, which has been detected as the vulnerable package
Aspire.Hosting.AppHost "Version=" 8.0.0
image

NOTE:

  1. This issue can be repro in any aspire project or in a project with aspire
    This issue also repro on Dev17.10 + Aspire 8.0.2/8.1 and Dev17.11 + Aspire 8.0.2/8.1

EXPECTED
The packages should be updated to depend on a newer version of System.text.json that is not vulnerable.

Activity

  1. balachir commented on Jul 17, 2024

    @balachir

    @mitchdenny is this a known issue? Note that this also reproduces using Aspire 8.0, so this may not be a blocking issue for Aspire 8.1. But if it's a straight-forward dependency update, perhaps we should go ahead and get it done.

  2. eerhardt commented on Jul 18, 2024

    @eerhardt
    Member

    The System.Text.Json v8.0.0 dependency is coming from the following dependency graph:

    image

    @ericstj @eiriktsarpalis @ViktorHofer - are we planning on updating Microsoft.Extensions.Hosting to uplift the System.Text.Json dependency to a non-vulnerable version? I know in this case the NuGet package isn't going to be used (since the System.Text.Json used will come from the shared framework). But I would guess every Worker app will have this vulnerability warning now. I am able to repro it by just creating a Worker service project in VS. This makes me think this issue should be transfered to dotnet/runtime.

    Thoughts?

  3. eiriktsarpalis commented on Jul 18, 2024

    @eiriktsarpalis
    Member

    I would say this is a duplicate of #104669. The current policy is that we don't update because of transitive dependencies being vulnerable.

  4. ericstj commented on Jul 18, 2024

    @ericstj
    Member

    Correct, it will ship with updated dependencies if it has a reason to ship.

  5. eerhardt commented on Jul 18, 2024

    @eerhardt
    Member

    The current policy is that we don't update because of transitive dependencies being vulnerable.

    I agree with this policy from a library perspective - so we don't have an explosion of new versions of all libraries in the world that depend on System.Text.Json.

    However, from an application perspective we are causing an issue for any application using our templates. dotnet new worker is now setting off these kinds of vulnerability warnings due to a transitive dependency on the STJ 8.0.0 nuget package. Options to address this that I can see are:

    1. We do nothing and tell customers they are responsible for "fixing up" our templates so they don't get warnings.
    2. We teach the vulnerability warnings about package conflict resolution, so they don't warn about the 8.0.0 nuget package being referenced transitively when the real System.Text.Json assembly will be loaded from the shared framework.
    3. We are super stringent about TFM dependencies - in this case Microsoft.Extensions.Configuration.Json and Microsoft.Extensions.Logging.Console shouldn't have a nuget dependency on System.Text.Json for the net8.0 TFM. It should come from the TFM net8.0.
    4. We update a targeted set of packages that are used directly in applications - in this case Microsoft.Extensions.Hosting v8.0.1 gets shipped that "lifts up" the System.Text.Json version to a non-vulnerable one. That way I just need to reference the latest Microsoft.Extensions.Hosting version in my worker app, and I no longer get security alerts.
    5. We update our templates (ex. worker and aspire) to manually "lift up" the dependency to a non-vulnerable version.

    Of these options, I think (3) might be the best. I'm not sure if we could make that kind of change in a servicing release, but we should think about that policy going forward so we don't get into these kinds of situations in the future.

  6. transferred this issue frommicrosoft/aspireon Jul 18, 2024
  7. dotnet-policy-service commented on Jul 18, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
    See info in area-owners.md if you want to be subscribed.

  8. changed the title [-][WebToolsE2E] [Aspire] After creating an aspire project, "System.text.json" 8.0.0 was referenced and identified as a vulnerable package[/-] [+]After creating a Worker service project, "System.text.json" 8.0.0 was referenced and identified as a vulnerable package[/+] on Jul 18, 2024
  9. dotnet-policy-service commented on Jul 18, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-extensions-hosting
    See info in area-owners.md if you want to be subscribed.

  10. added this to the 9.0.0 milestone on Jul 19, 2024
  11. removed
    untriagedNew issue has not been triaged by the area owner
    on Jul 24, 2024
  12. steveharter commented on Jul 30, 2024

    @steveharter
    Contributor

    The proposed fix from @eerhardt is:

    We are super stringent about TFM dependencies - in this case Microsoft.Extensions.Configuration.Json and Microsoft.Extensions.Logging.Console shouldn't have a nuget dependency on System.Text.Json for the net8.0 TFM. It should come from the TFM net8.0.

    Thoughts @ericstj @eiriktsarpalis?

  13. ericstj commented on Jul 30, 2024

    @ericstj
    Member

    I think that's reasonable to avoid dependencies when they're present in the framework. I see that as a nice improvement to avoid package downloads.

  14. self-assigned this
    on Aug 6, 2024
  15. ericstj commented on Aug 8, 2024

    @ericstj
    Member

    So there's a complication here. If a package needs a reference for NETStandard2.0 we may not be able to remove the package reference for older .NET versions. Consider the following package shape:

    A (netstandard2.0) -> B (package - 9.0.0.0)
    A (net8.0) -> B (framework - 8.0.0.0 | package - 9.0.0.0)
    A (net9.0) -> B (framework - 9.0.0.0)

    We can't remove the package reference for net8.0 because that would cause a ref-def mismatch for folks compiling on netstandard2.0 then running on net8.0 - since net8.0 only contains the 8.0.0.0 version. Even if we're OK using the API that's in 8.0 when compiling for it, we must deliver the 9.0 assembly since that's what we expose on netstandard2.0.

    We can still remove the package reference for the current framework, but not past ones in this case.

  16. added
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 9, 2024
  17. v-elenafeng commented on Aug 19, 2024

    @v-elenafeng

    Hi @ericstj, just one question: where (on which build) can I verify the fix for this issue? With VS 17.12 P2 (contains 9.0 P7), I was able to repro this, should it be issue 3047?

  18. ericstj commented on Aug 19, 2024

    @ericstj
    Member

    We only made this change for net9.0 in RC1. If you are using targeting net9.0 and an RC1 build you should see the fix.

  19. v-elenafeng commented on Aug 20, 2024

    @v-elenafeng

    We only made this change for net9.0 in RC1. If you are using targeting net9.0 and an RC1 build you should see the fix.

    Thanks! With 9.0 RC1, the dependency has been removed. For 8.0 templates in VS 17.11 and below, the package warning is only shown when checking for vulnerable packages from the nuget package manager. For 8.0 templates in VS 17.12 (where the default SDK is 9.0), we're tracking an issue https://github.com/dotnet/AspNetCore-ManualTests/issues/3047

  20. ericstj commented on Sep 12, 2024

    @ericstj
    Member

    This change has been ported to 8.0 in #107161 and should ship in the next servicing release of .NET 8.0.

  21. v-reinawang commented on Sep 24, 2024

    @v-reinawang

    Verify that this issue has been fixed in SDK 8.0.403.

  22. chrarnoldus commented on Oct 14, 2024

    @chrarnoldus

    I have noticed that updating a reference to System.Data.OleDb from v8.0.0 to v8.0.1 in a WinForms project will now cause additional DLLs to be copied to the output folder, namely System.Configuration.ConfigurationManager.dll and a few others. (The new OleDb version is a result of the backport https://github.com/dotnet/runtime/pull/107161/files#diff-30298982b02597cb3012558d2f74db967ea32ef46132610ba0fd030fe62eb727 if I understand correctly.)

    Failure to deploy these extra DLLs with your app may result in assembly load errors at runtime (possibly only when running on a pre-8.0.10 .NET 8 runtime).

    Was this change intentional?

  23. locked and limited conversation to collaborators on Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Extensions-Hostingin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions