anaisbetts / ModernHttpClient

HttpClient implementations that use platform-native HTTP clients for :rocket:
MIT License
659 stars 261 forks source link

MITM attack possible because of 'AllowUnknownCertificateAuthority' flag #267

Open mkcn opened 4 years ago

mkcn commented 4 years ago

Hello,

I would like to report a security issue found during an investigation for an iOS application which uses this library. Using the Burp tool I was able to conduct a MITM attack and intercept all traffic of the iOS application.

We found out this library allows any root CA (in this case, the root CA of Burp, which was NOT trusted on the iOS device) if the DidReceiveChallenge method is used, because of the following flag:

X509VerificationFlags.AllowUnknownCertificateAuthority;

iOS vulnerable line:

https://github.com/anaisbetts/ModernHttpClient/blob/1f462b76656d77030b712601c23284b4430547cb/src/ModernHttpClient/iOS/NSUrlSessionHandler.cs#L324

Android vulnerable line (this has not been tested):

https://github.com/anaisbetts/ModernHttpClient/blob/1f462b76656d77030b712601c23284b4430547cb/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs#L245

Important note: as far as I am aware, the library has been modified in the tested iOS app, therefore there is a chance the vulnerability is not exploitable in the repo version. But i would like to have your option about it and understand why this flag was enabled in the first place.

PS: I am well aware this project is not currently active but, if this issue is confirmed, a lot of projects may be affected and therefore vulnerable to MITM attacks.

Let me know if you need any further information.

Best, Mirko