idunno.Security.Ssrf
2.0.0
Prefix Reserved
See the version list below for details.
dotnet add package idunno.Security.Ssrf --version 2.0.0
NuGet\Install-Package idunno.Security.Ssrf -Version 2.0.0
<PackageReference Include="idunno.Security.Ssrf" Version="2.0.0" />
<PackageVersion Include="idunno.Security.Ssrf" Version="2.0.0" />
<PackageReference Include="idunno.Security.Ssrf" />
paket add idunno.Security.Ssrf --version 2.0.0
#r "nuget: idunno.Security.Ssrf, 2.0.0"
#:package idunno.Security.Ssrf@2.0.0
#addin nuget:?package=idunno.Security.Ssrf&version=2.0.0
#tool nuget:?package=idunno.Security.Ssrf&version=2.0.0
idunno.Security.Ssrf
A .NET library to help mitigate Server Side Request Forgery (SSRF) vulnerabilities in .NET applications that use HttpClient or ClientWebSocket.
Key Features
- Mitigates common SSRF vulnerabilities in .NET applications that use
HttpClientorClientWebSocket. - Supports both IPv4 and IPv6 addresses, including loopback, link-local, and private address ranges.
- Allows for extra IP ranges to be added to the default block list.
Getting Started
Add the idunno.Security.Ssrf package to your project, and then when you create an HttpClient and add an instance of the handler
to the message handler pipeline.
using (var httpClient = new HttpClient(idunno.Security.SsrfSocketsHttpHandlerFactory.Create()))
{
_ = await httpClient.GetAsync(new Uri("bad.ssl.fail")).ConfigureAwait(false);
}
If you want to protect a ClientWebSocket you can pass a an instance of the handler in as the invoker parameter of
ConnectAsync(Uri uri, System.Net.Http.HttpMessageInvoker? invoker, System.Threading.CancellationToken cancellationToken);.
using (var webSocket = new ClientWebSock())
using (var httpClient = new HttpClient(idunno.Security.SsrfSocketsHttpHandlerFactory.Create()))
{
await webSocket.ConnectAsync(
uri: new Uri("wss://echo.websocket.org"),
invoker: httpClient);
}
If the SSRF check finds an unsafe host, or a host that resolves to an unsafe address it will throw an SsrfException.
Depending on where the exception it thrown, and the type of client it will end up as the InnerException on the
HttpRequestException, SocketException or WebSocketException thrown by the client.
Please see the full README for more details on how to use this nupkg.
The CHANGELOG has a full a list of changes in each version.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
-
net8.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
-
net9.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on idunno.Security.Ssrf:
| Package | Downloads |
|---|---|
|
idunno.AtProto
.NET client for ATProto. |
GitHub repositories
This package is not used by any popular GitHub repositories.