The forwarded headers of every sender are trusted, so clients can claim any address
What it finds
The forwarded headers middleware of ASP.NET Core takes the client address and scheme from X-Forwarded-For and X-Forwarded-Proto, but only from the proxies and networks it knows. Clearing KnownProxies and KnownNetworks makes it believe these headers from any sender, so a client can claim any address, past rate limits, address filters and logs, and any scheme. Listing the addresses of the real proxies keeps the protection.
From the rule's source, forwarded_headers_from_any_proxy.rs.
using System.Net;using Microsoft.AspNetCore.Builder; class Startup{ void Configure(ForwardedHeadersOptions options) { options.KnownNetworks.Clear();tx0 reports: clearing KnownNetworks makes forwarded headers trusted from any sender options.KnownProxies.Clear();tx0 reports: clearing KnownProxies makes forwarded headers trusted from any sender options.KnownProxies.Add(IPAddress.Parse("10.0.0.1")); options.ForwardedHeaders.ToString(); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:forwarded-headers-from-any-proxy" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/csharp:forwarded-headers-from-any-proxy] reason="..."tx0 explain tx0/csharp:forwarded-headers-from-any-proxy shows the same in the terminal. Found a false positive? Report it.