GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Respect jdk.tls.disabledAlgorithms in the OpenSSL SslEngine by normanmaurer · Pull Request #18514 · netty/netty Conversation
Member
Motivation: The JDK SSLEngine honors the jdk.tls.disabledAlgorithms security Modification: Add JdkDisabledAlgorithms, which parses the security property. Plain ReferenceCountedOpenSslContext removes disabled cipher suites and fails Many existing tests use legacy protocols and ciphers on purpose, so run Result: The OpenSSL SslEngine respects jdk.tls.disabledAlgorithms like the JDK. BREAKING CHANGE: JDKs disable SSLv3, TLSv1, TLSv1.1, RC4, DES, Co-authored-by: Claude Sonnet 5.5 [email protected]
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsMotivation: The JDK SSLEngine honors the jdk.tls.disabledAlgorithms security property, but the OpenSSL based engine ignored it. Protocols and cipher suites an application disabled that way were still enabled when switching to the OpenSSL provider. See netty/netty-tcnative#530 Modification: Add JdkDisabledAlgorithms, which parses the security property. Plain protocol names and algorithm names that are a component of a cipher suite name are supported, entries with constraints or directives are ignored. The property is read when an OpenSSL SslContext is created. ReferenceCountedOpenSslContext removes disabled cipher suites and fails if none are left, as an empty list would fall back to the OpenSSL defaults. ReferenceCountedOpenSslEngine does not enable disabled protocols, either from the context or via setEnabledProtocols(). Many existing tests use legacy protocols and ciphers on purpose, so run the handler tests with a java.security override that clears the property. Add tests that set the property explicitly. Result: The OpenSSL SslEngine respects jdk.tls.disabledAlgorithms like the JDK. BREAKING CHANGE: JDKs disable SSLv3, TLSv1, TLSv1.1, RC4, DES, 3DES_EDE_CBC, anon and NULL by default via this property. Explicitly enabling any of these on the OpenSSL engine no longer has an effect unless the property is changed. Co-authored-by: Claude Sonnet 5.5 <[email protected]> Motivation: The override that relaxes jdk.tls.disabledAlgorithms for the handler tests cleared the whole property. The JDK engine runs in the same JVM, so SSLv3 became usable there and SslHandlerTest.testHandshakeFailedByWriteBeforeChannelActive, which relies on an SSLv3 handshake failing, timed out on CI. Modification: Only relax the property while keeping SSLv3 disabled. Result: SslHandlerTest passes again, and the OpenSSL tests that use TLSv1, TLSv1.1 and legacy ciphers still work. Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
violetagg
requested changes
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Motivation: The review of the OpenSSL jdk.tls.disabledAlgorithms support found that disabled algorithms could still end up enabled: - cipher suite wildcards like TLS_RSA_* were not recognized - the standard JDK algorithm names (SHA1, DH, HmacSHA256, ...) did not match the cipher suites the JDK disables for them - cipher suites configured with their OpenSSL names (AES128-SHA) were not checked - setEnabledCipherSuites() on the engine could enable a disabled cipher suite again - a disabled protocol inside of the enabled [min, max] range was still enabled in OpenSSL Modification: Support '*' wildcards in TLS_ cipher suite entries and the JDK names for the key exchange (DH, DiffieHellman, DSA), MAC / hash (SHA1, SHA-1, HmacSHA1, HmacSHA256, ...) and DESede components. Convert OpenSSL cipher suite names to their Java name before evaluating them. Filter disabled cipher suites in setEnabledCipherSuites() and getEnabledCipherSuites(), and explicitly set SSL_OP_NO_* for disabled protocols within the enabled range. Result: The OpenSSL SslEngine evaluates jdk.tls.disabledAlgorithms the same way for the cases above as the JDK does. Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
yawkat
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (AI-generated) Combined code review / security audit of 131cd12. Most findings were reproduced with real handshakes on JDK 25 with tcnative-boringssl-static 2.0.86, some also with dynamic OpenSSL 3.6. The suggestions were checked with
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (AI-generated) Filtering before
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Motivation: Review of the jdk.tls.disabledAlgorithms support in the OpenSSL SslEngine found several ways a disabled protocol or cipher suite could still be negotiated, or the property was parsed differently from the JDK. Modification: - Treat SSL_ and TLS_ prefixed cipher suite names as equivalent, both in the property and for the names checked against it - Strip surrounding double quotes from the property value and tolerate null protocol names - Also match ChaCha20-Poly1305, NoPadding, C_NULL and the SHA-256 PRF hash of the _SHA cipher suites like the JDK - Raise the minimum protocol instead of leaving a gap when a protocol inside of the enabled range is disabled - Do not enable TLSv1.2 and below if only TLSv1.3 cipher suites are left, as an empty cipher list is a no-op for OpenSSL / BoringSSL - Apply the property to the default cipher suites if the filtered cipher list is empty instead of falling back to the unfiltered native ones - Validate cipher suites before filtering in setEnabledCipherSuites() and fail with a message mentioning the property if all are disabled - BoringSSL can not disable TLSv1.3 cipher suites, so report them as enabled and log a warning instead of hiding them - Add the missing license header to the test java.security override Result: Less deviation from the JDK behaviour and no way to re-enable disabled algorithms via the engine.
violetagg
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only applies when the property removed a suite. With
Suggested change
@Test void tlsv12IsNotEnabledIfOnlyTlsv13CipherSuitesAreConfigured() throws Exception { assumeTrue(OpenSsl.isTlsv13Supported()); Security.setProperty(PROPERTY, "TLS_RSA_*"); SslContext context = newServerBuilder() .protocols(SslProtocols.TLS_v1_2, SslProtocols.TLS_v1_3) .ciphers(Collections.singletonList("TLS_AES_128_GCM_SHA256")) .build(); ReferenceCountedOpenSslEngine engine = null; try { engine = (ReferenceCountedOpenSslEngine) context.newEngine(UnpooledByteBufAllocator.DEFAULT); assertThat(SSL.getOptions(engine.sslPointer()) & SSL.SSL_OP_NO_TLSv1_2).isNotZero(); } finally { ReferenceCountUtil.release(engine); ReferenceCountUtil.release(context); } }
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check again
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…figured Motivation: If jdk.tls.disabledAlgorithms is set and the configured cipher suites only contain TLSv1.3 ones, nothing was removed by the property, so TLSv1.2 stayed enabled and OpenSSL / BoringSSL fell back to its unfiltered default cipher suites for it. Modification: Check the final cipher suite list instead of whether the property removed a suite, and add a test. Result: TLSv1.2 and below can not be negotiated with default cipher suites that the property disabled.
|
There was an error while loading. Please reload this page.
🚨 All tests passed but jobs failed 🚨Failed Jobs without Test Failures❌ Build PR / linux-x86_64-java11-boringssl build 🏷️ Commit: 7413f23 Rerun ControlsClick the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| !(OpenSsl.isBoringSSL() && SslUtils.isTLSv13Cipher(cipherSuite)); | ||
| } | ||
|
|
||
| static String[] toEnabledProtocols(String[] protocols, JdkDisabledAlgorithms disabledAlgorithms) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Small thought: if a protocol in the middle of the requested range is disabled (say TLSv1, TLSv1.1, TLSv1.2 requested and TLSv1.1 disabled), setEnabledProtocols0 raises the minimum so only TLSv1.2 is on the wire. This method would still report TLSv1 in getEnabledProtocols(), so the two could disagree.
Would it make sense to apply the same "raise the minimum" rule here, or share one helper between both places? Happy to be told I am missing something.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| assertThat(options & SSL.SSL_OP_NO_TLSv1_1).as("SSL_OP_NO_TLSv1_1").isEqualTo(SSL.SSL_OP_NO_TLSv1_1); | ||
| // The range must stay contiguous, so everything below the disabled protocol is disabled as well. | ||
| assertThat(options & SSL.SSL_OP_NO_TLSv1).as("SSL_OP_NO_TLSv1").isEqualTo(SSL.SSL_OP_NO_TLSv1); | ||
| assertThat(options & SSL.SSL_OP_NO_TLSv1_2).as("SSL_OP_NO_TLSv1_2").isZero(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice test for the option bits. Maybe it could also assert engine.getEnabledProtocols() here? I think that would show whether the reported protocols match what is really enabled in this range case (see my comment on toEnabledProtocols).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| OpenSsl.defaultProtocols(mode == SSL.SSL_MODE_CLIENT) : protocols; | ||
| if (!disabledAlgorithms.isEmpty() && !unmodifiableCiphers.isEmpty() && | ||
| !hasNonTlsv13Cipher(unmodifiableCiphers)) { | ||
| // Only TLSv1.3 cipher suites are left. Setting an empty cipher list is a no-op for OpenSSL / BoringSSL, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Curious about one edge case: if someone configures only TLSv1.2 together with only TLSv1.3 suites, this loop produces an empty protocol array. What happens when an engine is created from that context? Maybe a clear failure at context creation would be friendlier, and a small test could pin the behavior down. Does that sound reasonable?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| switch (mac) { | ||
| case "md5": | ||
| return new String[] { "hmacmd5" }; | ||
| case "sha": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this one is slightly too broad. A _SHA suite also gets sha256 and hmacsha256 here, so an admin who disables only SHA256 would also lose all *_SHA suites (and NoPadding in cipherAliases similarly disables every CBC/GCM/ChaCha suite). I understand this mirrors how the JDK decomposes suites. Would it be worth limiting the aliases to the clear cases, or at least adding a comment on why the over-matching is intended?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
SHA256 -> *_SHA is what the JDK does too, so I'd keep that. NoPadding shouldn't cover ChaCha20 though, the JDK keeps those suites with NoPadding disabled.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking, and good catch! I double checked against the JDK 25 sources. You are right that SHA256 on *_SHA suites is intended: those suites carry H_SHA256 as their PRF hash, and SSLAlgorithmDecomposer turns that into SHA256/HmacSHA256. So please ignore my worry about that part, keeping it makes sense.
The ChaCha20 point looks right too. The JDK transformation for it is just ChaCha20-Poly1305 (no /NoPadding), while the AES CBC/GCM ones are AES/CBC/NoPadding and AES/GCM/NoPadding. So maybe the _chacha20_poly1305_ check could be dropped from the nopadding condition in cipherAliases? A small test with NoPadding disabled that expects a ChaCha20 suite to stay enabled might be a nice guard. What do you think?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * The security property is global state, so this test must not run concurrently with others. | ||
| */ | ||
| @Isolated | ||
| class OpenSslDisabledAlgorithmsTest { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Idea: all tests here check configuration (cipher lists, enabled protocols, native option bits). Would a single handshake test be a good addition? For example an OpenSSL server with TLSv1 disabled and a client that only offers TLSv1, expecting the handshake to fail. It would show the end-to-end promise of the PR. Also, most tests start with assumeTrue(...), so it might be worth double checking that CI runs them on at least one provider instead of skipping.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| <!-- Needed for SelfSignedCertificate --> | ||
| <argLine.java9.extras>--add-exports java.base/sun.security.x509=ALL-UNNAMED</argLine.java9.extras> | ||
| <!-- Tests use legacy protocols / cipher suites that are disabled via jdk.tls.disabledAlgorithms by default. --> | ||
| <argLine.javaProperties>-Djava.security.properties=${project.basedir}/src/test/resources/io/netty/handler/ssl/legacy-algorithms.java.security</argLine.javaProperties> |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Two small ideas here. First, ${project.basedir} is unquoted, so a checkout path with spaces would break the argument. Second, only this module gets the override. Do tests in other modules that use the OpenSSL provider (for example codec-http2 or handler-ssl-ocsp) still pass with the JDK default list? Maybe CI already answers this.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.