-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
WIP: First pass at a reprodicible env for running under FIPS mode #16939
Closed
donoghuc
wants to merge
4
commits into
elastic:feature/fedramp-high-8.x
from
donoghuc:fips-container-exploration
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c4fa6bf
First pass at a reprodicible env for running under FIPS mode
donoghuc e30e728
Attempt to figure out timing
donoghuc a7224b0
Pattern for testing using standarized JVM config
donoghuc d5302be
Ensure gradle subtasks are configured to use bc
donoghuc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Start from the FIPS-compliant base image | ||
FROM docker.elastic.co/wolfi/chainguard-base-fips:latest | ||
|
||
# Install OpenJDK 21 | ||
RUN apk add --no-cache \ | ||
openjdk-21 \ | ||
bash | ||
|
||
# Create directory for security configuration | ||
RUN mkdir -p /etc/java/security | ||
RUN mkdir -p /root/.gradle | ||
|
||
# Copy configuration files | ||
COPY java.security /etc/java/security/ | ||
COPY java.policy /etc/java/security/ | ||
|
||
# Set environment variables | ||
ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk | ||
ENV PATH="${JAVA_HOME}/bin:${PATH}" | ||
|
||
# Create working directory | ||
WORKDIR /logstash | ||
|
||
# Copy the local Logstash source | ||
COPY . . | ||
|
||
# Initial build using JKS truststore | ||
# ENV JAVA_OPTS="-Djavax.net.ssl.trustStore=$JAVA_HOME/lib/security/cacerts -Djavax.net.ssl.trustStoreType=JKS -Djavax.net.ssl.trustStorePassword=changeit" | ||
RUN ./gradlew clean bootstrap assemble installDefaultGems testSetup --no-daemon | ||
|
||
# CMD ["sleep", "infinity"] | ||
RUN keytool -importkeystore \ | ||
-srckeystore $JAVA_HOME/lib/security/cacerts \ | ||
-destkeystore /etc/java/security/cacerts.bcfks \ | ||
-srcstoretype jks \ | ||
-deststoretype bcfks \ | ||
-providerpath /logstash/logstash-core/lib/jars/bc-fips-2.0.0.jar \ | ||
-provider org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider \ | ||
-deststorepass changeit \ | ||
-srcstorepass changeit \ | ||
-noprompt | ||
|
||
RUN keytool -importkeystore \ | ||
-srckeystore $JAVA_HOME/lib/security/cacerts \ | ||
-destkeystore /etc/java/security/keystore.bcfks \ | ||
-srcstoretype jks \ | ||
-deststoretype bcfks \ | ||
-providerpath /logstash/logstash-core/lib/jars/bc-fips-2.0.0.jar \ | ||
-provider org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider \ | ||
-deststorepass changeit \ | ||
-srcstorepass changeit \ | ||
-noprompt | ||
|
||
|
||
# Uncomment this out and build for interactive terminal sessions in a container | ||
# Currently this dockerfile is just for running tests, but I have been also using it to | ||
# do manual validation. Need to think more about how to separate concerns. | ||
ENV JAVA_SECURITY_PROPERTIES=/etc/java/security/java.security | ||
ENV JAVA_OPTS="\ | ||
-Djava.security.debug=ssl,provider \ | ||
-Djava.security.properties=${JAVA_SECURITY_PROPERTIES} \ | ||
-Djavax.net.ssl.keyStore=/etc/java/security/keystore.bcfks \ | ||
-Djavax.net.ssl.keyStoreType=BCFKS \ | ||
-Djavax.net.ssl.keyStoreProvider=BCFIPS \ | ||
-Djavax.net.ssl.keyStorePassword=changeit \ | ||
-Djavax.net.ssl.trustStore=/etc/java/security/cacerts.bcfks \ | ||
-Djavax.net.ssl.trustStoreType=BCFKS \ | ||
-Djavax.net.ssl.trustStoreProvider=BCFIPS \ | ||
-Djavax.net.ssl.trustStorePassword=changeit \ | ||
-Dssl.KeyManagerFactory.algorithm=PKIX \ | ||
-Dssl.TrustManagerFactory.algorithm=PKIX \ | ||
-Dorg.bouncycastle.fips.approved_only=true" | ||
|
||
ENV LS_JAVA_OPTS="${JAVA_OPTS}" | ||
# Run tests with BCFKS truststore | ||
CMD ["./gradlew","-PskipJRubySetup=true", "--info", "--stacktrace", "javaTestsOnly", "rubyTestsOnly"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
grant { | ||
// Your existing permissions | ||
permission java.lang.PropertyPermission "java.runtime.name", "read"; | ||
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.internal.spec"; | ||
permission java.lang.RuntimePermission "getProtectionDomain"; | ||
permission java.lang.RuntimePermission "accessDeclaredMembers"; | ||
permission org.bouncycastle.crypto.CryptoServicesPermission "tlsAlgorithmsEnabled"; | ||
permission org.bouncycastle.crypto.CryptoServicesPermission "exportKeys"; | ||
|
||
// Add provider permissions | ||
permission java.security.SecurityPermission "putProviderProperty.BCFIPS"; | ||
permission java.security.SecurityPermission "insertProvider.BCFIPS"; | ||
permission java.security.SecurityPermission "putProviderProperty.BCJSSE"; | ||
permission java.security.SecurityPermission "insertProvider.BCJSSE"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
security.provider.1=org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider | ||
security.provider.2=org.bouncycastle.jsse.provider.BouncyCastleJsseProvider fips:BCFIPS | ||
security.provider.3=SUN | ||
|
||
securerandom.source=file:/dev/random | ||
securerandom.strongAlgorithms=NativePRNGBlocking:SUN,DRBG:SUN | ||
securerandom.drbg.config= | ||
|
||
login.configuration.provider=sun.security.provider.ConfigFile | ||
|
||
policy.provider=sun.security.provider.PolicyFile | ||
policy.url.1=file:/etc/java/security/java.policy | ||
policy.expandProperties=true | ||
policy.allowSystemProperty=true | ||
policy.ignoreIdentityScope=false | ||
|
||
keystore.type=bcfks | ||
keystore.type.compat=true | ||
|
||
package.access=sun.misc.,\ | ||
sun.reflect. | ||
package.definition=sun.misc.,\ | ||
sun.reflect. | ||
|
||
security.overridePropertiesFile=true | ||
|
||
ssl.KeyManagerFactory.algorithm=PKIX | ||
ssl.TrustManagerFactory.algorithm=PKIX | ||
|
||
networkaddress.cache.negative.ttl=10 | ||
|
||
krb5.kdc.bad.policy = tryLast | ||
|
||
sun.security.krb5.disableReferrals=false | ||
sun.security.krb5.maxReferrals=5 | ||
|
||
jdk.disabled.namedCurves = secp112r1, secp112r2, secp128r1, secp128r2, \ | ||
secp160k1, secp160r1, secp160r2, secp192k1, secp192r1, secp224k1, \ | ||
secp224r1, secp256k1, sect113r1, sect113r2, sect131r1, sect131r2, \ | ||
sect163k1, sect163r1, sect163r2, sect193r1, sect193r2, sect233k1, \ | ||
sect233r1, sect239k1, sect283k1, sect283r1, sect409k1, sect409r1, \ | ||
sect571k1, sect571r1, X9.62 c2tnb191v1, X9.62 c2tnb191v2, \ | ||
X9.62 c2tnb191v3, X9.62 c2tnb239v1, X9.62 c2tnb239v2, X9.62 c2tnb239v3, \ | ||
X9.62 c2tnb359v1, X9.62 c2tnb431r1, X9.62 prime192v2, X9.62 prime192v3, \ | ||
X9.62 prime239v1, X9.62 prime239v2, X9.62 prime239v3, brainpoolP256r1, \ | ||
brainpoolP320r1, brainpoolP384r1, brainpoolP512r1 | ||
|
||
jdk.certpath.disabledAlgorithms=MD2, MD5, \ | ||
RSA keySize < 1024, DSA keySize < 1024, EC keySize < 224, \ | ||
SHA1, \ | ||
secp112r1, secp112r2, secp128r1, secp128r2, \ | ||
secp160k1, secp160r1, secp160r2, secp192k1, secp192r1, secp224k1, \ | ||
secp224r1, secp256k1, sect113r1, sect113r2, sect131r1, sect131r2, \ | ||
sect163k1, sect163r1, sect163r2, sect193r1, sect193r2, sect233k1, \ | ||
sect233r1, sect239k1, sect283k1, sect283r1, sect409k1, sect409r1, \ | ||
sect571k1, sect571r1, \ | ||
brainpoolP256r1, brainpoolP320r1, brainpoolP384r1, brainpoolP512r1 | ||
|
||
jdk.security.legacyAlgorithms=SHA1, \ | ||
RSA keySize < 2048, DSA keySize < 2048 | ||
|
||
jdk.jar.disabledAlgorithms=MD2, MD5, RSA keySize < 1024, \ | ||
DSA keySize < 1024, SHA1, \ | ||
secp112r1, secp112r2, secp128r1, secp128r2, \ | ||
secp160k1, secp160r1, secp160r2, secp192k1, secp192r1, secp224k1, \ | ||
secp224r1, secp256k1, sect113r1, sect113r2, sect131r1, sect131r2, \ | ||
sect163k1, sect163r1, sect163r2, sect193r1, sect193r2, sect233k1, \ | ||
sect233r1, sect239k1, sect283k1, sect283r1, sect409k1, sect409r1, \ | ||
sect571k1, sect571r1, X9.62 c2tnb191v1, X9.62 c2tnb191v2, \ | ||
X9.62 c2tnb191v3, X9.62 c2tnb239v1, X9.62 c2tnb239v2, X9.62 c2tnb239v3, \ | ||
X9.62 c2tnb359v1, X9.62 c2tnb431r1, X9.62 prime192v2, X9.62 prime192v3, \ | ||
X9.62 prime239v1, X9.62 prime239v2, X9.62 prime239v3, brainpoolP256r1, \ | ||
brainpoolP320r1, brainpoolP384r1, brainpoolP512r1 | ||
|
||
jdk.tls.disabledAlgorithms=MD5, SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \ | ||
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \ | ||
secp112r1, secp112r2, secp128r1, secp128r2, \ | ||
secp160k1, secp160r1, secp160r2, secp192k1, secp192r1, secp224k1, \ | ||
secp224r1, secp256k1, sect113r1, sect113r2, sect131r1, sect131r2, \ | ||
sect163k1, sect163r1, sect163r2, sect193r1, sect193r2, sect233k1, \ | ||
sect233r1, sect239k1, sect283k1, sect283r1, sect409k1, sect409r1, \ | ||
sect571k1, sect571r1, brainpoolP256r1, \ | ||
brainpoolP320r1, brainpoolP384r1, brainpoolP512r1 | ||
jdk.tls.legacyAlgorithms= \ | ||
K_NULL, C_NULL, M_NULL, \ | ||
DH_anon, ECDH_anon, \ | ||
RC4_128, RC4_40, DES_CBC, DES40_CBC, \ | ||
3DES_EDE_CBC | ||
jdk.tls.keyLimits=AES/GCM/NoPadding KeyUpdate 2^37, \ | ||
ChaCha20-Poly1305 KeyUpdate 2^37 | ||
|
||
crypto.policy=unlimited | ||
|
||
jdk.xml.dsig.secureValidationPolicy=\ | ||
disallowAlg http://www.w3.org/TR/1999/REC-xslt-19991116,\ | ||
disallowAlg http://www.w3.org/2001/04/xmldsig-more#rsa-md5,\ | ||
disallowAlg http://www.w3.org/2001/04/xmldsig-more#hmac-md5,\ | ||
disallowAlg http://www.w3.org/2001/04/xmldsig-more#md5,\ | ||
maxTransforms 5,\ | ||
maxReferences 30,\ | ||
disallowReferenceUriSchemes file http https,\ | ||
minKeySize RSA 1024,\ | ||
minKeySize DSA 1024,\ | ||
minKeySize EC 224,\ | ||
noDuplicateIds,\ | ||
noRetrievalMethodLoops | ||
|
||
jceks.key.serialFilter = java.base/java.lang.Enum;java.base/java.security.KeyRep;\ | ||
java.base/java.security.KeyRep$Type;java.base/javax.crypto.spec.SecretKeySpec;!* | ||
|
||
jdk.sasl.disabledMechanisms=CRAM-MD5, DIGEST-MD5 | ||
jdk.security.caDistrustPolicies=SYMANTEC_TLS | ||
jdk.io.permissionsUseCanonicalPath=false | ||
|
||
jdk.tls.alpnCharset=ISO_8859_1 | ||
|
||
org.bouncycastle.fips.approved_only=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I couldnt figure out a way to avoid downloading these deps at test time. I'll have to circle back to this.