Skip to content

openssh: default withLdns to false - #571725

Merged
philiptaron merged 1 commit into
NixOS:stagingfrom
Skyb0rg007:openssh-ldns-drop
Oct 8, 2026
Merged

philiptaron merged 1 commit into
NixOS:stagingfrom
Skyb0rg007:openssh-ldns-drop

Conversation

@Skyb0rg007

Copy link
Copy Markdown
Contributor

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 ssh request 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

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.
nixpkgs-branch-check[bot]

This comment was marked as outdated.

@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, andir, dasJ, helsinki-Jo, numinit, philiptaron and wahjava and removed request for a team October 8, 2026 13:30
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. labels Oct 8, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team October 8, 2026 13:31
@Skyb0rg007
Skyb0rg007 changed the base branch from master to staging October 8, 2026 13:43
@nixpkgs-ci nixpkgs-ci Bot closed this Oct 8, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Oct 8, 2026
@nixpkgs-branch-check
nixpkgs-branch-check Bot dismissed their stale review October 8, 2026 13:49

Review dismissed automatically

@philiptaron philiptaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@philiptaron
philiptaron added this pull request to the merge queue Oct 8, 2026
Merged via the queue into NixOS:staging with commit fea9225 Oct 8, 2026
62 checks passed
@Skyb0rg007
Skyb0rg007 deleted the openssh-ldns-drop branch October 8, 2026 17:27
etcDir ? null,
withKerberos ? false,
withLdns ? true,
withLdns ? false,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very short comment here would be good, also mentioning what none standard line is required

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Skyb0rg007 Skyb0rg007 added the backport staging-26.05 Backport PR automatically label Oct 24, 2026
@nixpkgs-ci

nixpkgs-ci Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Backport failed for staging-26.05, because it was unable to cherry-pick the commit(s).

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

diogotcorreia added a commit to diogotcorreia/dotfiles that referenced this pull request Nov 18, 2026
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
@diogotcorreia

Copy link
Copy Markdown
Member

Heads up, I don't think this should have been backported. It broke my backups this morning due to VerifyHostKeyDNS=yes not trusting the fingerprints anymore, and took me a while to figure out this was the reason. As far as I can tell, this was not really a security issue?
A changelog entry would have been good too, but now that it has been backported I feel like it doesn't matter anymore.

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 added trust-ad to resolvconf's options and everything works now.

@philiptaron

Copy link
Copy Markdown
Contributor

I'm not sure it should be either, TBH. Let's talk over at #578329

@Skyb0rg007

Skyb0rg007 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

It broke my backups this morning due to VerifyHostKeyDNS=yes not trusting the fingerprints anymore, and took me a while to figure out this was the reason. As far as I can tell, this was not really a security issue?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: failed backport 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 1001-2500 This PR causes many rebuilds on Darwin and should most likely target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 2501-5000 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. backport staging-26.05 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants