Skip to content

fix(-pr http11): disable retryablehttp HTTP/2 fallback when http11 protocol is forced#2438

Open
usernametooshort wants to merge 1 commit intoprojectdiscovery:mainfrom
usernametooshort:fix/http11-disables-http2-fallback
Open

fix(-pr http11): disable retryablehttp HTTP/2 fallback when http11 protocol is forced#2438
usernametooshort wants to merge 1 commit intoprojectdiscovery:mainfrom
usernametooshort:fix/http11-disables-http2-fallback

Conversation

@usernametooshort
Copy link

Problem

When -pr http11 is used, httpx correctly disables HTTP/2 at the transport level:

_ = os.Setenv("GODEBUG", "http2client=0")
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}

However, retryablehttp-go has an automatic fallback in do.go that silently upgrades to HTTP/2 when it sees a malformed HTTP/2 error:

if err != nil && stringsutil.ContainsAny(err.Error(), "net/http: HTTP/1.x transport connection broken...") {
    resp, err = c.HTTPClient2.Do(req.Request)  // bypasses http11 config!
}

This means -pr http11 has no effect for servers that respond with HTTP/2, because retryablehttp-go overrides the protocol choice via HTTPClient2.

Fixes #2240

Fix

This PR sets retryablehttpOptions.DisableHTTP2Fallback = true when Protocol == "http11", which (via projectdiscovery/retryablehttp-go#532) skips the HTTPClient2.Do fallback and honours the HTTP/1.1-only requirement end-to-end.

Dependency

Requires projectdiscovery/retryablehttp-go#532 to be merged first (adds the DisableHTTP2Fallback option).

Testing

# Before: http11 flag has no effect, server upgrades to HTTP/2
httpx -u https://example.com -pr http11 -debug 2>&1 | grep -i protocol

# After: request stays on HTTP/1.1
httpx -u https://example.com -pr http11 -debug 2>&1 | grep -i protocol

@neo-by-projectdiscovery-dev
Copy link

neo-by-projectdiscovery-dev bot commented Mar 6, 2026

Incremental Security Review - Commit 3f038ef

Reviewed the incremental changes between commit 0e65470 and 3f038ef. Only 1 file was modified (common/httpx/httpx.go) with 6 lines added. No exploitable security vulnerabilities were found in the changes.

📌 Key Takeaways

  • Only common/httpx/httpx.go was modified in this incremental update
  • Change adds DisableHTTP2Fallback=true when Protocol is http11 (lines 160-163)
  • This prevents silent HTTP/2 upgrades via retryablehttp-go's automatic fallback
  • No injection, authentication, or credential exposure vulnerabilities in the changes
  • The database code (internal/db/) from the previous review has been removed from this PR branch

… protocol is set

When -pr http11 is used, httpx correctly sets TLSNextProto={} and
GODEBUG=http2client=0 to force HTTP/1.1. However retryablehttp-go's
automatic HTTP/2 fallback in do.go silently bypasses this:

  if err is malformed HTTP/2 response {
      resp, err = c.HTTPClient2.Do(req.Request)  // <- ignores http11 config
  }

This commit sets retryablehttpOptions.DisableHTTP2Fallback=true when
Protocol=="http11", ensuring the HTTP/1.1-only requirement is honoured
end-to-end.

Depends on: projectdiscovery/retryablehttp-go#532
Fixes: projectdiscovery#2240
@usernametooshort usernametooshort force-pushed the fix/http11-disables-http2-fallback branch from 0e65470 to 3f038ef Compare March 6, 2026 07:14
@usernametooshort
Copy link
Author

Force-pushed to clean up the branch — it had accidentally included unrelated commits from the fork point.

The PR now contains only the single-line fix:

retryablehttpOptions.DisableHTTP2Fallback = true

The SQL injection warning from Neo was from pre-existing code in the old diff, not from this PR.

Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR should target the dev branch

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.

2 participants