[Libwebsockets] Proxy address parsing is broken on IPv6 input

Mateusz Stępień mateusz.stepien at netrounds.com
Wed Mar 6 12:43:26 CET 2019


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.

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


More information about the Libwebsockets mailing list