Skip to content
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

Add check to prevent the use of IP addresses as SNI hostnames #7483

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.os.Build;
import android.text.TextUtils;

import app.k9mail.core.common.net.HostNameUtils;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.ssl.TrustManagerFactory;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
Expand Down Expand Up @@ -129,7 +130,10 @@ public Socket createSocket(Socket socket, String host, int port, String clientCe

hardenSocket(sslSocket);

setSniHost(socketFactory, sslSocket, host);
// RFC 6066 does not permit the use of literal IPv4 or IPv6 addresses as SNI hostnames.
if (HostNameUtils.INSTANCE.isLegalIPAddress(host) == null) {
setSniHost(socketFactory, sslSocket, host);
}

return trustedSocket;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.os.Build;
import android.text.TextUtils;

import app.k9mail.core.common.net.HostNameUtils;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.ssl.TrustManagerFactory;
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
Expand Down Expand Up @@ -129,7 +130,10 @@ public Socket createSocket(Socket socket, String host, int port, String clientCe

hardenSocket(sslSocket);

setSniHost(socketFactory, sslSocket, host);
// RFC 6066 does not permit the use of literal IPv4 or IPv6 addresses as SNI hostnames.
if (HostNameUtils.INSTANCE.isLegalIPAddress(host) == null) {
setSniHost(socketFactory, sslSocket, host);
}

return trustedSocket;
}
Expand Down