Bsft.Http.Egress 2.2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bsft.Http.Egress --version 2.2.0.1
                    
NuGet\Install-Package Bsft.Http.Egress -Version 2.2.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bsft.Http.Egress" Version="2.2.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bsft.Http.Egress" Version="2.2.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Bsft.Http.Egress" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bsft.Http.Egress --version 2.2.0.1
                    
#r "nuget: Bsft.Http.Egress, 2.2.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bsft.Http.Egress@2.2.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bsft.Http.Egress&version=2.2.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Bsft.Http.Egress&version=2.2.0.1
                    
Install as a Cake Tool

Bsft.Http.Egress

The SSRF defence for outbound HTTP: one policy for where this application may connect to, and the connect-time guard that makes it hold against DNS rebinding. It stands on its own — the Bsft.Http prefix says which concern it belongs to, not which package it depends on: it references no Bsft package at all, so a console worker or a dependency-light client can take it by itself.

Install

dotnet add package Bsft.Http.Egress

No further Bsft packages. It references Microsoft.Extensions.Http, the options packages and nothing from ASP.NET Core, because it is the outbound half of an HTTP call.

Register

services.AddBsftHttpEgress(options =>
{
    options.AllowedHosts.Add("mail-relay.internal");
});

// or bound from configuration, section "Bsft:Http:Egress"
services.AddBsftHttpEgress(configuration);

Registering the policy does not guard anything by itself. A client is guarded on its own builder, which puts the request-time handler on the chain and the connect-time guard on the primary handler:

services.AddHttpClient("provider")
    .AddBsftHttpEgressGuard(handler => handler.AllowAutoRedirect = false);

Turning redirects off is worth doing on any client that calls a destination somebody else chose: following a redirect means the address that was checked is not the address that receives the request.

Configure

Option Default Effect
BsftHttpEgressOptions.AllowPrivateNetworks false Lets outbound requests reach loopback, link-local and the private ranges. A development override.
BsftHttpEgressOptions.AllowInsecureUrls false Lets outbound requests use plain http. A development override.
BsftHttpEgressOptions.AllowedHosts empty Bare host names that are exempt from the single-label rule and the address rules together.

Validation: an allow-list entry that is blank, or that carries a scheme, a port or a path rather than being a bare host name, fails the host at start-up — such an entry matches nothing and would read as a hole that was opened while it never fires.

Extend

  • IOutboundAddressPolicy (decides whether a URL, a host or a resolved address may be called; the default applies the range rules, the two overrides and the allow list).
  • IOutboundConnectGuard (resolves a host and connects to an address it judged; the default is what closes the DNS-rebinding race).
  • IEgressAddressResolver (says where a host points right now; the default is the system resolver, and hands back a literal address unresolved).

Documentation

Topic page: docs/http-egress.md. Conventions: docs/package-conventions.md.

Product 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 64 11/27/2026
2.2.0.1 124 10/31/2026
2.2.0 126 10/23/2026
2.1.0 127 9/28/2026