-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix resteasy-reactive-client hostname verification default #32932
Fix resteasy-reactive-client hostname verification default #32932
Conversation
...rest-client-config/runtime/src/main/java/io/quarkus/restclient/config/RestClientsConfig.java
Outdated
Show resolved
Hide resolved
.../client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java
Outdated
Show resolved
Hide resolved
.../client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/ClientBuilderImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This comment has been minimized.
This comment has been minimized.
The test failures are definitely related |
On the rest-client-reactive settings a custom hostname verifier is currently not supported. Adapted the tests accordingly as the builder fails early now throwing UnsupportedOperationException. For quarkusio#32932 (comment)
Sorry for that. Did not expect there to be tests for an unsupported feature. On the The general discussion if failing here with an exception makes sense is discussed here: #32932 (comment) In short: It should be the same behaviour for both unsupported features of the |
Should a CVE be opened for this for the affected versions so that affected users are notified by scanners? The actual weakness would be local to default From first sight the affected versions include: At least for other products CVEs were sometimes opened fur such trivial things, Applicable CWEs: |
As I have 0️⃣ time for at least the next week, I'll leave this up to @Sgitario and @sberyozkin |
This sounds reasonable to me +1 |
This comment has been minimized.
This comment has been minimized.
75e9b90
to
d9477f3
Compare
I added a test now to assert that certificate host name verification is now enabled by default and working. Build is also green now, based on the GitHub actions in the forked repository. |
cc @Sgitario |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me.
Though, there are still some custom hostname verifier classes that should be deleted now:
- MyHostnameVerifier1 and MyHostnameVerifier2 in RestClientCDIDelegateBuilderTest
- MyHostnameVerifier in HelloClientWithBaseUri
Also, squash all the commits, so we can proceed with merging these changes.
Many thanks!
Both custom HostnameVerifier and SSLContext are currently not supported by resteasy-reactive-client. This is documented as known limitations. This change aligns the implementation to the already present state for SSLContext. It makes the builder fail when HostnameVerifier is tried to be configured. The benefit is that it fails as early as currently possible and not only when the custom hostname verification would be needed later on. Switch both to UnsupportedOperationException. On the rest-client-reactive settings a custom hostname verifier is currently not supported. Adapted the tests accordingly as the builder fails early now throwing UnsupportedOperationException.
Since introduction of the setting 'verifyHost' the hostname verification was disabled by default for the resteasy-reactive-client, as the default value for boolean (primitive) is false. This disabled default makes the reactive client vulnerable to MITM attacks. In the meantime setting the config explicitly is a workaround e.g. with 'quarkus.rest-client.verify-host=true'. This change now adds a proper default both in the configuration and for the field in the reactive client builder implementation. Add test case for enabled host verification default
d9477f3
to
18f6f4c
Compare
@Sgitario I removed the unused hostname verifier classes from the tests now. I squashed it down to two commits, but these two are actually independent of each other:
From my perspective, only the second commit for enabling the hostname verification is necessary as a security fix backport to other branches, as it fixes the current vulnerability. |
✔️ The latest workflow run for the pull request has completed successfully. It should be safe to merge provided you have a look at the other checks in the summary. |
I think the pull request is now ready to be merged. |
@gastaldi would you mind a final review of this one and merging it if you're ok with it? Thanks! |
@Sgitario it looks good to me but I'll let @sberyozkin have the final say on this 😉 |
Hi, should this PR check if |
I suppose it can be handled in a follow up PR. @polarctos would you be OK with opening a new issue related to checking |
if 'verify-host Line 213 in 5bca78d
So, I think it's fine how it is now. |
Since introduction of the setting
verifyHost
in2.15.0.Final
the hostname verification was disabled by default for theresteasy-reactive-client
, as the default value forboolean
in Java (primitive) isfalse
.gsmet@941d3a6#diff-28d8221e6b920ee90f85249d3c250b932c207d6b2099fc9377984d7f550fe28d
A better configuration name value would have been a negated name like
disableHostnameVerification
, but renaming it is no longer possible as it would break compatibility.This disabled default currently makes the reactive client vulnerable to MITM attacks.
E.g. the following rest client builder from the documentation with
quarkus-rest-client-reactive-jackson
is vulnerable, as it does not fail during the SSL handshake:The expected exception has the cause
javax.net.ssl.SSLHandshakeException
. The test caseExternalWrongHostTestCase.java
currently only tests the disabling of hostname verification but not for a default secure behaviour.In the meantime setting the config explicitly is a workaround e.g. with
quarkus.rest-client.verify-host=true
.This enables hostname verification again also for the reactive client. But the default of Quarkus should instead be secure!
This change now adds a proper default both in the configuration and assigns safe initial values for the fields in the reactive client builder implementation.
Both custom
HostnameVerifier
andSSLContext
are currently not supported by resteasy-reactive-client.This is documented as known limitations.
This change also aligns the implementation for both to the already present state for
SSLContext
.It makes the builder fail when
HostnameVerifier
is tried to be configured. The benefit is that it fails as early ascurrently possible and not only when the custom hostname verification would be needed later on.
The general need for the configuration option of a custom hostname verifier still stays relevant, as it was also requested in #27901. Currently just having the possibility to completely disable hostname verification is preventing the chance to supply a suitable customised hostname verifier that implements custom verification rules.