Have ForwardedHeaders send 400 responses for bad/missing forwarders
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
Today the ForwardedHeadersMiddleware no-ops if the expected headers are missing or invalid. For our common use cases though, we expect the headers to always be there or else the proxy is misconfigured (or the request is coming from a potentially malicious side-channel?). In these scenarios it makes sense to reject the request as invalid (400).
This would be optional and only enabled for our known scenarios (IIS out-of-proc, Azure Linux, Nginx & Apache docs, etc.) because we don't know how other customers may be using it.
Compare to the HostFitlering middleware that sends a 400 and an optional HTML message.
Design note: Rather than making this a bool option, consider a ForwardMinimum count that would mirror the existing ForwardLimit. E.g. There must be at least ForwardMinimum headers applied or else we fail the request. However, for all of our usages this minimum would be 1 (ForwardLimit also defaults to 1). The default would be 0.
@blowdart @davidfowl
Contributor guide
Assessment
This issue has not been assessed yet.