fix(docker): remove libtcnative-1 at runtime when FIPS mode is detected#35777
fix(docker): remove libtcnative-1 at runtime when FIPS mode is detected#35777dsilvam wants to merge 2 commits into
Conversation
SSLEngine=off alone is insufficient to prevent the OpenSSL 3.x crash on FIPS-enabled hosts. libtcnative-1 still loads libcrypto.so.3 and calls OpenSSL for non-SSL operations (e.g. random number generation), which triggers EVP_MD_get0_provider+0x4 SIGSEGV when the FIPS provider (fips.so) is missing from Ubuntu 24.04. The fix removes libtcnative-1.so at container startup when FIPS mode is detected, before Tomcat starts. This prevents the native library from loading OpenSSL entirely. Tomcat falls back to pure Java NIO/JSSE. libtcnative-1 remains installed by default for non-FIPS environments. Fixes #34212 Related: #34067, PR #34213
|
Claude finished @dsilvam's task in 2m 22s —— View job Code Review
SummaryThe pivot from A few things worth a second look: Findings1. PR description and test plan are stale (medium) The description still says "remove 2.
3. Brittle
4. Volume override case (informational) If a user mounts a custom Not issues (verified)
|
The previous approach (rm -f libtcnative-1.so) was silently a no-op: the container runs as UID 65001 (non-root) and cannot unlink root-owned files under /usr/lib. The || true masked the EACCES, making the fix invisible in logs while the JVM continued to crash. Instead, remove the AprLifecycleListener entry from server.xml at container startup when FIPS mode is detected. server.xml lives under /srv/dotserver/tomcat/conf/ which is owned by the dotcms user, so no root privileges are needed. Without the AprLifecycleListener, Tomcat never calls Library.initialize() and libtcnative-1 is never loaded, preventing libcrypto.so.3 from being touched entirely. Also adds a post-condition grep to fail loudly if the sed did not remove the listener, so failures are visible in container logs. Fixes #34212 Related: #34067, PR #34213
Summary
Fixes the JVM crash (
SIGSEGVinlibcrypto.so.3 EVP_MD_get0_provider+0x4) that occurs when running dotCMS on FIPS-enabled hosts (e.g. RHEL with CIS Level 2 hardening).The fix shipped in PR #34213 (
SSLEngine=off) was insufficient. SettingSSLEngine=offonly prevents OpenSSL from being used for SSL connections, butlibtcnative-1still loadslibcrypto.so.3and calls OpenSSL for non-SSL operations (e.g. random number generation). On a FIPS-enabled kernel without the OpenSSL FIPS provider (fips.so, not shipped in Ubuntu 24.04), this triggers the same crash regardless of the SSL engine setting.This PR extends
15-detect-fips-and-set-ssl-engine.shto also removelibtcnative-1.soat container startup when FIPS mode is detected, before Tomcat starts. Tomcat then falls back to pure Java NIO/JSSE automatically.libtcnative-1remains installed in the image by default for all non-FIPS environments — no performance impact for the majority of installations.Changes
15-detect-fips-and-set-ssl-engine.sh: whenFIPS_ENABLED=true, removelibtcnative-1.so.0*before Tomcat starts, in addition to settingCMS_SSL_ENGINE=offSSLEngine=offalone is not sufficientTest plan
libtcnative-1must still load andCMS_SSL_ENGINE=on(no regression)/proc/sys/crypto/fips_enabled=1) — container must start without SIGSEGV, log must show[FIPS Detection] Removing libtcnative-1 to prevent OpenSSL initialization in FIPS modeCMS_DISABLE_APR_SSL=truepath still works on non-FIPS hostCMS_SSL_ENGINE=offmanual override still worksRelated
Closes #34212
Related: #34067, PR #34213, Freshdesk ticket #34489