[Libwebsockets] Proxy address parsing is broken on IPv6 input

Andy Green andy at warmcat.com
Wed Mar 6 12:50:23 CET 2019



On March 6, 2019 7:43:26 PM GMT+08:00, "Mateusz Stępień" <mateusz.stepien at netrounds.com> wrote:
>Hello,
>
>I tried to pass an IPv6 address as a proxy in a libwebsocket client and
>
>it looks like it fails on parsing here 
>https://libwebsockets.org/git/libwebsockets/tree/lib/core-net/client.c?id=ecb22183f9c41bed6d8260a90f5f6f8c159662e3#n63-76
>
>
>
>         p = strchr(vhost->http.http_proxy_address, ':');
>
>It parses part of the IPv6 address as port, and it later fails to 
>connect because proxy address and port are invalid. Working it around 
>with strrchr makes it fail later, because address passed to HTTP
>CONNECT 
>method is not surrounded by brackets, according to section 3.2.2 of 
>RFC3986 ( https://tools.ietf.org/html/rfc3986#section-3.2.2 ).
>
>https://libwebsockets.org/git/libwebsockets/tree/lib/roles/http/client/client-handshake.c?id=ecb22183f9c41bed6d8260a90f5f6f8c159662e3#n238
>
>Surrounding proxy_address with brackets does not help, it fails on 
>getaddrinfo, string passed there does not have the brackets stripped.

Mmm sounds broken for ipv6 case.

IIUI, solving it just means requiring ipv6 addresses with ports like "[::1]:443", and take care about trimming the [] cleanly... is that what you also understood from it?

-Andy


>https://libwebsockets.org/git/libwebsockets/tree/lib/roles/http/client/client-handshake.c?id=ecb22183f9c41bed6d8260a90f5f6f8c159662e3#n281
>
>This was reproduced on lws-minimal-ws-client-echo example, the only 
>change that was made to the example is to fill http_proxy_address and 
>_port in lws_context_creation_info with IPv6 address and port of a
>proxy.
>
>Mateusz
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>https://libwebsockets.org/mailman/listinfo/libwebsockets


More information about the Libwebsockets mailing list