You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/Security-Best-Practices.md
+30-10Lines changed: 30 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,8 @@ We will cover various tools and techniques that NuGet and GitHub provides, which
61
61
62
62
### NuGet dependency graph
63
63
64
+
π¦ Package Consumer
65
+
64
66
You can view your NuGet dependencies in your project by looking directly at the respective project file.
65
67
66
68
This is typically found in one of two places:
@@ -76,13 +78,17 @@ For more information on managing NuGet dependencies, [see the following document
76
78
77
79
### GitHub dependency graph
78
80
81
+
π¦ Package Consumer | π¦π Package Author
82
+
79
83
You can use GitHubβs dependency graph to see the packages your project depends on and the repositories that depend on it. This can help you see any vulnerabilities detected in its dependencies.
80
84
81
85
For more information on GitHub repository dependencies, [see the following documentation](https://github.co/dependency-graph).
82
86
83
87
### Dependency versions
84
88
85
-
To ensure a secure supply chain of dependencies, you will want to ensure that all your dependencies are regularly updated to the latest stable version. Your dependencies can include code you depend on, binaries you consume, tooling you use, and other components. This can include:
89
+
π¦ Package Consumer | π¦π Package Author
90
+
91
+
To ensure a secure supply chain of dependencies, you will want to ensure that all of your dependencies & tooling are regularly updated to the latest stable version as they will often include the latest functionality and security patches to known vulnerabilities. Your dependencies can include code you depend on, binaries you consume, tooling you use, and other components. This may include:
@@ -93,10 +99,14 @@ To ensure a secure supply chain of dependencies, you will want to ensure that al
93
99
94
100
### NuGet deprecated and vulnerable dependencies
95
101
102
+
π¦ Package Consumer | π¦π Package Author
103
+
96
104
You can use the [dotnet CLI](/dotnet/core/tools/dotnet-list-package) to list any known deprecated or vulnerable dependencies you may have inside your project or solution. You can use the command `dotnet list package --deprecated` or `dotnet list package --vulnerable` to provide you a list of any known deprecations or vulnerabilities.
97
105
98
106
### GitHub vulnerable dependencies
99
107
108
+
π¦ Package Consumer | π¦π Package Author
109
+
100
110
If your project is hosted on GitHub, you can leverage [GitHub Security](https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/automatically-scanning-your-code-for-vulnerabilities-and-errors) to find security vulnerabilities and errors in your project and Dependabot will fix them by opening up a pull request against your codebase.
101
111
102
112
Catching vulnerable dependencies before they are introduced is one goal of the [βShift Leftβ](https://en.wikipedia.org/wiki/Shift-left_testing) movement. Being able to have information about your dependencies such as their license, transitive dependencies, and the age of dependencies helps you do just that.
@@ -105,54 +115,64 @@ For more information about Dependabot alerts & security updates, [see the follow
105
115
106
116
### NuGet feeds
107
117
108
-
Packages can come from different feeds. To ensure you are secure, knowing what feed your packages are coming from is a best practice. One such best practice is the use of a single feed. You can accomplish this by using multiple upstream source feeds to bring your packages into a single feed.
118
+
π¦ Package Consumer
119
+
120
+
When using multiple public & private NuGet source feeds, a package can be downloaded from any of the feeds. To ensure your build is predictable and secure from known attacks such as [Dependency Confusion](https://medium.com/@alex.birsan/dependency-confusion-4a5d60fec610), knowing what specific feed(s) your packages are coming from is a best practice. You can use a single feed or private feed with upstreaming capabilities for protection.
109
121
110
122
For more information to secure your package feeds, see [3 Ways to Mitigate Risk When Using Private Package Feeds](https://azure.microsoft.com/en-us/resources/3-ways-to-mitigate-risk-using-private-package-feeds/).
111
123
112
124
### Client trust policies
113
125
126
+
π¦ Package Consumer
127
+
114
128
There are policies that you can opt-into in which you require the packages you use to be signed. This allows you to trust a package author, as long as it is author signed, or trust a package if it is owned by a specific user or account that is repository signed by NuGet.org.
115
129
116
130
To configure client trust policies, [see the following documentation](../consume-packages/installing-signed-packages.md).
117
131
118
132
### Lock files
119
133
134
+
π¦ Package Consumer
135
+
120
136
Lock files store the hash of your packageβs content. If the content hash of a package you want to install matches with the lock file, it will ensure package repeatability.
121
137
122
138
To enable lock files, [see the following documentation](../consume-packages/package-references-in-project-files#locking-dependencies).
123
139
124
140
## Monitor your supply chain
125
141
126
-
### Publish to NuGet.org
127
-
128
-
NuGet.org serves as a central repository to over 200,000 unique packages. Whenever you publish a package, NuGet.org will go through numerous validations and indexing that can benefit you in the long term. These can include scanning the package for viruses, [providing a repository signature](../reference/signed-packages-reference.md) on the package, and even protecting your package ID so only you can push updates to it.
129
-
130
-
To learn more about the benefits of publishing on NuGet.org, see [Package validation and indexing](../nuget-org/publish-a-package.md#package-validation-and-indexing).
131
-
132
142
### GitHub secret scanning
133
143
144
+
π¦π Package Author
145
+
134
146
GitHub scans repositories for NuGet API keys to prevent fraudulent uses of secrets that were accidentally committed.
135
147
136
148
To learn more about secret scanning, see [About secret scanning](https://docs.github.com/en/github/administering-a-repository/about-secret-scanning).
137
149
138
150
### Author Package Signing
139
151
140
-
[Author signing](../reference/signed-packages-reference.md) allows a package author to stamp their identity on a package and for a consumer to verify it came from you. This protects you against content tampering and serves as a single source of truth about the origin of the package and the package authenticity.
152
+
π¦π Package Author
153
+
154
+
[Author signing](../reference/signed-packages-reference.md) allows a package author to stamp their identity on a package and for a consumer to verify it came from you. This protects you against content tampering and serves as a single source of truth about the origin of the package and the package authenticity. When combined with client trust policies, you can verify a package came from a specific author.
141
155
142
156
To author sign a package, see [Sign a package](../create-packages/sign-a-package.md).
143
157
144
158
### Two-Factor Authentication (2FA)
145
159
160
+
π¦π Package Author
161
+
146
162
Enabling two-factor authentication (2FA) can add an extra layer of security when [logging into your GitHub account](https://docs.github.com/en/github/authenticating-to-github/securing-your-account-with-two-factor-authentication-2fa) or the [NuGet.org public package repository](../nuget-org/individual-accounts.md#enable-two-factor-authentication-2fa). It is recommended that you enable two-factor authentication to protect your account.
147
163
148
164
### Package ID prefix reservation
149
165
150
-
To protect the identity of your packages, you can reserve a package ID prefix to associate a matching owner if your package ID prefix properly falls under the [specified criteria](../nuget-org/id-prefix-reservation.md#id-prefix-reservation-criteria).
166
+
π¦π Package Author
167
+
168
+
To protect the identity of your packages, you can reserve a package ID prefix with your respective namespace to associate a matching owner if your package ID prefix properly falls under the [specified criteria](../nuget-org/id-prefix-reservation.md#id-prefix-reservation-criteria).
151
169
152
170
To learn about reserving ID prefixes, see [Package ID prefix reservation](../nuget-org/id-prefix-reservation.md).
153
171
154
172
### Deprecating and unlisting a vulnerable package
155
173
174
+
π¦π Package Author
175
+
156
176
To protect the .NET package ecosystem when you are aware of a vulnerability in a package you have authored, do your best to deprecate and unlist the package so it is hidden from users searching for packages. If you are consuming a package that is deprecated and unlisted, you should avoid using the package.
157
177
158
178
To learn how to deprecate and unlist a package, see the following documentation on [deprecating](../nuget-org/deprecate-packages.md) and [unlisting packages](../nuget-org/policies/deleting-packages.md#unlisting-a-package).
0 commit comments