I am trying to improve the MITM protection of an iOS app I am responsible for, so I want to understand exactly how it happens. I have set up Charles to act as a proxy which required setting the proxy on the phone and installing the Charles certificate. I am now able to read the TLS data sent back and fourth.

In reality most people don't install certificates (at least not the way the Charles certificate is installed) and don't set proxy servers in their network settings.

Presuming I am staying in a hotel and using their WIFI to access my server, how would they go about performing a MITM attack on me?

  • 1
    People DO configure proxy servers on their phones. Any medium-to-large company will have a proxy on their network.
    – ThoriumBR
    Jan 26, 2016 at 22:12

3 Answers 3


One way that an attacker can pull-off a MITM attack in a place where public wifi is available (like a hotel) it to create a fake wifi hotspot, which uplinks to the hotel's wifi. Then, the attacker can use a tool like sslsniff to intercept SSL connections.

Edit: To protect against a MITM attack, the client should check that the server's certificate (or the CA that signed the certificate) is one that is trusted. This can be done by way of certificate pinning.

  • That explains how my traffic would end up going through a proxy. They would have to sign with a certificate for my domain thought right? If this was not from a trusted CA then my browser, for example, would warn me.
    – Onato
    Jan 26, 2016 at 22:44
  • Correct. Certificates are the defense against MITM attacks. To pull-off an MITM attack, the attacker would either have to create a certificate signed by a CA that your browser trusts (a la the infamous Diginotar incident in 2011, see en.wikipedia.org/wiki/DigiNotar), or the attacker would have to dupe you into ignoring your browser's certificate warnings.
    – mti2935
    Jan 26, 2016 at 23:00
  • So in order to protect my iOS app I would have to check that the CA is one that I can trust or the one that I know my server is using? Could you update your answer with this info?
    – Onato
    Jan 26, 2016 at 23:18
  • Sure thing. Done.
    – mti2935
    Jan 26, 2016 at 23:26
  • See my answer @Onato. There are standards and libraries for doing this. Jan 26, 2016 at 23:26

I think you got something fundamelntally wrong. A MitM attack is an attack whichs goal it is to redirect traffic over the attackers host. The attacker then acts as a proxy but he will not be able to install an additional certificate on your host without having root/administrative access to that host.

How to perform a MitM attack

MitM Attacks are mostly performed by abusing protocol weaknesses but its sometimes also possible due to logic fails "comitted" by the developer. There are several ways to carry out these attacks. I will only list the common ones on the LAN:

  • Port-Stealing (Layer 2)
  • MAC-Floogin (Layer 2)
  • ARP-Spoofing (Layer 3)
  • Rouge-DHCP-Server (Layer 7)
  • WPAD-Redirection (Layer 7 - Based on nbns, LLMNR or mDNS spoofing)

WLAN-Specific opportunities

When you are in posession of the PSK you can also passivly capture all the traffic an then decrypt all the traffic using airdecap-ng which will be sucessful when you fit the folliwing requirements:

  • WEP = Know the PSK it will use the PSk to encrypt the traffic
  • WPA2 = Know the PSK and capture the 4-Way-Handshake. There will be a session specific key which can be obtained when you fit both requirements

This will only work on non enterprise networks that use a user unspecific PSK.

Defeating SSL

An attacker won't be able to get around SSL without access to the victims host. But there are ways to prevent the useage of SSL:

  • SSLStrip - Will remove all https links from unencrypted webpages passed trough the MitM Host. The basic idea is that users use https only because they are redirected to https not because they type it in their browesers
  • Deloreon - Will get you around HSTS by manipulating the system time using fake NTP responses.
  • DNS-Spoofing and Application Proxy - Will like SSLStrip only work on connections that aren't already encrypted
  • Your post is correct, but the question seems to be asking about HTTPS MITM attacks rather than other types of MITM attacks. Feb 22, 2016 at 20:49

Assuming that you control both the app and the server, the best strategy for preventing MiTM in mobile apps is to always require SSL and use certificate pinning. Certificate pinning forces your application to only accept a specific cert. This will prevent an MiTM even against an attacker who has obtained an illicit but valid cert for your site.

  • 2
    As in the link you provided, most of the iOS certificate pinning examples I found compare the remote certificate to one that is bundled with the app. This means that my app breaks as soon as I update the certificate on the server. Am I right in assuming that if I verify the issuer details then I would also secure the app and be able to update the certificate on the server, provided I stick with the same CA?
    – Onato
    Jan 26, 2016 at 23:55
  • Yes. But you can also be victim to an errant cert issued by the same CA. I'm not saying that is likely, just an additional risk. Jan 26, 2016 at 23:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .