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

Certificate check leaks HTTP headers #44

Closed
sebkoller opened this issue May 5, 2023 · 0 comments
Closed

Certificate check leaks HTTP headers #44

sebkoller opened this issue May 5, 2023 · 0 comments

Comments

@sebkoller
Copy link

When the certificates are fetched and verified on Android and iOS, the headers of the actual request are sent.
In case of a MITM attack, HTTP headers, which often contain authorization headers, are leaked to the attacker.

My suggestion:

  1. Headers are not needed to download the certificates
  2. There is no need to do a full HTTP request to get the certificates. Opening a SSL/TLS connection is sufficient.

Here is an example to fetch the certificates with an SSLSocket in Kotlin:

fun main() {
    val hostname = "example.com"
    val port = 443 // Default HTTPS port
    val timeout = 5000

    try {
        val factory = SSLSocketFactory.getDefault() as SSLSocketFactory
        val socket = factory.createSocket(hostname, port) as SSLSocket
        socket.soTimeout = timeout;
        socket.startHandshake()

        val session = socket.session
        val serverCertificate = session.peerCertificates[0]

        // verify certificate

        socket.close()
    } catch (ex: SSLPeerUnverifiedException) {
        // handle ssl exception
    } catch (ex: IOException) {
        // handle io excepition
    }
}
@sebkoller sebkoller changed the title The certificate check leaks HTTP headers Certificate check leaks HTTP headers May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants