Skip to content

[Java] CWE-295 - Incorrect Hostname Verification - MitM #109

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

Closed
1 task done
intrigus-lgtm opened this issue May 27, 2020 · 4 comments
Closed
1 task done

[Java] CWE-295 - Incorrect Hostname Verification - MitM #109

intrigus-lgtm opened this issue May 27, 2020 · 4 comments
Labels
All For One Submissions to the All for One, One for All bounty

Comments

@intrigus-lgtm
Copy link
Contributor

CVE ID(s)

List the CVE ID(s) associated with this vulnerability. GitHub will automatically link CVE IDs to the GitHub Advisory Database.

  • CVEs pending

Report

Hostname verification is an essential part of Transport Layer Security (TLS) and HTTPS.

When a TLS connection is established there are two important steps:
First, the chain of trust is verified that means it is checked whether the certificate has been issued by a trusted certificate authority.
Second, the hostname (that is being connected to) needs to be verified against the certificate.
That means it is checked whether the certificate is actually for the hostname.

If the hostname is not verified an attacker could present any certificate with a valid chain of trust, but that is not issued for the hostname at all.
This allows a man-in-the-middle attack!

Many posts tell developers that have problems with hostname verification to accept any certificate as valid in the case of a mismatch.
These problems usually are configuration problems that should be fixed instead.

Java verifies HTTPS hostnames by default.
But when a protocol uses TLS (SSLEngine) the hostname is not verified by default.
That's where the second part of my query (IncorrectHostnameVerifier.ql) comes into play.

[This PR and PR description is WIP]

87 of 642 projects tested have overridden the Hostname.verify method.
Query: github/codeql#3581
27 of 642 projects are detected by my currently running query.

  • Are you planning to discuss this vulnerability submission publicly? (Blog Post, social networks, etc). We would love to have you spread the word about the good work you are doing
@intrigus-lgtm intrigus-lgtm added the All For One Submissions to the All for One, One for All bounty label May 27, 2020
@xcorail
Copy link
Contributor

xcorail commented Jun 25, 2020

Hey @intrigus-lgtm can you please send me privately the email address that you would like to use for the bounty payment? Thanks

@intrigus-lgtm
Copy link
Contributor Author

Done.

@xcorail
Copy link
Contributor

xcorail commented Jul 6, 2020

Created Hackerone report 917456 for bounty 227493 : [109] [Java] CWE-295 - Incorrect Hostname Verification - MitM 🎉

@xcorail xcorail closed this as completed Jul 6, 2020
@intrigus-lgtm
Copy link
Contributor Author

Thank you @xcorail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
All For One Submissions to the All for One, One for All bounty
Projects
None yet
Development

No branches or pull requests

2 participants