-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Describe the bug
As part of #29888 (cc: @michalvavrik) a check was added for the address of the proxy which the proxy uses to connect to Quarkus.
When using the option quarkus.http.proxy.trusted-proxies
, it allows passing in a hostname that is then resolved via a DNS lookup. While this is expected to be slower and not recommended, I found that there is behavior in Vert.x 4.x that make is impossible to work with some DNS servers with the current implementation. I also see obstacles in mixed IPv4/IPv6 environments, CNAMEs and multiple IP addresses assigned to a host.
Expected behavior
For an incoming request the host name should be resolved to an IP address to be checked against the incoming IP address.
The description doesn't provide much how IPv4 and IPv6 are handled here. One could expect that remote IPv4 remote addresses are matched against host's resolved IPv4 addresses, and IPv6 remote addresses are matched against host's resolved IPv6 addresses. Also CNAME handling could be expected.
Actual behavior
With Vert.x 4.x, a one DNS query asking for both A and AAAA records will be sent. Only some DNS servers support it, while other don't. This was first reported here in the lase commend to this Vert.x issue: eclipse-vertx/vert.x#5035 (comment)
Apparently the behavior changed in Vert.x 5.x and will now send two separate queries, which is expected to work with all DNS servers.
In my case, the DNS queries lead always lead to timeouts after several seconds as a reply was never received, so my Quarkus application practically stopped.
Looking at the code, the DnsClient.lookup()
will return "The first found". So if a hostname has both an IPv4 and IPv6 address, only one of them will be matched independent if the remote IP address is an IPv4 or an IPv6 address.
While there is no description on how hostnames are handled, there seems to be no handling of multiple A and AAAA entries for a hostname, and no handling of CNAMEs.
How to Reproduce?
No response
Output of uname -a
or ver
No response
Output of java -version
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version
or gradlew --version
)
No response
Additional information
Instead of lookup()
, the methods resolveA()
and resolveAAAA()
could be better suited to resolve all IP addresses of a host depending if the caller is using an IPv4 or IPv6 address. Still this leaves the CNAME handling on the table to handled as well.
In the context of Keycloak where I'm currently evaluating this, I might not expose the functionality of passing in a host name either temporarily (given the open issues I see above), or permanently given the performance impacts the DNS look will have even if it succeeds until a Keycloak user shows a use case where this should be supported.
So from the perspective of Keycloak, I would be ok if the functionality to pass in a hostname would be deprecated and eventually dropped.
There is a discussion related to the same Quarkus option on a different subject here: #42760