Bug in Lynx's SSL certificate validation – leaks password in clear text via SNI
openwall.com
openwall.com
From [0], the issue arises when they send "user:pass@host" to SSL_set_tlsext_host_name, which happily sets the SNI to whatever it's given [1]. As a point of comparison, when you create a Rustls client via ClientSession::new [2], you have to pass it a DNSNameRef, which will validate that there's no auth component in the string it wraps, and return an error if you try to set the server name to something involving auth details.
I'm sure there's reasons why OpenSSL is set up to work like this, but I can't see why anyone would ever want to send those auth details in the clear in the SNI, and I wish it provided an API that would anticipate this misuse, like in Rust. The OpenSSL docs don't indicate it's an issue you should think about when invoking this function [3].
I realise I'm picking on OpenSSL here, and GnuTLS appears to do the exact same thing. I'm just not certain anyone not wearing a hazmat suit and being watched by multiple other trained professionals should be handling OpenSSL code.
0: https://www.openwall.com/lists/oss-security/2021/08/07/7
1: https://github.com/openssl/openssl/blob/5cbd2ea3f94aa8adec9b...
2: https://docs.rs/rustls/0.19.1/rustls/struct.ClientSession.ht...
3: https://www.openssl.org/docs/man1.1.1/man3/SSL_set_tlsext_ho...
However, this doesn't cover DNS name validation for the hostname:
"This specification does not mandate a particular registered name lookup technology and therefore does not restrict the syntax of reg-name beyond what is necessary for interoperability"
It also doesn't constrain the userinfo ("username:password") part described in this vulnerability.
So yeah, it's non-trivial.
authority = [ userinfo "@" ] host [ ":" port ]
described in section 3.2 of that specification. Looks pretty trivial to me.The RFC reads:
> Use of the format "user:password" in the userinfo field is deprecated.
In the real world, for HTTP use cases, you can't just ignore this because it's deprecated.
Yes. So, a correct implementation can't use this document to destructure it, but that's OK because it doesn't need to do so. It can however easily distinguish the userinfo from the rest of the authority.
Unless, like this code, it simply doesn't bother to try.
> In the real world, for HTTP use cases, you can't just ignore this because it's deprecated.
Then I guess you'll need to write code to further parse the userinfo. Seems pretty easy, but this document doesn't explain how because it's deprecated. No impact on whether you can find the host name in the authority since that's a separate field from userinfo.
Assuming, of course, that you bother to separate userinfo from the domain name in the authority, which Lynx did not.
Currently, the only server names supported are DNS hostnames; however, this does not imply any dependency of TLS on DNS, and other name types may be added in the future (by an RFC that updates this document).
RFC 5280:
The subject alternative name extension allows identities to be bound to the subject of the certificate. These identities may be included in addition to or in place of the identity in the subject field of the certificate. Defined options include an Internet electronic mail address, a DNS name, an IP address, and a Uniform Resource Identifier (URI). Other options exist, including completely local definitions.
So it is feasible -- at scale -- for TLS clients to validate that DNS names in the SNI extension really are DNS names, and are not IP addresses or bits of URL.
Was Windows' Schannel also tested? Or this is simply due to the dev team having access to Linux and macOS?
Back then, when I still cared about textmode browsers, there was lynx. Then came w3m and links and they were the cool new stuff.
They had a menu where you could access email (Pine), manage your small amount of file space (downloads went here, then you'd go to the file manager to transfer them to your computer via ZModem), change your password, etc.
I have fond memories of Lynx, but I haven't used it since I switched to a provider that gave me a "real" connection.
Update: It seems there's a preliminary patch that will not fix http auth URLs, but will prevent the info leak: https://www.openwall.com/lists/oss-security/2021/08/07/7
As far as mitigations go, I guess any of these would work: don't use Lynx; don't use SNI (???); don't use plain auth.
[0]: https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Sy...
Thorsten Glaser appears to be another from the BSD school of "perfect" programmers who are held back by the inadequacies of literally everybody and everything else in the world. If only the TLS protocol was designed by Thorsten, and everybody else used it the way Thorsten thinks they should, then this program would be correct so it's not really his fault, it's our fault. See?
> Nah, SNI is a rather recent thing. But…
This "rather recent thing" was standardised in 2003 and thus is old enough that if it were human it could vote in a lot of the world. But it's true that in some versions of Lynx it wasn't available until July 2018. They only had three years to identify this gross parsing bug.
https://lists.nongnu.org/archive/html/lynx-dev/2021-08/msg00...
I wish it were the year 2060 so IPv6 could finally be used reliably.
Somehow I’ve avoided gaining an understanding of the details of the SNI protocol, so i can’t comment on its quality, but the achievement it has enabled is fairly profound.
You put the requested hostname (e.g. example.com) into the Client Hello message in cleartext so that the server knows which SSL site to direct you to / which SSL cert to give you. And the server has a config that matches up server certs with hostnames (and a default server cert) to return.
That's it. It's why people want to encrypt the client hello message, because that leaks info.
When a client connects to a TLS server it may (must in TLS 1.3 if it knows the name of the service) send a field labelled Server Name Indication that gives a name it intended to reach.
The SNI specification explains one type of name, a Fully Qualified Domain Name e.g. "news.ycombinator.com" (notice not "news.ycombinator.com." if you understand why that might matter) but leaves open the possibility that others could exist. They don't and in practice you likely couldn't add new ones now.
The server should look at this name & use it to decide what the client intended. For example if you're a bulk hosting site you might have fifty customers on a single physical machine and you can match the SNI name against the list of customer sites on that machine, then use this to present the appropriate certificates and use the right keys so the connection works and is trusted by the client for that name.
For HTTPS the server should further reason that if the SNI says news.ycombinator.com but then an HTTP/1.1 Host header says some.other.example that's nonsense and deserves an error. Likewise it should reason that if you send SNI for this.does.not.exist.example and it has no records of a this.does.not.exist.example site, it should just give you the TLS error saying it doesn't recognise the name and never get to HTTP at all.
In practice several popular web server programs (e.g. Apache) treat these two stages as entirely unrelated problems, so you can connect to a bulk host, use SNI to say you want corpA.example, and then in HTTP/1.1 ask for corpB.example and it's common that the web server will give you the corpB.example web site, but served with the corpA.example certificates and encryption... if you send SNI for this.does.not.exist.example you may get a randomly chosen or alphabetically first certificate and then an HTTP 404 error...
The more modern ALPN is similar but for protocols instead of names, this lets clients specify which "next" protocols they want to speak on top of TLS. So for example "h2" means you'd like to use HTTP/2 instead of HTTP/1.1 to talk to a web server. The server can reply to ALPN by specifying which of the list you offered it agrees to e.g. it can say it only speaks HTTP/1.1 -- or it can ignore your request entirely.
However I suspect that by now somebody would have spotted that we're smuggling the thing we actually wanted to convey via the IPv6 address. some.specialised.thing.example resolves to an address with a particular combination of low 64-bits which are then de-coded by server software listening on that entire subnet as some.specialised.thing.example. And somebody would have proposed just actually transmitting the text across the wire instead.
So I expect that today SNI would exist or at least, the exact same discussion that led to eSNI and today ECH would have happened for other reasons in the world where everybody has IPv6 and the fix for that would be under development.
If you have plentiful IPv6 addresses the privacy aspect still matters, but maybe it gets pushed out further and we're only talking about it now rather than earlier.
One of the things we see with the Great Firewall is that you can reach some brand new service, and then a few minutes later (after presumably some automation span up, examined it and didn't like what it found) it's blocked.
In contrast under ECH Winnie can choose to have 10.20.30.40 blocked, and if the only things on it are winnie-the-pooh.china.example and kick-putin-out.russia.example then why not. But if it also features popular-website.example then that's a difficulty.
If it helps while I expect Cloudflare will continue as before, ECH is actually carefully designed so that intermediates can be set up to be able to discern that you want winnie-the-pooh.example and make that work without in fact knowing how to answer for that name. In effect you can sign up to have some popular host (e.g. Google, Amazon, or indeed Cloudflare) provide their servers for your names, but not provide your services and not have any ability to MITM you, they're acting as a sort of IP proxy instead. And some of the big names are clearly enthusiastic about enabling this capability, albeit for a price.
https://news.ycombinator.com/newsguidelines.html
Also, please don't cross into personal attack. You can make your substantive points without that.