Repository navigation
openssh: default withLdns to false - #571725
Conversation
ldns support can be used by openssh to perform in-process DNSSEC validation for ValidateHostKeyDNS=, but doing so also requires configuration of non-standard /etc/resolv.conf options that NixOS doesn't support.
Review dismissed automatically
philiptaron
left a comment
There was a problem hiding this comment.
I sent Claude on a research mission about these claims; following the links, the distros claim looks correct. Avoid your eyes if you don't like LLM reports, but it helped me say yes.
Distro survey
| Distro | ldns? | Citation |
|---|---|---|
| Debian | No | debian/rules: confflags has no --with-ldns |
| Ubuntu | No | debian/rules @ ubuntu/devel: no ldns anywhere |
| Fedora | No | openssh.spec (rawhide): %configure has no ldns. The 2009 changelog entry "Added dnssec support" (rhbz 205842) is unrelated. |
| Arch | No (dropped Feb 2024) | 78be9ea6 "Do not build against ldns", closing Arch openssh issue 2 |
| Alpine | No | main/openssh/APKBUILD |
| Gentoo | Opt-in USE flag, off by default | openssh-9.9_p2-r4.ebuild: IUSE="… ldns …" (not +ldns) |
| Void | Yes, default on | srcpkgs/openssh/template: build_options_default="fido2 gssapi ldns ssl" |
| Homebrew (non-distro) | Yes | Formula/o/openssh.rb: depends_on "ldns", --with-ldns |
| FreeBSD base (non-Linux) | Yes | secure/ssh.mk: MK_LDNS → -DHAVE_LDNS=1 |
| FreeBSD ports (non-Linux) | Yes | security/openssh-portable/Makefile: LDNS in OPTIONS_DEFAULT |
Arch's rationale
From 78be9ea6:
Since glibc 2.31 the trust-ad configuration option in /etc/resolv.conf
is available and offers DNSSEC validation.
This AD bit is unfortunately ignored by ldns.
With glibc >= 2.31 there is no longer a reason to rely on ldns as DNS
resolver.
In other words, ldns trusts the AD bit from any configured nameserver, which bypasses glibc's trust-ad guard.
Technical claims
"Requires non-standard /etc/resolv.conf options": true
ldns 1.9.2 resolver.c (from the nixpkgs ldns.src tarball), ldns_resolver_new_frm_fp_l:
keyword[LDNS_RESOLV_ANCHOR] = "anchor"; /* line 802 */
...
case LDNS_RESOLV_ANCHOR: /* line 936 */
/* a file containing a DNSSEC trust anchor */anchor <file> is ldns-only syntax. NixOS has no first-class way to write it: nixos/modules/config/resolvconf.nix only produces an options line.
"Immediately fail because it has no root trust anchor": a bit overstated
OpenSSH openbsd-compat/getrrsetbyname-ldns.c:
if (ldns_pkt_ad(pkt)) {
rrset->rri_flags |= RRSET_VALIDATED;
} else { /* AD is not set, try autonomous validation */
...
if ((err = ldns_verify_trusted(ldns_res, rrdata, rrsigs,
trusted_keys)) == LDNS_STATUS_OK) {If the upstream resolver sets AD (e.g. systemd-resolved with DNSSEC=yes, or a local unbound), the record is accepted as validated without any trust anchor. It only tries its own validation, the step that needs an anchor, when AD is absent. Even then the connection doesn't abort; the SSHFP match is just treated as unverified.
The non-ldns path also needs resolver config
Without ldns, OpenSSH uses glibc res_query, which (glibc ≥ 2.31) only passes the AD bit through when options trust-ad is set. NixOS already does this when useLocalResolver is enabled (resolvconf.nix#L16):
++ lib.optional cfg.useLocalResolver "trust-ad";So VerifyHostKeyDNS still works on a properly configured NixOS host after this PR. It just goes through glibc instead of ldns.
Nixpkgs history
ldns was turned on in 2342298229c8 "openssh: enable ldns" (Oct 2023):
ldns is used for validating DNSSEC responses. With ldns enabled, using
SSHFP records on DNSSEC signed zones allows connecting to ssh servers
with host keys being automatically validated.
Heads up for that author (@jcgruenhage). Their use case should keep working with a validating resolver plus trust-ad.
| etcDir ? null, | ||
| withKerberos ? false, | ||
| withLdns ? true, | ||
| withLdns ? false, |
There was a problem hiding this comment.
A very short comment here would be good, also mentioning what none standard line is required
There was a problem hiding this comment.
You'd need to add anchor /path/to/file/containing/one/DS to /etc/resolv.conf. NixOS doesn't have any sort of config option for that, and can't work with systemd-resolved.
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin staging-26.05
git worktree add -d .worktree/backport-571725-to-staging-26.05 origin/staging-26.05
cd .worktree/backport-571725-to-staging-26.05
git switch --create backport-571725-to-staging-26.05
git cherry-pick -x 0e0e7648c15bdfe55bd8eb11291b8cffd55c8cfa |
Openssh is built without ldns in nixpkgs as of recently [1,2] and so it was failing to perform DNSSEC validation of SSHFP records, causing backups to fail due to host key verification failures. Adding the `trust-ad` option to resolveconf fixes the issue, as dnsproxy performs DNSSEC validation already. It was still working on host bro because the dnsmasq module does this automatically, but that option has now been disabled since dnsmasq is not actually used as a DNS server. [1]: NixOS/nixpkgs#571725 [2]: NixOS/nixpkgs#578329
|
Heads up, I don't think this should have been backported. It broke my backups this morning due to I overall agree with the change, the setup I had was probably incorrect, but I'd have preferred if it had been a change when upgrading to 26.11 and not overnight. |
|
I'm not sure it should be either, TBH. Let's talk over at #578329 |
I believe it was a security issue. If you set the DNS server to a non-localhost address, ldns would trust the AD bit unconditionally, which would allow any attacker between you and your DNS server to spoof your SSH server's fingerprint. Edit: the Arch Linux repo linked by @philiptaron's Claude analysis has a decent write up on this issue and why it is a security issue https://gitlab.archlinux.org/archlinux/packaging/packages/openssh/-/work_items/2 |
ldns support can be used by openssh to perform in-process DNSSEC validation for ValidateHostKeyDNS=, but doing so also requires configuration of non-standard /etc/resolv.conf options that NixOS doesn't support.
This ends up making
sshrequest all of the DNSSEC resource records, then immediately fail because it tries to validate them without having a root trust anchor.For this reason, other major Linux distributions keep this option disabled; this change brings NixOS in-line with Debian, Fedora, etc.
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.