Subject: [9front] Http parsing auth (Was Re: bug in Lynx' SSL certificate validation -> leaks password in clear text via SNI (under some circumstances) )

From: [email-masked]
Date: Fri, 20 Aug 2021 21:40:23 -0700

See below, which is a forward of a message I received a couple weeks ago.

The best I can tell is that the parser for lynx didn't understand the
authn part of the URI.  I think libhttpd doesn't have the same
problem--it just returns a bad uri, which is better than leaking.  I'm
looking at /sys/src/libhttpd/parsereq.c:/^parseuri .
/sys/src/libhttpd/parse.c parses the mime header, so it's not an issue
with requests that are sent with the authorization that way.  From
httpd(2):
     BUGS
          This is a rough implementation and many details are going to
          change.

Webfs(4) looks to handle things properly in parsing (
/sys/src/cmd/webfs/url.c ), but would still generate a URI that
libhttpd couldn't handle: /sys/src/cmd/webfs/url.c:^/Ufmt .

Questions: if my analysis is correct, should parseuri be made to parse
authuser and authpass?  Or is libhttpd not used as much and other
software is preferred?

Quoth Katherine Mcmillan <[email-masked]>:
> FYI
> 
> ________________________________
> From: Lynx-dev <lynx-dev-bounces+kmcmi046=[email-masked]> on behalf of Ariadne Conill <[email-masked]>
> Sent: 07 August 2021 10:17
> To: [email-masked] <[email-masked]>
> Cc: Axel Beckert <[email-masked]>; [email-masked] <[email-masked]>; [email-masked] <[email-masked]>; [email-masked] <[email-masked]>
> Subject: Re: [Lynx-dev] [oss-security] Re: bug in Lynx' SSL certificate validation -> leaks password in clear text via SNI (under some circumstances)
> 
> Attention : courriel externe | external email
> 
> Hi,
> 
> On Sat, 7 Aug 2021, Thorsten Glaser wrote:
> 
> > Axel Beckert dixit:
> >
> >> This is more severe than it initially looked like: Due to TLS Server
> >> Name Indication (SNI) the hostname as parsed by Lynx (i.e with
> >> "user:pass@" included) is sent in _clear_ text over the wire even
> >
> > I *ALWAYS* SAID SNI IS A SHIT THING ONLY USED AS BAD EXCUSE FOR NAT
> > BY PEOPLE WHO ARE TOO STUPID TO CONFIGURE THEIR SERVERS RIGHT AND AS
> > BAD EXCUSE FOR LACKING IPv6 SUPPORT, AND THEN THE FUCKING IDIOTS WENT
> > AND MADE SNI *MANDATORY* FOR TLSv1.3, AND I FEEL *SO* VINDICATED RIGHT
> > NOW! IDIOTS IN CHARGE OF SECURITY, FUCKING IDIOTS…
> 
> It turns out SNI is only marginally related to this issue.  The issue
> itself is far more severe: HTParse() does not understand the authn part of
> the URI at all.  And so, when you call:
> 
>    HTParse("https://foo:[email-masked]", "", PARSE_HOST)
> 
> It returns:
> 
>    foo:[email-masked]
> 
> Which is then handed directly to SSL_set_tlsext_host_name() or
> gnutls_server_name_set().  But it will also leak in the Host: header on
> unencrypted connections, and also probably SSL ones too.
> 
> As a workaround, I taught HTParse() how to parse the authn part of URIs,
> but Lynx itself needs to actually properly support the authn part really.
> 
> I have attached the patch Alpine is using to work around this infoleak.
> 
> Ariadne
>