Skip to content

Fix nil req.URL crash for gRPC/HTTP2 requests in MITM mode#18

Merged
bbrowning merged 1 commit into
mainfrom
http2-url-reconstruct
May 11, 2026
Merged

Fix nil req.URL crash for gRPC/HTTP2 requests in MITM mode#18
bbrowning merged 1 commit into
mainfrom
http2-url-reconstruct

Conversation

@bbrowning
Copy link
Copy Markdown
Owner

When gRPC clients (like dolt's eventsapi) connect through the MITM proxy, they use HTTP/2 which doesn't have a traditional request-line. Instead, HTTP/2 uses pseudo-headers (:method, :path, :authority, :scheme).

goproxy was designed for HTTP/1.1 and doesn't properly reconstruct req.URL from HTTP/2 pseudo-headers in MITM mode, leaving it nil. This caused the proxy to crash when accessing req.URL.Host.

This fix:

  • Detects when req.URL is nil
  • Logs diagnostic information (Method, Host, RequestURI, Proto)
  • Reconstructs req.URL from req.Host and req.RequestURI when available
  • Only returns an error if reconstruction is impossible

This allows gRPC traffic (eventsapi.dolthub.com) to flow through the proxy while still catching genuinely malformed requests.

When gRPC clients (like dolt's eventsapi) connect through the MITM proxy,
they use HTTP/2 which doesn't have a traditional request-line. Instead,
HTTP/2 uses pseudo-headers (:method, :path, :authority, :scheme).

goproxy was designed for HTTP/1.1 and doesn't properly reconstruct req.URL
from HTTP/2 pseudo-headers in MITM mode, leaving it nil. This caused the
proxy to crash when accessing req.URL.Host.

This fix:
- Detects when req.URL is nil
- Logs diagnostic information (Method, Host, RequestURI, Proto)
- Reconstructs req.URL from req.Host and req.RequestURI when available
- Only returns an error if reconstruction is impossible

This allows gRPC traffic (eventsapi.dolthub.com) to flow through the proxy
while still catching genuinely malformed requests.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bbrowning bbrowning merged commit cd70ced into main May 11, 2026
6 checks passed
@bbrowning bbrowning deleted the http2-url-reconstruct branch May 11, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant