-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Failure during connection to MYSQL on FIPS-compliant host #32910
Comments
Are you sure this works in native when native got built on a FIPS enabled host (that's a prerequisite for a FIPS enabled native build)? Otherwise the native build is equivalent to a JVM mode run with |
@jerboaa all commands from the reproducer (including the ones for building) were run on a host with fips enabled. |
@fedinskiy Sure, but Mandrel in use when generating the the app matters too. Which was used? Only the |
@jerboaa I build native via quakrus profile and docker:
|
Please build with |
Quick check that a native image is actually FIPS enabled is this (returns
|
As to the failure it seems to be caused by this:
which seems to then delegate to:
That cipher is not supported by the NSS FIPS provider by RH OpenJDK:
So it's the Is there any particular reason why |
Also, I see message |
Also, it looks like[1] |
This is for some Quarkus dev to answer. I don't know. |
Ideally the mysql Java driver would allow for a config to select which cipher to use. Currently it looks hard-coded: https://github.com/mysql/mysql-connector-j/blob/release/8.0/src/main/protocol-impl/java/com/mysql/cj/protocol/a/authentication/Sha256PasswordPlugin.java#L171 @Sanne Would you know if that driver supports it? If not, an issue should probably filed for this (not sure where they have the bug tracker). |
More general grep:
Also it seems weird, that running native seems to be "curing" the JVM mode. |
Sorry, my bad for the wrong instructions on how to determine after-the-fact whether or not it's a fips enabled image or not. This is still to be determined. |
I cannot parse this, sorry. What do you mean? Could you reword, please? |
See step 8 of the reproducer. We run jar, it fails, we run binary, it succeeds, we run jar again, it now also succeeds |
@fedinskiy it is possible to supply your own custom authentication plugin: which has to implement the The default authenticaton plugin is You could build off your custom authentication plugin based on this and override the method which is at fault. Worth noting that, If you are running in native mode, make sure that the class implementing the custom authentication logic is registered for reflection. |
@machi1990 I thought, that Quarkus supports FIPS out-of-the-box. Can I consider this an official recommendation? Is it documented anywhere? For context: I am a member of Quarkus QE team, so my goal is less about "make the app work" and more about "make sure, that there are no nasty surprises for users" |
Thanks. I'd attribute this behaviour to some caching mechanism of the driver. Aside: @fedinskiy Are you saying that even a FIPS enabled native image (as produced here) works? That'd be a surprise and would have to get investigated. |
+1 to "make sure, that there are no nasty surprises for users". The goal should be that it works smoothly in the default case (in FIPS). |
+1 I am also worried that if we follow @machi1990 suggestion (thanks for taking your time to answer!) customers lose support (MySQL is officially supported with RHBQ 2.13 https://code.quarkus.redhat.com/?extension-search=origin:platform%20mysql) Do you by chance know what is supported solution? |
I don't know much about FIPS specifics, but I see several comments referring to Yes it can, MySQL supports several authentication plugins and that is just one of the many ones; e.g. see For example |
And according the these comments, not only could we extend the set of plugins with a custom one, but we could also override the default ones it's providing: (that seems like a last resort though, I'd expect the driver to be able to work with FIPS out of the box, but it might be useful if we wanted to "decorate" some of the basic ones for improved user experience) |
(I only see now that @machi1990 had provided very similar information, sorry for the noise!) In regards to support concerns of such an approach... yes I wouldn't expect end users to need to provide a custom plugin. |
@jerboaa no, the native image, built with custom mandrel doesn't work, thank for the info.
So, for native image to support fips, it should be built with @Sanne as I understand, this plugin requires changes in jdbc connection string[1]. However, if the ssl is enabled ( eg
[1] https://stackoverflow.com/questions/48688140/mysql-jdbc-encryption-using-ssl |
We are finally on the same page. Thanks.
Yes, for native fips support it has to be the product build of Mandrel (which RHBQ 2.13 uses, btw). That's the default image if you are on RHBQ 2.13 (so in a way you don't need to do anything other than build on a fips enabled host). There will need to be some documentation at some point. First step: Support FIPS in JVM mode, document that, then native documentation will follow. I'm the one responsible for FIPS support in Mandrel, so I might be able to help with certain JVM mode cases too. |
@Sanne yes. |
@fedinskiy Please update the description of this issue that it doesn't matter whether or not it's JVM or native (as we've shown that a fips enabled native image fails the same way as JVM mode). |
ok great. We shouldn't change the default, this is a matter of documentation and testing the configurations. |
+1 |
@fedinskiy Could you give |
@jerboaa according to the manual[1], it should be enabled by default. Are there any additional actions to be done? [1] https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html |
@fedinskiy Sorry, I have no idea about how to use the one over another. @Sanne would probably be your best bet. Though, the original stacktrace suggests it goes from |
It should work, if you could share some way to reproduce it (how did you setup the db exactly?) I can try debugging it. |
@Sanne I think it's just the |
But I guess you'd have to have a FIPS enabled system |
sorry I might try to help with that but I'm travelling & fully scheduled for the upcoming two weeks, I don't think I'll have time to setup a FIPS server on RHEL soon. But also for sake of future maintenance, could we find a way to have integration tests upstream? No container images freely available? |
@Sanne All RH UBI openjdk images have FIPS support. But enabling of it is a kernel feature. So you'd need to run the container on a FIPS enabled system. E.g. |
I tried to follow this manual[1] to use RSA over unencrypted connection First using the plugin with disabled ssl: I also tried to use secure connection
with a different error:
[1] https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html |
@fedinskiy can this be closed now? |
I the app is built with |
Describe the bug
I have an application, which uses
quarkus-hibernate-orm-panache
andquarkus-jdbc-mysql
to connect to MYSQL instance. When I run the application ( or integration test) on a RHEL machine with enabled FIPS mode, connection fails.Expected behavior
Application should establish the connection successfully.
Actual behavior
How to Reproduce?
git clone [email protected]:fedinskiy/reproducer.git -b mysql-fips
mvn clean package -Dquarkus.platform.version=3.0.1.Final -DskipTests
cp -r target/quarkus-app/ .
java -jar quarkus-app/quarkus-run.jar
— this robustly fails.The same can be reproduced for Native mode:
mvn clean package -Pnative -DskipTests -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=registry.access.redhat.com/quarkus/mandrel-22-rhel8:22.3
target/code-with-quarkus-1.0.0-SNAPSHOT-runner
Surprisingly, if we run native binary, which was built without support for native mode, then the connection starts working:
mvn clean package -Dquarkus.platform.version=3.0.1.Final -DskipTests -Pnative
target/code-with-quarkus-1.0.0-SNAPSHOT-runner
— this succeedsjava -jar quarkus-app/quarkus-run.jar
— now this also succeeds, unless we restart the dbOutput of
uname -a
orver
4.18.0-425.19.2.el8_7.x86_64
Output of
java -version
11.0.18, vendor: Red Hat, Inc
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.0.1.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Additional information
The text was updated successfully, but these errors were encountered: