Skip to content

fix(DnsPinning): Ensure to always lookup based on FQDN#59147

Open
DerDreschner wants to merge 1 commit intomasterfrom
fix/use-fqdn-for-dns-pinning
Open

fix(DnsPinning): Ensure to always lookup based on FQDN#59147
DerDreschner wants to merge 1 commit intomasterfrom
fix/use-fqdn-for-dns-pinning

Conversation

@DerDreschner
Copy link
Contributor

@DerDreschner DerDreschner commented Mar 21, 2026

Summary

After upgrading my private server from Debian 12 to Debian 13, I've experienced the same issue mentioned in #56489 which resulted in the app store to be totally unusable. Upgrading the Nextcloud version worked without any issues tho.

The investigation got the following results:

  • The main issue is the DNS Pinning
  • When looking up github.com, it tried to resolve A, AAAA and CNAME records
  • It only got an A and AAAA record back
  • The A record had the correct host and IP, but the AAAA record didn't. It was the result for github.com.dreschner.net
  • cURL tries to connect via the (incorrectly) provided IPv6 address first
  • The certificate doesn't match the expected hostname and resulting in the error 60

For reproducing the issue on command line level, you can use the following command on a server with IPv6 connectivity:

curl -v https://github.com/nextcloud-releases/integration_giphy/releases/download/v2.2.0/integration_giphy-v2.2.0.tar.gz --resolve 'github.com:443:140.82.121.4,2a0a:4cc0:c1:71d6:1876:e0ff:fe86:4038'

The reason is that we don't use FQDNs for resolving the DNS records and GitHub doesn't provide an AAAA record. Therefore, the program behind dns_get_records() looks for the host as subdomain of the local domain name. This works as I have a wildcard AAAA record set-up.

The fix is easy: just add a . at the end to make the requested domain name a FQDN and prevent the lookup under the local domain name when no record is being found in the first lookup.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@DerDreschner DerDreschner requested a review from a team as a code owner March 21, 2026 19:08
@DerDreschner DerDreschner requested review from ArtificialOwl, icewind1991, provokateurin and salmart-dev and removed request for a team March 21, 2026 19:08
@DerDreschner DerDreschner added bug 3. to review Waiting for reviews labels Mar 21, 2026
@DerDreschner
Copy link
Contributor Author

/backport to stable32

@DerDreschner DerDreschner force-pushed the fix/use-fqdn-for-dns-pinning branch from 31e56ed to d413f74 Compare March 21, 2026 19:25
@DerDreschner
Copy link
Contributor Author

/backport to stable33

@DerDreschner DerDreschner force-pushed the fix/use-fqdn-for-dns-pinning branch from d413f74 to b6f77cb Compare March 21, 2026 19:31
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
@DerDreschner DerDreschner force-pushed the fix/use-fqdn-for-dns-pinning branch from b6f77cb to aa45c07 Compare March 21, 2026 19:39
@DerDreschner DerDreschner enabled auto-merge March 21, 2026 19:44
Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

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

Uh that is quite something 😅


// Before looking up any DNS record, we need to make sure the
// provided target is an FQDN by adding a dot to the end.
$target = str_ends_with($target, '.') ? $target : "$target.";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$target = str_ends_with($target, '.') ? $target : "$target.";
if (!str_ends_with($target, '.')) {
$target .= '.';
}


// Before looking up any DNS record, we need to make sure the
// provided target is an FQDN by adding a dot to the end.
$target = str_ends_with($target, '.') ? $target : "$target.";
Copy link
Contributor

@kesselb kesselb Mar 21, 2026

Choose a reason for hiding this comment

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

Would prefer rtrim($target, '.') . '.' ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe through a small helper function enforceFdqn or such.

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

Labels

Projects

None yet

3 participants