Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
### [Package Manager Console (PowerShell)](consume-packages/install-use-packages-powershell.md)
## Configure NuGet
### [Visual Studio options](consume-packages/nuget-visual-studio-options.md)
### [NuGet HTTPS Everywhere](consume-packages/nuget-https-everywhere.md)
### Package restore options
#### [Restore packages](consume-packages/package-restore.md)
#### [Troubleshooting](consume-packages/package-restore-troubleshooting.md)
Expand Down
60 changes: 56 additions & 4 deletions docs/concepts/Auditing-Packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ This involves identifying vulnerabilities, evaluating risks, and making recommen
The audit can include a review of the packages themselves, as well as any dependencies and their associated risks.
The goal of the audit is to identify and mitigate any security vulnerabilities that could be exploited by attackers, such as code injection or cross-site scripting attacks.

We also have a [blog post](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) which discusses our recommended method for taking action when a package with a known vulnerability is found to be used by your project, and tools to help get more information.

### Feature availability

| NuGet | .NET SDK | Visual Studio | Feature |
Expand Down Expand Up @@ -182,7 +180,14 @@ Note that `--include-transitive` is not default, so should be included.

## Actions when packages with known vulnerabilities are reported

We also have a [blog post](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) which discusses our recommended method for taking action when a package with a known vulnerability is found to be used by your project, and tools to help get more information.
Getting a warning about packages with known vulnerabilities is only part of the process.
Once discovered, action needs to be taken to remove the potential vulnerability from your solution.

The easiest case is when a package you reference directly has the known vulnerability.
In this situation, update the package version to one that fixes the vulnerability.
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

Extra space at the end of line 186. The period should be followed by a single space before the next sentence, not a period-space-newline-In.

Suggested change
The easiest case is when a package you reference directly has the known vulnerability.
In this situation, update the package version to one that fixes the vulnerability.
The easiest case is when a package you reference directly has the known vulnerability. In this situation, update the package version to one that fixes the vulnerability.

Copilot uses AI. Check for mistakes.

Package vulnerabilities may be reported in both direct and transitive package references.
The action you take to resolve may be different because of that.

### Security vulnerabilities found with updates

Expand All @@ -195,13 +200,60 @@ If security vulnerabilities are found and updates are available for the package,

#### Transitive Packages

If a known vulnerability exists in a top-level package's transitive dependencies, you have these options:
Often a vulnerability will be in a transitive dependency.
Our recommendation is to prefer updates to packages "closest" to your direct references.
Though, there's nothing wrong with just upgrading the package with known vulnerability either.

For example, say your project references package A.
Package A has a dependency on package B, which in turn has a dependency on package C.
In this example, we'll consider that package C version 1.0.0 has a known vulnerability, fixed in version 2.0.0.
Our recommendation is to first try upgrading package A.
If that doesn't resolve the audit warning, then try upgrading package B.
If that doesn't resolve the audit warning, then upgrade C directly.
To aid with this, you'll [need to find the transitive package path](#finding-the-transitive-package-path).

In summary, if a known vulnerability exists in a top-level package's transitive dependencies, you have these options:

- Check if the top-level package contains an update that does not have a transitive vulnerability and update that instead.
- Update the closest package to your direct references that does not reference a vulnerability.
- Add the fixed package version as a direct package reference. **Note:** Be sure to remove this reference when a new package version update becomes available and be sure to maintain the defined attributes for the expected behavior.
- Use [Central Package Management with the transitive pinning functionality](../consume-packages/Central-Package-Management.md#transitive-pinning).
Note that if you pack your project into your own package to share with others, [CPM with transitive pinning will cause packages to become dependencies](../consume-packages/Central-Package-Management.md#transitive-pinning-and-pack), even if your project doesn't directly call APIs on that package.
- [Suppress the advisory](#excluding-advisories) until it can be addressed.
- File an issue in the top-level package's tracker to request an update.

##### Finding the transitive package path

There are several ways to find the package path.
Which method you prefer depends on what tools you normally use during your development.

###### dotnet nuget why

On the command line, you can use the [`dotnet nuget why` command](/dotnet/core/tools/dotnet-nuget-why) to understand why transitive packages are being included in your project's package graph.

![dotnet nuget why example](media/dotnet-nuget-why-1.png)

###### Visual Studio Solution Explorer

SDK style projects also provide the full package graph under the project's Dependency node.
It's also searchable!
Expand search options and enable “search external files”.

![Visual Studio Solution Explorer Search Options](media/vs-solution-explorer-search-options-1.png)

Search the package name, and it will show you all instances under each project's Dependencies node.

![Visual Studio Solution Explorer Search Results](media/vs-solution-explorer-search-results-1.png)

###### Visual Studio NuGet Package Manager UI

When you look at the Installed tab in Visual Studio's package manager UI, when the project uses PackageReference for package management, it will show both direct and transitive packages.
Currently, this only happens when you manage packages for a project, not for the solution.

If you mouse hover over a package in the package list, the tooltip will include the name of one direct package that has caused that transitive package to be included in the project.

![Visual Studio Package Manager UI tooltip](media/pm-ui-transitive-tooltip-1.png)

### Use Copilot to update packages
NuGet has released a Model Context Protocol (MCP) server that has the ability to update packages in your project to versions that resolve known vulnerabilities.
See [Fixing package vulnerabilities](NuGet-MCP-Server.md#fixing-package-vulnerabilities) for more information.
Expand Down
78 changes: 78 additions & 0 deletions docs/concepts/NuGet-MCP-Server.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,84 @@ To verify that the MCP server is working correctly, open the GitHub Copilot Chat
Then click the Tools icon in the bottom toolbar to bring up the Tools menu.
You should see the MCP server named "nuget" in the list of available servers.

## Getting started in GitHub Copilot Agent

You can also configure the MCP Server to work with GitHub Copilot as a Coding Agent in your repositories.
Ensure that you configured your repository to use [GitHub Copilot Coding Agents](https://github.com/settings/copilot/coding_agent).

Browse to your repository and click the Settings tab.
Expand the Copilot section and click on Coding Agents.

![GitHub Copilot coding agent settings](./media/github-copilot-agent-settings.png)

Scroll down to the **Model Context Protocol (MCP)** section and add the following JSON snippet to your `mcpServers` configuration:

```json
{
"mcpServers": {
"NuGet": {
"type": "local",
"command": "dnx",
"args": ["NuGet.Mcp.Server", "--yes"],
"tools": ["*"],
"env": {}
}
}
}
```

This will make all of NuGet's MCP server tools available. If you want specific tools, you can list them in the `"tools"` parameter array.

Finally, click the **Save MCP configuration** button to save your changes.

Now that the NuGet MCP is configured, you will also need to create a GitHub Actions workflow to install .NET 10 Preview 6 or higher so that the `dnx` command is available to run the MCP server.
You can do this by creating the following workflow file in your repository at

`.github/workflows/copilot-setup-steps.yml`

The contents of this workflow file should be as follows:

```yml
name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest

# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read

# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- name: Install .NET 10.x
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
10.x
dotnet-quality: preview

- name: dotnet --info
run: dotnet --info
```

This will ensure that the `dnx` command is available to run the NuGet MCP server when GitHub Copilot runs as a coding agent in your repository.

## Fixing package vulnerabilities

The NuGet MCP server can help you identify and fix package vulnerabilities in your project.
Expand Down
Binary file added docs/concepts/media/dotnet-nuget-why-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions docs/consume-packages/nuget-https-everywhere.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: NuGet HTTPS Everywhere
description: Learn why NuGet enforces HTTPS connections for package sources, what errors like NU1302 mean, and how to safely allow HTTP feeds when necessary.
author: Nigusu-Allehu
ms.author: nyenework
ms.date: 10/28/2025
ms.topic: conceptual
ai-usage: ai-generated
---

# NuGet HTTPS Everywhere

NuGet requires all package sources to use **HTTPS** instead of **HTTP**.
This enforcement protects the software supply chain by preventing tampering and interception during package restore and related operations.
NuGet enforces this requirement by producing an error and stopping the operation when an HTTP source is used.

## Understanding the HTTP Error

This error occurs when one or more package sources in your configuration use an **HTTP** URL instead of **HTTPS**.

In earlier NuGet versions, this scenario produced a **warning** ([`NU1803`](../reference/errors-and-warnings/nu1803.md)).
Beginning with [**NuGet 6.12**](../release-notes/NuGet-6.12.md) and later, it now results in an **error** unless the use of HTTP sources is explicitly permitted.
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

Extra space before [NuGet 6.12]. Should be single space after 'with'.

Suggested change
Beginning with [**NuGet 6.12**](../release-notes/NuGet-6.12.md) and later, it now results in an **error** unless the use of HTTP sources is explicitly permitted.
Beginning with [**NuGet 6.12**](../release-notes/NuGet-6.12.md) and later, it now results in an **error** unless the use of HTTP sources is explicitly permitted.

Copilot uses AI. Check for mistakes.

### Recommended Resolution

Before allowing HTTP connections, confirm whether your package source supports HTTPS.
If it does, update the feed URL to use the secure protocol:

```xml
<add key="MyFeed" value="https://contoso/packages/v3/index.json" />
```

Switching to HTTPS ensures end-to-end encryption and is the recommended and more secure approach.

### Allowing Insecure HTTP Feeds (Opt-Out)

If HTTPS is not available and you operate in a trusted or isolated environment, you can explicitly allow HTTP sources.

#### Option 1: Set allowInsecureConnections in your `NuGet.Config`

* **Use Visual Studio**

Enable or disable allowing insecure HTTP connections with the [Package Sources settings](/nuget/consume-packages/nuget-visual-studio-options#allow-insecure-connections) under the Visual Studio options > **NuGet Package Manager**.

* **Edit `NuGet.Config` manually**

Add the `allowInsecureConnections="true"` attribute to the affected source:

```xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyHttpFeed" value="http://contoso/packages/v3/index.json" allowInsecureConnections="true" />
</packageSources>
</configuration>
```

#### Option 2: Use the Command-Line Parameter

For commands that support it, include the following flag to temporarily permit HTTP connections:

For **dotnet** commands:

```bash
--allow-insecure-connections
```

For **NuGet.exe** commands, use:

```powershell
-AllowInsecureConnections
```

#### Commands that support opt-out options

| Tool | Commands | Support for Allow Insecure Connection |
| -------------- | ------------------------- | ------------------------------------- |
| **nuget.exe** | `push` | NuGet **7.0** |
| **dotnet CLI** | `dotnet nuget push` | .NET **10.0.1xx** and newer |
| **dotnet CLI** | `dotnet nuget add source` | .NET **9.0.1xx** and newer |

## HTTPS Enforcement Rollout Across Tools

NuGet’s HTTPS enforcement was introduced gradually across releases.
The following table summarizes the progression from [**warnings (NU1803)**](../reference/errors-and-warnings/nu1803.md) to [**errors (NU1302)**](../reference/errors-and-warnings/nu1302.md).

| Versions Affected | Behavior |
| ----------------------------------------------------- | --------------------------------------------------------------------- |
| [NuGet.exe 6.3](../release-notes/NuGet-6.3.md)+, Visual Studio 17.3+, .NET 6.0.100+ | ⚠️ **Warning (NU1803)** – HTTP sources allowed but discouraged |
| [NuGet.exe 6.12](../release-notes/NuGet-6.12.md)+, Visual Studio 17.12+, .NET 9.0.100+ |**Error (NU1302)** – HTTP sources blocked unless explicitly allowed|

## See Also

* [NU1302](../reference/errors-and-warnings/nu1302.md)
* [NU1803](../reference/errors-and-warnings/nu1803.md)
* [NuGet.Config Reference](../reference/nuget-config-file.md#packagesources)
* [NuGet Visual Studio Options](../consume-packages/nuget-visual-studio-options.md)
33 changes: 33 additions & 0 deletions docs/reference/errors-and-warnings/NU1302.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ f1_keywords:

# NuGet Error NU1302

## Scenario 1

> You are running the 'restore' operation with an 'HTTP' source: myHttpSource. NuGet requires HTTPS sources. To use an HTTP source, you must explicitly set 'allowInsecureConnections' to true in your NuGet.Config file. Please refer to https://aka.ms/nuget-https-everywhere for more information.

### Issue
Expand Down Expand Up @@ -53,3 +55,34 @@ Here's how it functions:

> [!WARNING]
> Changing SdkAnalysisLevel has other side-effects. Refer to the [`SdkAnalysisLevel`](/dotnet/core/project-sdk/msbuild-props#sdkanalysislevel) for a summary of the full scope of .NET SDK features affected.

## Scenario 2

> You are using a NuGet source 'https://contoso/v3/index.json' that contains an 'HTTP' service index resource endpoint: 'http://contoso/v3-flatcontainer/contoso/index.json'. This is insecure and not recommended. To allow HTTP resources, you must explicitly set 'allowInsecureConnections' to true in your NuGet.Config file. For more information, visit https://aka.ms/nuget-https-everywhere.

### Issue

A configured package source uses **HTTPS**, but one of its resources (indicated in the error message) uses **HTTP**.

NuGet requires that all sources and their resources use HTTPS.
If you want to continue using this source despite its HTTP resource, you must set the `allowInsecureConnections` flag to true in your NuGet.config file.

To learn more about package sources and resource endpoints, take a look at the [NuGet Server API](../../api/overview).

#### Option 1: Update the Source to Use HTTPS

Whenever possible, switch to a package source that provides only HTTPS resources. This is the recommended and most secure option.

#### Option 2: Allow Insecure Connections (If Necessary)

If you must use the source, explicitly allow insecure connections by adding the `allowInsecureConnections` flag in the `NuGet.Config`:

For information about managing the setting in Visual Studio, see [NuGet Options in Visual Studio](../../consume-packages/nuget-visual-studio-options.md#allow-insecure-connections)

```xml
<configuration>
<packageSources>
<add key="InsecureSource" value="https://contoso/v3/index.json" allowInsecureConnections="true" />
</packageSources>
</configuration>
```
2 changes: 1 addition & 1 deletion docs/reference/errors-and-warnings/NU1901-NU1904.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For more information, see [the documentation on auditing packages](../../concept

### Solution

We have [a blog post](https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/) with more discussion about our recommended actions when your project uses a package with a known vulnerability, and tools that can help.
We have [documentation on upgrading vulnerable packages](../../concepts/Auditing-Packages.md#actions-when-packages-with-known-vulnerabilities-are-reported) that goes in more detail about our recommended actions when your project uses a package with a known vulnerability, and tools that can help.

Upgrading to a newer version of the package is likely to resolve the warning.
If your project does not reference the package directly (it's a transitive package), [`dotnet nuget why`](/dotnet/core/tools/dotnet-nuget-why) can be used to understand which package caused it to be included in your project.
Expand Down