-
Notifications
You must be signed in to change notification settings - Fork 0
Adds TLS SNI to ghidra client connections #8
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* ### | ||
| * IP: GHIDRA | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package ghidra.framework.client; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.*; | ||
| import java.util.*; | ||
|
|
||
| import javax.net.ssl.*; | ||
| import javax.rmi.ssl.SslRMIClientSocketFactory; | ||
|
|
||
| /** | ||
| * <code>GhidraSSLClientSocket</code> facilitates ability to impose client authentication | ||
| * for SSL server sockets used with Ghidra Server RMI connection. | ||
| */ | ||
| public class GhidraSSLClientSocket extends SslRMIClientSocketFactory { | ||
| /** | ||
| * Creates an SSLSocket on a given port | ||
| * | ||
| * @throws IOException if an error occurs on socket creation. | ||
| */ | ||
| public Socket createSocket(String host, int port) throws IOException | ||
| { | ||
| SSLSocket sslSocket = (SSLSocket) super.createSocket(host, port); | ||
| List<SNIServerName> serverNames = Arrays.asList(new SNIHostName(host)); | ||
| SSLParameters params = sslSocket.getSSLParameters(); | ||
|
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. Security Improvement Opportunity: Consider adding error handling for SNI configuration in Recommendation: try {
List<SNIServerName> serverNames = Arrays.asList(new SNIHostName(host));
SSLParameters params = sslSocket.getSSLParameters();
params.setServerNames(serverNames);
sslSocket.setSSLParameters(params);
} catch (IllegalArgumentException e) {
// Log warning but continue with connection without SNI
// This could happen if the hostname is invalid for SNI
} |
||
| params.setServerNames(serverNames); | ||
| sslSocket.setSSLParameters(params); | ||
| return sslSocket; | ||
| } | ||
| } | ||
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.
💡 Verification agent
🧩 Analysis chain
Consider using the hostname rather than IP address for SNI.
SNI is designed to indicate the hostname being accessed, not the IP address. While using the IP address will work technically, it may not provide the expected behavior with certain proxy configurations that rely on hostname-based routing.
Note: This implementation would require tracking and passing the original hostname through the API. The current implementation using IP address will work for basic SNI functionality, but might not provide the optimal behavior with hostname-based proxy routing.
🌐 Web query:
💡 Result:
Using an IP address with SNI (Server Name Indication) is not valid according to the SNI specification and its intended purpose.
SNI is an extension to the TLS protocol that allows a client to specify the hostname (domain name) it wants to connect to during the TLS handshake, enabling servers to present the correct certificate for that hostname even when multiple domains are hosted on the same IP address[2][3][7]. The key point is that SNI is designed for hostnames, not IP addresses.
If a client attempts to use an IP address in the SNI field:
In summary:
SNI is designed to be used with domain names, not IP addresses. Using an IP address in the SNI field is not valid, and is not supported by the protocol or by major web servers. If you use an IP address in SNI, you will likely encounter connection errors or certificate warnings.[2][3][9]
Citations:
Use DNS hostname for SNI instead of IP address
SNI (per RFC 6066) must carry the server’s DNS name. Supplying an IP address will be ignored by many servers or cause a default‐certificate fallback, leading to TLS failures or certificate mismatches.
Please update the code at:
Suggested changes:
streamServerHostname) through your API.Example diff:
You’ll need to update the surrounding API to accept and pass along
streamServerHostnameaccordingly.