Skip to content

HTTP/2 protocol error: Received header value surrounded by whitespace #4836

Closed

Description

@trungtly

Problem Description

Youtube iOS app unable to connect through mitmproxy. The event log is as below

Web server listening at http://127.0.0.1:8081/
Proxy server listening at http://*:8080
192.168.1.106:50388: client connect
192.168.1.106:51246: client connect
192.168.1.106:51247: client connect
192.168.1.106:50388: server connect r1---sn-u2bpouxgoxu-hxay.googlevideo.com:443 (202.7.223.140:443)
192.168.1.106:51248: client connect
192.168.1.106:51246: server connect notifications-pa.googleapis.com:443 (142.250.70.138:443)
192.168.1.106:51247: server connect youtubei.googleapis.com:443 (142.250.70.170:443)
192.168.1.106:51248: server connect inappcheck.itunes.apple.com:443 (23.199.68.241:443)
192.168.1.106:50389: client connect
192.168.1.106:51249: client connect
192.168.1.106:50388: client disconnect
192.168.1.106:51247: 192.168.1.106:51247: HTTP/2 protocol error: Received header value surrounded by whitespace b'com.google.ios.youtube/16.38.2 (iPhone9,4; U; CPU iOS 14_7_1 like Mac OS X; en_AU) '
192.168.1.106:51248: Client TLS handshake failed. The client disconnected during the handshake. If this happens consistently for inappcheck.itunes.apple.com, this may indicate that the client does not trust the proxy's certificate.
192.168.1.106:51248: client disconnect
192.168.1.106:51247: client disconnect

Steps to reproduce the behavior:

  1. Launch mitmweb on macbook
  2. Connect iPhone 7 to the proxy
  3. Open Youtube iOS app

System Information

Mitmproxy: 7.0.3
Python: 3.9.7
OpenSSL: OpenSSL 1.1.1l 24 Aug 2021
Platform: macOS-11.6-x86_64-i386-64bit

Activity

  1. added
    kind/triage
    on Oct 2, 2021
  2. mhils commented on Oct 2, 2021

    @mhils
    Member
  3. trungtly commented on Oct 2, 2021

    @trungtly
    Author
  4. mhils commented on Oct 2, 2021

    @mhils
    Member
  5. added and removed
    kind/triage
    on Oct 3, 2021
  6. changed the title [-]Youtube iOS app unable to connect[/-] [+]HTTP/2 protocol error: Received header value surrounded by whitespace[/+] on Oct 3, 2021
  7. rinsuki commented on Nov 29, 2021

    @rinsuki
    Contributor

    9fed8ae#diff-6b44693c3a91cce56d2b6fafa62f8d2eadae6bf67ff04547d9f1e91eabeb6aacL40

    It looks we need to split validate_inbound_headers to something like validate_inbound_headers (validates potentially danger things) and validate_inbound_headers_strictly (strictly validates, for pass h2spec), right?

  8. rinsuki commented on Nov 29, 2021

    @rinsuki
    Contributor

    UPDATE: actually validate_inbound_headers is directly passed to external h2 library, so we need to:

    • disable validate in h2 library by default (like before 9fed8ae)
    • and validates potentially danger things in mitmproxy
  9. AlbertoFDR commented on Jan 10, 2022

    @AlbertoFDR

    Any update? 🙃

    If you try to visit dropbox.com throws the same exception.

  10. mhils commented on Jan 11, 2022

    @mhils
    Member

    For now the recommended workarounds are to either use 7.0.2 or to pass --no-http2. Of course, if you are looking at your own client you should just send correct HTTP/2.

    Fixing this shouldn't be too hard, we "just" need to disable inbound header validation again (9fed8ae#diff-6b44693c3a91cce56d2b6fafa62f8d2eadae6bf67ff04547d9f1e91eabeb6aacL40) and then add a manual check that there are no transfer-encoding headers. We do need to be a bit careful here and also detect TransFeR-EnCoDing and Transfer-Encoding  (with a whitespace), but taking some inspiration from hyper-h2's validate_headers we should be able to cover everything.

    Somewhat refs #4746.

  11. self-assigned this
    on Mar 16, 2022
  12. mhils commented on Mar 19, 2022

    @mhils
    Member

    This check can be disabled in mitmproxy 8 using the validate_inbound_headers option. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions