Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

martian: fix connection hangs in mitm mode #718

Merged
merged 1 commit into from
Feb 23, 2024
Merged

martian: fix connection hangs in mitm mode #718

merged 1 commit into from
Feb 23, 2024

Conversation

mmatczuk
Copy link
Contributor

A regression was introduced in 9cc9854 that allowed use of HTTP/2 inside MITM.

This patch adds the following to all http.Transport instances

t.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)

Interestingly with that t = t.Clone() we get an error

forwarder encountered an unexpected error
net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x12\x04\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x80\x00\x04\x00\x01\x00\x00\x00\x05\x00\xff\xff\xff\x00\x00\x04\b\x00\x00\x00\x00\x00\x7f\xff\x00\x00\x00\x00\b\a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"

A regression was introduced in 9cc9854 that allowed use of HTTP/2 inside MITM.

This patch adds the following to all http.Transport instances

t.TLSNextProto = make(map[string]func(string, *tls.Conn) http.RoundTripper)

Interestingly with that t = t.Clone() we get an error

forwarder encountered an unexpected error
net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x12\x04\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x80\x00\x04\x00\x01\x00\x00\x00\x05\x00\xff\xff\xff\x00\x00\x04\b\x00\x00\x00\x00\x00\x7f\xff\x00\x00\x00\x00\b\a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
Copy link
Contributor

@Choraden Choraden left a comment

Choose a reason for hiding this comment

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

Good catch. I wouldn't expect Clone to do such a nasty thing.

@mmatczuk mmatczuk merged commit c570e1f into main Feb 23, 2024
4 checks passed
@mmatczuk mmatczuk deleted the mmt/fix_hang branch February 23, 2024 13:51
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.

None yet

2 participants