News for hackers. Stuff that matters.
Re:Bizarre and Unusual Uses of DNS by manuel_w on Saturday February 25, 2023 @04:45PM (#34940789)
Tangentially related: One can store SSH server host keys in DNS and tell the client to make use of them. (OpenSSH supports `VerifyHostKeyDNS=yes`.) This is an alternative to the client asking the user to confirm the server host key, which many people just blindly confirm.

I asked GitLab if they could make use of that, but it hasn't received much attention so far:

* https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/10376

Re:Bizarre and Unusual Uses of DNS by Nextgrid on Saturday February 25, 2023 @05:42PM (#34941204)
You'd need DNSSEC for this right? If not can't an MITM still intercept the DNS lookup and substitute their own key?

In fact, even if the original domain does support DNSSEC, can a userspace program such as the SSH client actually tell whether the record it just resolved was resolved using a DNSSEC-aware resolver?

Re:Bizarre and Unusual Uses of DNS by aaronmdjones on Saturday February 25, 2023 @05:52PM (#34941286)
Yes, you would need a DNSSEC-validating resolver, and no, ssh(1) can't confirm if the answer was actually validated or not.

There's an "ad" (Authenticated Data) flag in the DNS reply header that a resolver can set to 1 to indicate that it validated the answer, but an MITM can also just set that to 1. The client would have to do its own validation, and ssh(1) doesn't. Therefore, you can only safely use this if you use a DNSSEC-validating resolver, and you trust the resolver (e.g. you administer it yourself), and you have a trusted path between you and it (e.g. it's on your LAN).

Re:Bizarre and Unusual Uses of DNS by devman0 on Saturday February 25, 2023 @08:38PM (#34942220)
Trusted path could also be DoH or DoT as well, but yeah, not just 53/udp in the clear over the internet.
Re:Bizarre and Unusual Uses of DNS by 3np on Saturday February 25, 2023 @08:48PM (#34942264)
An example to work around this would be to run a validating resolver (for example unbound) on localhost of each host and have it forward to whatever DNS server you use today.

If you're on Ubuntu, you most likely have a local resolver running already.

Re:Bizarre and Unusual Uses of DNS by dgl on Saturday February 25, 2023 @10:52PM (#34942883)
On Ubuntu the default is to use systemd-resolved, which is actually a validating stub resolver. You just need to set DNSSEC=true (see man resolved.conf) and it will work*.

*: this is the definition of "work" that also means it won't resolve anything if anything is wrong with DNSSEC validation, but if you want to be secure you need it to fail closed.

Re:Bizarre and Unusual Uses of DNS by d110af5ccf on Saturday February 25, 2023 @11:04PM (#34942921)
Perhaps a solution such as dnscrypt-proxy and configuring it to forward requests that match certain patterns to a validating resolver on the local network would work? Requests that didn't match could be forwarded to some other resolver that wasn't configured to validate.
Re:Bizarre and Unusual Uses of DNS by skissane on Saturday February 25, 2023 @11:53PM (#34943157)
There should be an option for "validate but still return invalid data, just reflect validity in the AD bit". Is there?

That way most things will still work even DNSSEC is broken, and apps with higher security requirements can opt-in to "fail if invalid", by passing setting the AD bit on queries, and checking if it is still there on responses.

Re:Bizarre and Unusual Uses of DNS by yrro on Monday February 27, 2023 @07:11AM (#34955507)
I believe that is DNSSEC=allow-downgrade which is also the default.
Re:Bizarre and Unusual Uses of DNS by skissane on Monday February 27, 2023 @08:36AM (#34956201)
I thought “allow-downgrade” meant it would return unsigned data, but not invalidly signed data? I was talking about the latter case not the former.
Re:Bizarre and Unusual Uses of DNS by yrro on Monday February 27, 2023 @09:23AM (#34956702)
You could be right. I guess the documentation isn't terribly clear...
Re:Bizarre and Unusual Uses of DNS by skissane on Saturday February 25, 2023 @09:54PM (#34942595)
> and no, ssh(1) can't confirm if the answer was actually validated or not.

Isn’t this a gap in the API? res_query/etc should provide some way to find out if the response is validated or not. That would require either (1) a validating resolver running locally, or (2) a remote validating revolver, accessed over a secure protocol (such as DoT or DoH), which the system administrator has elected to trust. But the system should be able to tell applications, via some API, whether (1) or (2) hold or not

Re:Bizarre and Unusual Uses of DNS by dgl on Saturday February 25, 2023 @10:58PM (#34942904)
This is [was; the quote in the parent was edited] incorrect, the response includes `header.ad`, which on Linux is controlled by both what the resolver responds with and `option trust-ad` in /etc/resolv.conf, so the administrator can choose if they trust their resolver via "trust-ad".
Re:Bizarre and Unusual Uses of DNS by skissane on Saturday February 25, 2023 @11:47PM (#34943136)
Thanks for clarifying, that makes more sense. I was just going by what the person I was replying to was saying.

The man pages on my Linux box are too old to mention the trust-ad option, although newer Linux man pages do.

glibc defines a RES_TRUSTAD bit which is equivalent, so applications can choose to request and trust the AD bit even if resolv.conf isn't configured to do so. However, that doesn't appear to be documented anywhere other than the header file and the NEWS file in the glibc distribution. Both RES_TRUSTAD and trust-ad were added in glibc 2.31 (released Feb 2020).

Re:Bizarre and Unusual Uses of DNS by aaronmdjones on Sunday February 26, 2023 @04:38PM (#34949767)
Yes, I mentioned the AD header. However, I stand by my statement that ssh(1) cannot confirm whether the answer was actually validated because an MITM could have set that flag.
Re:Bizarre and Unusual Uses of DNS by skissane on Sunday February 26, 2023 @05:11PM (#34950099)
If ssh is using the GNU C Library’s resolv functions, and it isn’t setting RES_TRUSTAD, then glibc will automatically clear the AD bit unless the sysadmin has configured the trustad option in resolv.conf. A competent sysadmin would only do that in cases where MITM is impossible - either a local validating resolver, or DoT/DoH to a remote validating resolver. It is true that ssh has to trust the sysadmin to be competent and not enable that option in cases where MITM is possible, but I think that’s a general assumption for security that the sysadmin is doing the right thing, otherwise there are numerous other possible insecure configurations which might break ssh’s security. To double foolproof it, ssh_config could come with its own trustad setting independent of resolv.conf, so you’d have to set both.
Re:Bizarre and Unusual Uses of DNS by capableweb on Saturday February 25, 2023 @06:15PM (#34941420)
In that vein, is there something that could allow me to manage authorized_keys via DNS? Let's say I own capableweb.com, I'd love it if sshd could just read all records from keys.capableweb.com and use those as valid public keys.

I have bunch of personal servers, and bunch of keys in use, many of the servers are not automated (they're pets, not cattle), so when I rotate keys, it's sometimes a hassle.

Mostly asking just because it'd be fun.

Re:Bizarre and Unusual Uses of DNS by knewter on Saturday February 25, 2023 @06:33PM (#34941562)
A tiny bash script and a cronjob
Re:Bizarre and Unusual Uses of DNS by dgl on Saturday February 25, 2023 @06:54PM (#34941684)
As mentioned elsewhere in this thread, actually using SSHFP in a secure way is difficult.

Far better is to use SSH host certificates, then your known_hosts can simply have a @cert-authority * some-cert in it. (See https://www.lorier.net/docs/ssh-ca.html)

Re:Bizarre and Unusual Uses of DNS by toast0 on Saturday February 25, 2023 @06:55PM (#34941693)
You might consider checking in an authorized_keys file? Not as fun as dns, but maybe easier. You can use ssh-keyscan to build the file.
Re:Bizarre and Unusual Uses of DNS by benmanns on Saturday February 25, 2023 @08:04PM (#34942067)
If you trust GitHub you could curl https://github.com/capableweb.keys on startup
Re:Bizarre and Unusual Uses of DNS by Queue29 on Saturday February 25, 2023 @08:32PM (#34942193)
Similar idea: This runs as a cron/systemd timer and updates your authorized_keys from your GitHub account.

https://github.com/shoenig/ssh-key-sync

Re:Bizarre and Unusual Uses of DNS by samber on Sunday February 26, 2023 @02:07PM (#34948344)
Re:Bizarre and Unusual Uses of DNS by hamandcheese on Saturday February 25, 2023 @08:56PM (#34942305)
AuthorizedKeysCommand is what you are looking for.

https://man.openbsd.org/sshd_config#AuthorizedKeysCommand

Re:Bizarre and Unusual Uses of DNS by capableweb on Saturday February 25, 2023 @09:37PM (#34942514)
That is indeed what seems to be the most useful out of all the replies, thanks a lot!
Re:Bizarre and Unusual Uses of DNS by t0mas88 on Sunday February 26, 2023 @03:57AM (#34944116)
Be warned that when using this a lot of the security comes down to your own implementation of that command.

The suggested alternative using certificates is a much more standard way that has less ways to create holes in your security.

Re:Bizarre and Unusual Uses of DNS by capableweb on Sunday February 26, 2023 @11:45AM (#34946918)
Maybe I'm missing something obvious, but seems to be much more up to the security of my DNS setup rather than the command.

The command would basically hit "keys.my-domain.example" and return the values of each TXT record. Not sure what could go wrong here, besides if I lose DNS access, I won't have access to the boxes. Probably add some sort of caching as well for that.

But otherwise, it seems to be much more about the security of what goes into "keys.my-domain.example".

Re:Bizarre and Unusual Uses of DNS by t0mas88 on Sunday February 26, 2023 @02:20PM (#34948459)
That's what I meant. Just looking up a DNS record as an implementation sounds like a bad idea. You would have to set up thinks like DNSSec validation, and consider all the ways in which that could fail.
Re:Bizarre and Unusual Uses of DNS by Drewza on Saturday February 25, 2023 @11:20PM (#34943013)
There are also 'free for personal' use commercial systems that work in a similar way to some of the suggestions posted in the comments:

https://www.keystash.io

Re:Bizarre and Unusual Uses of DNS by Galanwe on Sunday February 26, 2023 @12:29AM (#34943312)
The cleanest way in your use case would be to store keys in an LDAP server instead of local users' authorized_keys You can plug any of your server to this LDAP and enjoy the same users and keys everywhere.
Re:Bizarre and Unusual Uses of DNS by ttyprintk on Sunday February 26, 2023 @02:24AM (#34943767)
An SSH certificate authority is what I’d choose for that. Can work with both user keys and host keys. The host certs have a field for demonstrating their hostname; the user certs have a field restricting their username. So, as the certificate authority you have a little more power than what you can distribute via DNS.
Re:Bizarre and Unusual Uses of DNS by sammax on Sunday February 26, 2023 @06:35AM (#34944765)
I’ve set up an AuthorizedKeysCommand that uses unbound to get the authorized keys for the server via DNSSEC, with the ability to specify keys for whole servers, users on servers or globally for all servers. This is pretty neat for my few private boxes, I wouldn’t advise it for something bigger or enterprise, an ldap or similar seems better for that.
Re:Bizarre and Unusual Uses of DNS by tptacek on Sunday February 26, 2023 @05:51PM (#34950534)
People scaling SSH authorization tend to set up SSH CAs (either directly, or baked into some higher-level management solution). SSH CAs scale down nicely, as well.
Re:Bizarre and Unusual Uses of DNS by matheusmoreira on Saturday February 25, 2023 @06:32PM (#34941558)
It's also possible to distribute PGP keys this way. Probably a much better solution than the keyserver mess.

https://www.pgp.guide/pgp_dns/

Re:Bizarre and Unusual Uses of DNS by throwawaaarrgh on Saturday February 25, 2023 @09:10PM (#34942382)
Please don't put security stuff in DNS. DNS isn't secure and DNSSEC is a travesty. Just take the records it gives "under advisement" and confirm it over TLS or another secure transport protocol.
Re:Bizarre and Unusual Uses of DNS by 3np on Saturday February 25, 2023 @11:32PM (#34943056)
* * *
Re:Bizarre and Unusual Uses of DNS by karlshea on Sunday February 26, 2023 @01:00AM (#34943471)
This is the tptacek bat signal
Re:Bizarre and Unusual Uses of DNS by whyever on Sunday February 26, 2023 @01:01AM (#34943475)
Re:Bizarre and Unusual Uses of DNS by teddyh on Sunday February 26, 2023 @01:28AM (#34943586)
And yet here we are, eight years later, DNSSEC adoption still growing.
Re:Bizarre and Unusual Uses of DNS by mike_d on Sunday February 26, 2023 @01:48AM (#34943651)
The rate of DNSSEC signed zones is growing, but the number of recursive resolvers that hard fail on validation failures is static or going down.

Unfortunately the user experience for a DNSSEC signature failure is so bad, the only option if you run a large ISP or corporate network is to just use the answer you get anyway.

Re:Bizarre and Unusual Uses of DNS by teddyh on Sunday February 26, 2023 @02:02AM (#34943702)
Since (regrettably, for other reasons), many people seem to be moving to use centralized resolvers which all, incidentally, do validate DNSSEC strictly, I doubt whether “number of recursive resolvers” is a valid proxy for “number of users using DNSSEC validation in practice” anymore.

In fact, I see a lot of people advocating for using centralized resolvers, and not even once have I seen a counter-argument in the form of DNSSEC validation being a problem.

Re:Bizarre and Unusual Uses of DNS by tptacek on Sunday February 26, 2023 @05:49PM (#34950518)
What does it matter if your centralized resolver across the Internet is doing DNSSEC? The same on-path attacker DNSSEC was designed to address can defeat DNSSEC on the path between you and the resolver. It's a baffling design.
Re:Bizarre and Unusual Uses of DNS by teddyh on Monday February 27, 2023 @03:35PM (#34961529)
It matters because the topic was whether DNSSEC is growing or not, specifically whether more or fewer users are using DNSSEC validating resolvers. You’re not just moving the goalposts, you’re changing the topic entirely.
Re:Bizarre and Unusual Uses of DNS by mike_d on Monday February 27, 2023 @10:18PM (#34965245)
The horse has been beaten to death - DNSSEC is dead. It continues to see adoption on the authoritative side because turning it on in a basic state and letting it limp along costs almost nothing.

Many recursive servers do validate DNSSEC, but disable it on a per-zone basis when validation failures happen and users start to complain.

tptacek raises an additional good point that DNSSEC does nothing to protect the last mile of a query. It also provides zero confidentiality.

dnscrypt was always a superior implementation, but saw little uptake because people blindly believed the DNSSEC propaganda.

Re:Bizarre and Unusual Uses of DNS by teddyh on Tuesday February 28, 2023 @06:00AM (#34967979)
From my perspective, DNSSEC is very much alive, and moreso every year. At work, we only ever see requests for more DNSSEC from everybody; both customers and TLDs/registries. Nobody at conferences, both formally and in informal conversations, has said anything against DNSSEC in principle. I used to say that I ever only saw one person argue against DNSSEC; and it was here on HN. I guess that I can now say that it is two people, both here on HN.

If validation failures were that common, I would think I, working at a domain registrar and authoritative DNS provider, would hear about it. The last mile problem would be solved by DoT/DoH, no?

If anything is a “dead horse”, it’s dnscrypt. Are you claiming that DNSSEC is some sort of industry conspiracy?

Re:Bizarre and Unusual Uses of DNS by tptacek on Tuesday February 28, 2023 @02:05PM (#34973393)
It's a conspiracy, but not from the industry, which has broadly rejected it. :)
Re:Bizarre and Unusual Uses of DNS by teddyh on Tuesday February 28, 2023 @02:38PM (#34973792)
What “industry” would that be? Certainly not the DNS industry, or their customers (i.e. anybody who wants a domain name). Do you mean “rejected” in the same sense as how IPv6 is still only slowly being adopted?
Re:Bizarre and Unusual Uses of DNS by tptacek on Sunday February 26, 2023 @05:57PM (#34950593)
Grab any list of the top domains on the Internet. My go-to has been the "Moz 500" --- I don't know what it is, or whether it's any good, but it's easy to get. Then write the trivial shell loop to `dig ds $domain`, and count how many of the top domains are signed. Some patterns will emerge: government sites, unsurprisingly, have subscribed themselves to the de jure government PKI that DNSSEC is, and commercial sites overwhelmingly do not.

It's very easy to just check this for yourself. There are increasing numbers of domains signed every year, because registrars and product companies have baked DNSSEC in as a feature. But the vast majority of zones don't matter: nobody ever looks anything up in them. The figure of merit is how many important zones are signed.

Re:Bizarre and Unusual Uses of DNS by xelle on Sunday February 26, 2023 @07:59PM (#34951673)
> `dig ds $domain`

Amusingly for this method to work the resolver must understand DNSSEC. This is because DS records exist solely at the parent side of a delegation. A resolver that is not aware of DNSSEC will look to the child as it would for any other kind of record type.

Re:Bizarre and Unusual Uses of DNS by gorgoiler on Sunday February 26, 2023 @01:26AM (#34943577)
This is fun but a more practical solution would be for “ssh host” to GET the host’s public key from https://host/.well-known/.

The OpenSSH daemon could host it for you if you could fit a tiny, vuln free httpd inside it — not an enormously onerous task given that the codebase already includes the implementation of a robust TCP daemon. Add ACME support and you’ve moved the TOFU MITM attack from being possible on every-new-client-connection to also having to coincide with the once-every-X-days for the HTTPS certificate renewal.

It’s a lot of new functionality which probably isn’t cool for the OpenSSH codebase, but it’s a pragmatic solution to plugging the gap between mankind’s universally deployed PKI and ssh’s ephemeral peer-to-peer verification.

Re:Bizarre and Unusual Uses of DNS by CGamesPlay on Sunday February 26, 2023 @03:12AM (#34943939)
Doesn't SSH already support using TLS keys for authentication? So, we can skip the whole HTTPS part of the equation.
Re:Bizarre and Unusual Uses of DNS by t0mas88 on Sunday February 26, 2023 @03:52AM (#34944091)
Jup, it does. And that was my first thought reading this as well.
Re:Bizarre and Unusual Uses of DNS by jleahy on Sunday February 26, 2023 @04:02AM (#34944127)
No it has its own certificate system, it’s not TLS and it’s not even X.509.
Re:Bizarre and Unusual Uses of DNS by growse on Sunday February 26, 2023 @05:22AM (#34944465)
Not being x.509 is arguably a good thing. :)
Re:Bizarre and Unusual Uses of DNS by AndyMcConachie on Sunday February 26, 2023 @04:02AM (#34944126)
Making SSH authentication dependent on HTTPS seems like a really bad idea.
Re:Bizarre and Unusual Uses of DNS by kedihacker on Sunday February 26, 2023 @04:24AM (#34944212)
Making ssh authentication dependent on honesty seems like a really bad idea.
Re:Bizarre and Unusual Uses of DNS by est on Sunday February 26, 2023 @08:38AM (#34945433)
However I'd wish the reverse is true, SSH via TLS connections, so I don't need to open another 22 port, and make my SSH hidden behind Cloudflare or something.
Re:Bizarre and Unusual Uses of DNS by chrisandchris on Sunday February 26, 2023 @04:43AM (#34944306)
So one needs to run an HTTP-Server for a host that only has SSH otherwise?

> but it's a pragmatic ...

I think we have different views of the word pragmatic if your pragmatic solution covers including a HTTP server in OpenSSH for serving a single (!) file while the other solution depends on something you most probably already use to connect to the server (DNS).

Re:Bizarre and Unusual Uses of DNS by gorgoiler on Sunday February 26, 2023 @05:36AM (#34944526)
Hah, I’m surprised you zoomed in on that part. All you have to do for the protocol is blurt out “HTTP/1.1 200 OK\n\nssh-rsa AAAAf00fcafe…=“ on port 443 instead of “SSH-2.0-OpenSSH_xyz EtcEtc” on port 22. I wouldn’t (and didn’t) suggest you include code to respond with the contents of files, nor should you even bother parsing the request*.

The harder parts are what is the client going to do, and how will you implement TLS at each end? For the client, you’ll want to link against an HTTP library that integrates with the client OS’s x509 PKI as that will be the axiom upon which your trust of the server is founded. Their host key was served in a connection signed by Let’s Encrypt, and you’ve got Let’s Encrypt in /etc/ssl/cacerts.pem or whatever.

The hardest part is adding a TLS implementation to OpenSSH and the crazy part is having it support ACME so it can fetch its own certificates**. There is precedent for this though — caddy includes support for negotiating issuance and renewal of SSL certificates via ACME:

https://caddyserver.com/

Adding a new feature like this comes with the responsibility of supporting it in production and fixing bugs (in this case, dealing with weird missing features) for the remaining lifetime of the product. It’s not something to be done as lightly as an HN comment, by any means. There are a lot of sensible reasons to use DNS to bootstrap trust but as others have pointed out it is a little naive to think that DNSSEC has anything like the level of deployment that HTTPS has achieved since ACME and Lets Encrypt showed up. I contend that it’s that aspect which makes my solution indeed a more practical method — pragmatic, even — of bootstrapping trust over The Internet in 2023.

* Yes, this will mean you cannot support clients that demand their content be encoded with xzip in ylang with zspace. We’re not writing a real httpd here, remember.

** If it’s using ACME HTTP then that makes the simplistic httpd a bit more complicated, of course. Now you have to blurt two responses instead of one.

Re:Bizarre and Unusual Uses of DNS by nousermane on Sunday February 26, 2023 @05:36AM (#34944528)
That's clever - let PKI (via letsencrypt or other ACME) deal with trust, by getting a certificate there.

It's a shame that OpenSSH can't use those directly. "ssh-keygen -i" can import individual keys, but alas - SSH certificate signatures are generated differently from X.509 certs.

Re:Bizarre and Unusual Uses of DNS by est on Sunday February 26, 2023 @08:35AM (#34945415)
> not an enormously onerous task given that the codebase already includes the implementation of a robust TCP daemon.

Yeah then you got at least two more problems. SSL and OCSP