A man-in-the-middle (MitM) attack is a form of cyberattack where important data is intercepted by an attacker using a technique to interject themselves into the communication process. The attacker can be a passive listener in your conversation, silently stealing your secrets, or an active participant, altering the contents of your messages, or impersonating the person/system you think you’re talking to.
Think back to the 20th century, when your younger sibling would pick up the phone when you were talking to your crush. You didn’t know they were listening, and then they went and tattled on you. That’s a basic MitM attack.
- MitM Process
- MitM Techniques
- MitM Detection
- MitM Prevention
How Does A Man-in-the-Middle Attack Work?
Download the full Netcat cheatsheet
Most MitM attacks follow a straightforward order of operations, regardless of the specific techniques used in the attack.
In this example, there are three entities, Alice, Bob, and Chuck (the attacker).
- Chuck covertly listens to a channel where Alice and Bob are communicating
- Alice sends a message to Bob
- Chuck intercepts and reads Alice’s message without Alice or Bob knowing
- Chuck alters messages between Alice and Bob, causing unwanted/damaging responses
MitM techniques are usually employed early in the cyber kill chain – during reconnaissance, intrusion, and exploitation. Attackers often use MitM to harvest credentials and gather intelligence about their targets.
Multi-factor authentication (MFA) can be an effective safeguard against stolen credentials. Even if your username and password are scooped up by a man-in-the-middle, they’d need your second factor to make use of them. Unfortunately, it’s possible to bypass MFA in some cases.
Here is a practical example of a real-world MiTM attack against Microsoft Office 365 where MFA was bypassed by the attacker:
- User clicks a phishing link that takes them to a fake Microsoft login page where they enter their username and password
- The fake webpage forwards the username and password to the attacker’s server
- The attacker forwards the login request to Microsoft, so they don’t raise suspicion
- Microsoft sends the two-factor authentication code to the user via SMS
- User enters the code into the fake webpage
- The fake page forwards 2FA code to the attacker’s server
- The attacker uses Evilginx to steal the session cookie
- The attacker forwards the user’s 2FA code to Microsoft, and now the attacker can log in to Office 365 as the compromised user by using the session cookie, and has access to sensitive data inside the enterprise
You can see this exact attack happen in a live environment during our weekly cyber-attack workshops.
MitM Attack Techniques and Types
Here are a few of the common techniques that attackers use to become a man-in-the-middle.
1. ARP Cache Poisoning
Address Resolution Protocol (ARP) is a low-level process that translates the machine address (MAC) to the IP address on the local network.
Attackers inject false information into this system to trick your computer to think the attacker’s computer is the network gateway. When you connect to the network, the attacker is receiving all of your network traffic (instead of your real network gateway) and passes the traffic along to its real destination. From your perspective, everything is normal. The attacker is able to see all of your packets.
- Chuck (our attacker) joins your network and runs a network sniffer
- Chuck inspects your network packets to attempt to predict the sequence numbers of your packets between you and the gateway
- Chuck sends a packet to your computer with the faked source address of the gateway and the correct ARP sequence to fool your computer into thinking the attacker’s computer is the gateway
- At the same time, Chuck floods the gateway with a Denial of Service (DoS) attack so you receive the fake ARP packet before the gateway is able to respond
- Chuck fooled your computer into thinking the attacker’s laptop is the real gateway, and the MitM attack is successful
2. DNS Cache Poisoning
DNS cache poisoning is when the attacker gives you a fake DNS entry that leads to a different website. It might look like Google, but it’s not Google, and the attacker captures whatever data – username and password, for example – you enter into the faked website.
- Chuck figures out that you use a certain DNS resolver.
- Chuck knows this resolver is vulnerable to exploits, like an older version of BIND.
- Chuck uses this exploit to tell the DNS resolver that www.example.com lives at an IP address that they own.
- You go to www.example.com from your computer, and the DNS resolver tells you that the IP address of that site is the attacker’s machine!
- Chuck completes the connection to the real website so you don’t realize there is anyone listening, but he is able to see all the packets that you (or anyone else that uses this DNS resolver to connect to www.example.com) are sending.
3. HTTPS Spoofing
HTTPS is one of the ways users know that their data is “safe.” The S stands for secure. At least that is what an attacker wants you to think. Attackers set up HTTPS websites that look like legitimate sites with valid authentication certificates, but the URL will be just a bit different. For example, they will register a website with a unicode character that looks like an ‘a’ but isn’t. Continuing with the “example.com” example, the URL might look like https://www.example.com, but the ‘a’ in “example” is a cyrillic “a”, which is a valid unicode character that appears just like an arabic “a” with a different unicode value.
- Chuck gets you to visit his website www.example.com with the Cyrillic “a” using some kind of attack, phishing for example.
- You download the CA certificate for the fake website.
- Chuck signs the certificate with his CA private key and sends it to you.
- You store the certificate in your trusted key store.
- Chuck relays the traffic to the real www.example.com, and he is now a real MitM listening to your traffic
4. Wi-Fi Eavesdropping
Attackers listen to traffic on public or unsecured Wi-Fi networks, or they create Wi-Fi networks with common names to trick people into connecting so they can steal credentials or credit card numbers or whatever other information users send on that network. Kody from SecurityFWD has several different videos that show how easy this is.
5. Session Hijacking
Session hijacking is a MitM attack where the attacker watches for you to log into a web page (banking account, email account, for example) and then steals your session cookie to log into that same account from their browser. This is the attack we demonstrate in our Live Cyber Attack workshop we mentioned previously.
Once the attacker has your active session cookie on their computer, they can do whatever you could do on that website. Our guy Chuck could transfer all of your savings to an offshore account, buy a bunch of goods with your saved credit card, or use the stolen session to infiltrate your company network and establish a stronger foothold on the corporate network.
Are MitM Attacks Common?
MitM attacks have been around for a long time, and while they’re not as common as phishing and malware or even ransomware, they are usually part of targeted attacks with specific intent. For example, an attacker who wants to steal a credit card number might snoop on a coffee shop Wi-Fi for that data. Another attacker might use MitM techniques as part of a larger plan to break into a large enterprise. Our MitM Cyber Attack Lab demonstrates how an attacker can use malware to intercept network traffic and gain entry into the enterprise email system.
How to Detect a Man-in-the-Middle Attack
MitM attacks can be difficult to catch, but their presence does create ripples in the otherwise regular network activity that cybersecurity professionals and end-users can notice. The conventional wisdom is more prevention than detection.
Signs to Look For
Here are some signs there may be extra listeners on your networks.
- Unexpected and/or repeated disconnections: Attackers forcefully disconnect users so they can intercept the username and password when the user tries to reconnect. By monitoring for unexpected or repeated disconnections, you can pinpoint this potentially risky behavior proactively.
- Strange addresses in your browser address bar: If anything in the address looks odd, even by a little, double-check it. It could be a DNS hijack. For example, you see https:\\www.go0gle.com instead of https:\\www.google.com
- You log into a public and/or unsecured Wi-Fi: Be very careful of what networks you connect to, and avoid public Wi-Fi if possible. Attackers create fake networks with known IDs like “local free wireless” or some other common name to trick people into connecting. If you connect to the attacker’s Wi-Fi, they can easily see everything you send on the network.
How to Prevent a Man-in-the-Middle Attack
Here are several best practices to protect you and your networks from MitM attacks. None of them are 100% fool-proof.
General Best Practices
Overall, good cybersecurity hygiene will help protect you from MitM attacks.
- Only connect to secured Wi-Fi routers or use your wireless carrier’s encrypted connection. Connect to routers that use WPA2 security. It’s not totally foolproof, but it’s much better than nothing.
- Add a VPN to encrypt traffic between end-points and the VPN server (either on the enterprise network or on the internet). If traffic is encrypted, it’s harder for a MiTM to steal or modify it.
- Use end-to-end encryption for your emails, chat, and video communication (Zoom, Teams, etc.)
- Keep the system patched and malware updated
- Use a password manager to protect your passwords and prevent reuse of passwords
- Only connect to HTTPS connections, use a browser plugin to enforce this rule
- Use multi-factor authentication wherever available
- Employ DNS over HTTPS, which is a new technology that protects you from DNS hijacking by encrypting your DNS requests
- Follow the zero-trust principles to build internal barriers around access to data, which prevent infiltrators from moving freely throughout the network if they were to get inside
- Monitor activity on the network to detect evidence (malicious network connections or abnormal user behavior, for example) of a compromise or MitM techniques in use
Why Encryption Can Protect You From MitM Attacks
End-to-end encryption can help prevent a MitM from reading your network messages. Encryption involves both the sender and the receiver using a shared key to encrypt and decrypt messages that they send and receive. Without that shared key, the messages are gobbledygook, so the MitM can’t read them.
Encryption makes it harder for an attacker to intercept and read the network data, but it isn’t impossible, and it’s not a guarantee against compromise, because attackers have developed techniques to work around encryption.
For example, in the MitM Cyber Attack Lab, we demonstrate how an attacker can steal the authentication token that contains the username, password, and MFA authentication data to log in to an email account. Once they hijack the session cookie, it doesn’t matter that the communication between the client and server is encrypted — the hacker simply logins as the end-user and can access everything the user can access.
Future of MitM Attacks
MitM attacks will continue to be a useful tool in attackers’ arsenals as long as they can continue to intercept important data like passwords and credit card numbers. It’s a perpetual arms race between software developers and network providers to close the vulnerabilities attackers exploit to execute MitM.
Take the massive proliferation of the Internet of Things (IoT) over the past few years. IoT devices don’t yet adhere to the same security standards or have the same capabilities as other devices, which makes them more vulnerable to MitM attacks. Attackers use them as a way into an organization’s network so they can move to other techniques. Who knew that a new fancy internet-capable thermostat was a security hole? Attackers do!
Wider adoption of wireless networking, 5G networks, for example, is another opportunity for attackers to use MitM to steal data and infiltrate organizations, as demonstrated at BlackHat 2019. It is incumbent on the wireless companies to fix vulnerabilities like the ones shown at BlackHat and provide a secure backbone for users and devices.
Overall, there are more devices connected to more networks, which means more opportunities for attackers to use MitM techniques. Knowing the telltale signs of a MitM attack and putting in place detection methods can help you spot attacks before they do damage.
Check out our Live Cyber Attack Workshop, where we demonstrate how an attacker can intercept a user’s authentication token using MitM to infiltrate and steal important data and show how Varonis can detect this attack.
FAQs
What is a Man-in-the-Middle Attack: Detection and Prevention Tips? ›
Having a strong encryption mechanism on wireless access points prevents unwanted users from joining your network just by being nearby. A weak encryption mechanism can allow an attacker to brute-force his way into a network and begin man-in-the-middle attacking. The stronger the encryption implementation, the safer.
What is man-in-the-middle attack and how to prevent it? ›Having a strong encryption mechanism on wireless access points prevents unwanted users from joining your network just by being nearby. A weak encryption mechanism can allow an attacker to brute-force his way into a network and begin man-in-the-middle attacking. The stronger the encryption implementation, the safer.
What is the man-in-the-middle attack? ›A man in the middle (MITM) attack is a general term for when a perpetrator positions himself in a conversation between a user and an application—either to eavesdrop or to impersonate one of the parties, making it appear as if a normal exchange of information is underway.
What are the three ways to prevent man-in-the-middle attacks? ›- Secure connections. A secure internet connection is your first line of defense. ...
- VPN. One of the best practices for network security is to use a VPN (virtual private network) when connecting online. ...
- Endpoint security. ...
- Multi-factor authentication. ...
- Education.
An easy way to prevent IP spoofing-based MiTM attacks is to use a VPN. Get CyberGhost VPN to hide your IP address and encrypt your traffic. Even if an attacker manages to intercept your data packets he won't be able to alter them or make sense of them in any way.
What are the best defenses to a MITM attack? ›Knowledge and Information. Knowledge on cyber-attacks and data leaks in general is your best defense against MITM attacks.
What is an example of men in the middle attack? ›For example, the cybercriminal will take login credentials captured from the fake website and use them on the actual one. From there, they could change the user's password, steal vital financial information, or use the credentials for longer-term initiatives such as a company network or a more severe attack.
What is the most common man-in-the-middle attack? ›Man-in-the-browser is the most common type of MiTM attack in which the attackers focus on browser infection and inject malicious proxy malware into the victim's device.
What are the consequences of man-in-the-middle attacks? ›Using the MITM attack, criminals can access login credentials, payment information, and other sensitive data. It's a common entry point for many costly cyberattacks. These attacks are especially effective in environments where security standards like encryption and authentication aren't present.
What are the objectives of man-in-the-middle attack? ›The goal of a MITM attack is to collect personal data, passwords or banking details, and/or to convince the victim to take an action such as changing login credentials, completing a transaction or initiating a transfer of funds.
What is the primary defense of a man-in-the-middle? ›
Defense and detection. MITM attacks can be prevented or detected by two means: authentication and tamper detection. Authentication provides some degree of certainty that a given message has come from a legitimate source. Tamper detection merely shows evidence that a message may have been altered.
How do man-in-the-middle attacks work? ›A man-in-the-middle attack is a type of eavesdropping attack, where attackers interrupt an existing conversation or data transfer. After inserting themselves in the "middle" of the transfer, the attackers pretend to be both legitimate participants.
Which of the following techniques is effective against man-in-the-middle attacks? ›Use a Firewall. A firewall can be used to block unauthorised access and malicious traffic. This can help protect against man-in-the-middle attacks.
What are the 3 common methods of defend strategy? ›the means used by companies in market leadership positions to defend their market share from attacks by challengers; six common defence strategies are position defence, flanking defence, pre-emptive defence, counter-offensive defence, mobile defence and contraction defence.
What is the most effective way of preventing targeted attacks? ›Timely detection and response, training of personnel, and advanced training of information security department employees help reduce the risks associated with targeted attacks.
What are the tools used in man in the middle attack? ›Following are the common tools that are used in Man in the Middle attacks. PacketCreator, Ettercap, dSniff, and Cain and Abel are usually used to intercept communication between hosts. The mentioned tools are more effective and efficient when used in LAN network environments.
Can you detect a man-in-the-middle attack? ›Man-in-the-middle attacks can also be detected using deep packet inspection (DPI) and deep flow inspection (DFI) during network monitoring. DPI and DFI provide network monitors with information such as packet length and size. They can be used to identify anomalous network traffic.
What type of prevention can be implemented to reduce or stop security threats? ›Use firewalls.
Firewalls are another essential tool in defending networks against security threats. A firewall can help prevent unauthorized access to a network by blocking incoming traffic from untrusted sources.
Man-in-the-middle attacks are caused by the compromisation of a Wi-Fi network. This could be the hacking of a public or private network, or a hacker creating their own malicious Wi-Fi network for unsuspecting victims to connect to.
Who are the prime targets of MitM attacks? ›This attack aims to get access to personal information such as credit card details, account numbers, and login credentials. The man-in-the-middle attack's prime targets are the users of eCommerce websites, SaaS businesses, and financial applications.
What must be protected to prevent attackers from intercepting secure communications? ›
Encryption. First and foremost, encrypt email, networks and communications, as well as data at rest, in use and in motion. That way, even if data is intercepted, the hacker will not be able to decrypt it without the encryption key. For wireless encryption, Wi-Fi Protected Access 2 or WPA3 is recommended.
What is man-in-the-middle in information security? ›NIST SP 800-63-3 under Man-in-the-Middle Attack (MitM) An attack where the adversary positions himself in between the user and the system so that he can intercept and alter data traveling between them.
What is man-in-the-middle attack and how it can attack your network system? ›A man-in-the-middle attack is a type of eavesdropping attack, where attackers interrupt an existing conversation or data transfer. After inserting themselves in the "middle" of the transfer, the attackers pretend to be both legitimate participants.
What is the symptoms of man-in-the-middle attack? ›- Pop-ups or captive portal pages asking for credentials.
- Login pages appear that don't look legitimate.
- Fake software update pop-ups.
- Certificate error messages.
Man-in-the-middle attacks require three players. There's the victim, the entity with whom the victim is trying to communicate, and the “man in the middle,” who intercepts the victim's communications.
Who uses a man-in-the-middle attack? ›Threat actors could use man-in-the-middle attacks to harvest personal information or login credentials. If attackers detect that applications are being downloaded or updated, compromised updates that install malware can be sent instead of legitimate ones.
Who are the prime targets of MITM attacks? ›This attack aims to get access to personal information such as credit card details, account numbers, and login credentials. The man-in-the-middle attack's prime targets are the users of eCommerce websites, SaaS businesses, and financial applications.