diff options
author | Matt Holt <[email protected]> | 2024-07-05 10:46:20 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-05 10:46:20 -0600 |
commit | c3fb5f4d3fb3eed9136f766cb88f2d8ac54de685 (patch) | |
tree | e5b791a071ef8853ab620156fe6b9b2ea15919ec /modules/caddyhttp/ip_matchers.go | |
parent | 15d986e1c9decae4d753d7cbec41275264697b2f (diff) | |
download | caddy-c3fb5f4d3fb3eed9136f766cb88f2d8ac54de685.tar.gz caddy-c3fb5f4d3fb3eed9136f766cb88f2d8ac54de685.zip |
caddyhttp: Reject 0-RTT early data in IP matchers and set Early-Data header when proxying (#6427)
* caddyhttp: Reject 0-RTT early data in IP matchers and set Early-Data header when proxying
See RFC 8470: https://httpwg.org/specs/rfc8470.html
Thanks to Michael Wedl (@MWedl) at the University of Applied Sciences St. Poelten for reporting this.
* Don't return value for {remote} placeholder in early data
* Add Caddyfile support
Diffstat (limited to 'modules/caddyhttp/ip_matchers.go')
-rw-r--r-- | modules/caddyhttp/ip_matchers.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/caddyhttp/ip_matchers.go b/modules/caddyhttp/ip_matchers.go index baa7c51ce..9101a0357 100644 --- a/modules/caddyhttp/ip_matchers.go +++ b/modules/caddyhttp/ip_matchers.go @@ -143,6 +143,9 @@ func (m *MatchRemoteIP) Provision(ctx caddy.Context) error { // Match returns true if r matches m. func (m MatchRemoteIP) Match(r *http.Request) bool { + if r.TLS != nil && !r.TLS.HandshakeComplete { + return false // if handshake is not finished, we infer 0-RTT that has not verified remote IP; could be spoofed + } address := r.RemoteAddr clientIP, zoneID, err := parseIPZoneFromString(address) if err != nil { @@ -228,6 +231,9 @@ func (m *MatchClientIP) Provision(ctx caddy.Context) error { // Match returns true if r matches m. func (m MatchClientIP) Match(r *http.Request) bool { + if r.TLS != nil && !r.TLS.HandshakeComplete { + return false // if handshake is not finished, we infer 0-RTT that has not verified remote IP; could be spoofed + } address := GetVar(r.Context(), ClientIPVarKey).(string) clientIP, zoneID, err := parseIPZoneFromString(address) if err != nil { |