fix(DnsPinning): Ensure to always lookup based on FQDN#59147
Conversation
|
/backport to stable32 |
31e56ed to
d413f74
Compare
|
/backport to stable33 |
b6f77cb to
aa45c07
Compare
provokateurin
left a comment
There was a problem hiding this comment.
Uh that is quite something 😅
aa45c07 to
2d3b281
Compare
| * @param string $hostname | ||
| * @return string |
There was a problem hiding this comment.
nit: @param/@return phpdoc comments are redundant with the type hints
There was a problem hiding this comment.
True, I have to figure out how to get PhpStorm to not do that when adding phpdoc comments.
2d3b281 to
f728b49
Compare
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
f728b49 to
5bc0ba6
Compare
|
I've realized that my fix has an unexpected side effect. It totally prevents the usage of relative domains, as all domains are being treated as FQDNs from a DNS point of view. That's totally fine for the app store - but a bit unexpected for other developers and might break some apps, as it's usually possible to use both relative and absolute domains on any HTTP request. As most apps use our implementation, I lean on fixing it before someone might complain about it (and hence merging it into stable33 and stable32). I can think of two ways to tackle that:
The suggested change here to discard the record if it doesn't match the requested host would have the same unexpected side effect as my fix does. So, that solution is not possible, unfortunately. Also, as the example with Any thoughts on this? @kesselb @provokateurin @ChristophWurst |
|
Unfortunately I absolutely lack expertise in this area. I don't know. |
I've looked into that a while ago, because resolving via curl would also address some issues in gated networks using proxies for outgoing connections, but it wasnt possible at this time. Since PHP 8.4 we have https://www.php.net/manual/en/curl.constants.php#constant.curlopt-prereqfunction, that could work. However we have the connection established already, so not ideal either. Also not usable for us at the moment because PHP 8.4 or newer. |
Ohh, do you have more information about that for me? I was looking into this during my vacation and it's possible with a little trick using the Additionally, we only get the IP the connection is being established to. If there are multiple A / AAAA records, there is no way we can switch over in case of a failure. I wanted to make a test to see how browsers like Firefox handle that case to see if that is something I should really care about or can ignore safely with DNS Pinning (e.g., to prevent malicious redirects). I was leaning towards the second option for that reason... But as there may be other features in the future we would have to implement ourself then as well, like DNS over TLS, I honestly don't like doing so. |
|
Case 1) Private network. Outgoing connections are only possible through HTTP proxy. The nextcloud host could only resolve internal domain names through the DNS resolver. Hence the only option was to disable DNS pinning because we were unable to resolve external domain names. Requests themselves were possible because resolving did happen through the proxy. Case 2) |
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:
github.com, it tried to resolve A, AAAA and CNAME recordsproxy.fjygbaifeng.eu.org.dreschner.netFor reproducing the issue on command line level, you can use the following command on a server with IPv6 connectivity:
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
3. to review, feature component)stable32)AI (if applicable)