Conversation
CodeQL's java/unsafe-cert-trust (alert #5) flagged the socket written to in AbstractSocketAppender. Client sockets already verify the server's hostname by default (#479), but the endpoint identification algorithm was set inside SSLConfigurableSocket, on a field, so the query could not see it on the path from ConfigurableSSLSocketFactory.createSocket() to getOutputStream(). ConfigurableSSLSocketFactory now applies hostname verification to the SSLSocket it returns, through SSLConfigurableSocket.applyHostnameVerification(), which returns the socket. SSLParametersConfiguration still makes the decision (and logs it) in configureExceptHostnameVerification(); its public configure() behaves as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019BddTdtdSnfEZadKuaxXYz
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Addresses code scanning alert #5 (
java/unsafe-cert-trust, Critical) atAbstractSocketAppender.java:264.Why the alert was still open
Since #479, client SSL sockets verify the server's hostname by default. But
SSLParameters.setEndpointIdentificationAlgorithm("HTTPS")andsetSSLParameters()were called on thedelegatefield insideSSLConfigurableSocket. CodeQL only counts that as a sanitizer when thesetSSLParameters()qualifier flows locally to the socket on the path from(SSLSocket) factory.createSocket(...)tosocket.getOutputStream(). So it couldn't see the verification.Change
ConfigurableSSLSocketFactorynow applies hostname verification to theSSLSocketit returns, through a privateconfigure()that returnsSSLConfigurableSocket.applyHostnameVerification(socket, verify). That helper sets the endpoint identification algorithm and returns the socket, so the returned socket passes through the sanitizer.SSLParametersConfiguration.configureExceptHostnameVerification()(package-private) still makes the decision and logs it: client sockets verify by default,<hostnameVerification>false</hostnameVerification>opts out, and below API 24 a warning is logged. The publicconfigure(SSLConfigurable)behaves exactly as before.SSLConfigurableSocket.setHostnameVerification(boolean)delegates to the same helper, so the logic lives in one place.No behavior change: each socket gets the same parameters as before, set once.
Tests
Added
socketFactoryVerifiesHostnameByDefaultandsocketFactoryHostnameVerificationCanBeDisabledtoSSLHostnameVerificationTest, which cover the factory path end to end. I couldn't run Gradle locally: the session's network policy blocksdl.google.com, so the Android Gradle plugin doesn't resolve../scripts/check-architecture-docs.shpasses. CI needs to confirm the build and tests.Deferred work considered: none of the 6 open issues touch
core.net.sslor the socket appenders. No upstream port applies, because upstream logback hits the same CodeQL pattern.馃 Generated with Claude Code
https://claude.ai/code/session_019BddTdtdSnfEZadKuaxXYz
Generated by Claude Code