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

HTTP2 spec section 3.5 error #112

Open
rustrust opened this issue Apr 26, 2020 · 5 comments
Open

HTTP2 spec section 3.5 error #112

rustrust opened this issue Apr 26, 2020 · 5 comments

Comments

@rustrust
Copy link

rustrust commented Apr 26, 2020

it looks like the good folks over at actix-web found an error in h2spec section 3.5

actix/actix-web#1453

"Clients and servers MUST treat an invalid connection preface as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. A GOAWAY frame (Section 6.8) MAY be omitted in this case, since an invalid preface indicates that the peer is not using HTTP/2." per http2 sec https://http2.github.io/http2-spec/#ConnectionHeader

but it looks like h2spec requires a GOAWAY frame--please see the linked issue

@summerwind
Copy link
Owner

Sorry for the delayed response.

h2spec expects a GOAWAY frame OR connection to be disconnected in 3.5. It does not necessarily require a GOAWAY frame.

Looking at the output of the original Issue, it looks like the server is forcing the connection to be terminated without proper disconnection from the server. Is your server side properly terminating the connection?

Hypertext Transfer Protocol Version 2 (HTTP/2)
  3. Starting HTTP/2
    3.5. HTTP/2 Connection Preface
      × 2: Sends invalid connection preface
        -> The endpoint MUST terminate the TCP connection.
           Expected: GOAWAY Frame (Error Code: PROTOCOL_ERROR)
                     Connection closed
             Actual: Error: read tcp 127.0.0.1:56738->127.0.0.1:8080: read: connection reset by peer

@sbordet
Copy link

sbordet commented Jun 5, 2020

Also at Jetty we are having problems with the too strict interpretation of this section.

Sending an invalid preface may first trigger a HTTP/1.1 parser (in case a HTTP/1.1 to HTTP/2 upgrade is necessary).

The HTTP/1.1 parser will not recognize the preface and generate a HTTP/1.1 400 with a small body, and then close the connection.

Apparently, h2spec does not allow for some bytes before reading -1?

Attached a network capture that shows the issue.
h2spec_3.5.pcapng.zip

Thanks!

@bjosv
Copy link

bjosv commented Aug 24, 2020

This issue could most probably be solved by #119

@gstrauss
Copy link

A workaround (kludge) is

--- a/spec/verifier.go
+++ b/spec/verifier.go
@@ -66,6 +66,10 @@ func VerifyConnectionError(conn *Conn, codes ...http2.ErrCode) error {
                        if actual == nil {
                                actual = event
                        }
+               case ErrorEvent:
+                       if event.String() == "Error: unexpected EOF" {
+                               passed = true
+                       }
                default:
                        actual = event
                }

#119 addresses the issue more cleanly.

@dmatej
Copy link

dmatej commented Nov 19, 2020

Hi from Payara, both master and #119 still fail on Ubuntu the same way ...

Hypertext Transfer Protocol Version 2 (HTTP/2)
3. Starting HTTP/2
3.5. HTTP/2 Connection Preface
using source address 127.0.0.1:49970
× 2: Sends invalid connection preface
-> The endpoint MUST terminate the TCP connection.
Expected: GOAWAY Frame (Error Code: PROTOCOL_ERROR)
Connection closed
Actual: Error: unexpected EOF

The trick from @gstrauss works, but looks very nasty :-)

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

No branches or pull requests

6 participants