Man-in-the-Middle Attacks: How to Prevent Security Breaches

Written by Sagar Joshi | Jul 7, 2023 6:33:21 AM

Preventing damage gets even tricker when you don’t know the cause.

Man-in-the-middle attacks, also known as machine-in-the-middle, monkey-in-the-middle, or person-in-the-middle attacks, cause disruptions where users are generally unaware of their cause. Attackers intercept networks and decrypt data exchanges in a man-in-the-middle attack to exploit victim’s data and compromise cybersecurity.

You need to set strong preventive measures using tools like encryption software, virtual private network software, and others to protect yourself against man-in-the-middle attacks. It’ll help ensure network security and data protection while complying with various industry standards.

Attackers intercept information and can send malicious links or attachments to the two parties involved without being detected. 

Man-in-the-middle attacks can be a type of session hijacking attack that causes damage to an organization’s cybersecurity. For example, in 2017, Equifax faced a data breach that led to the leakage of the personal data of 147 million people. Later, it was found that the website didn’t consistently use Hypertext Transfer Protocol Secure (HTTPS), enabling attackers to intercept data in a user session.

People involved in a man-in-the-middle attack include:

  • Person A and Person B: Legitimate people who are exchanging information.
  • Attacker: Perpetrators who intercept communication between the two parties without triggering any suspicion.

The primary goal in a man-in-the-middle attack is to steal sensitive information or personally identifiable information (credit card numbers, social security numbers, and so on.) and send malicious links or malware to a victim to further exploit their assets.

Attackers can conduct identity theft or unauthorized fund transfer, and many other malicious activities using the information gained in a man-in-the-middle attack. Sometimes, perpetrators can use the intercepted data to conduct bigger cyber attacks.

Another form of man-in-middle attack is a man-in-the-browser attack. An attacker intercepts a communication channel between two legitimate parties by compromising a web browser used by either of them. They exploit security vulnerabilities or alter browser functionalities to modify the browser’s behavior to insert themselves in the communication channel.

How does a man-in-the-middle attack work?

A man-in-the-middle attack involves two phases: interception and decryption. In the interception phase, an attacker intercepts user traffic before it reaches the destination. Once the traffic is intercepted, it’s decrypted to reveal the information without alerting legitimate parties.

Suppose you receive an email from your bank’s website asking you to carry out an urgent activity. You dive into the link, authenticate into the website that appears to be your bank’s, and perform the task. Here, the email was a social engineering attempt (phishing) carried out by man-in-the-middle, tricking you into making a login attempt into a malicious website and revealing your login credentials. The attacker can then use them to carry out fraudulent activities. 

Interception techniques

The simplest way an attacker can intercept a communication is by creating a free and public Wi-FI hotspot. When victims connect to these hotspots, attackers gain visibility over the ongoing data exchanges.

Spoofing is a cyber attack that happens when an attacker pretends to be a trusted brand or contact in an attempt to trick a target into revealing sensitive information. Perpetrators can intercept information exchanges through multiple active approaches. 

Domain Name System (DNS) spoofing 

DNS spoofing, also referred to as DNS cache poisoning, is a technique that attackers use to direct users to maliciously crafted websites instead of genuine ones. It involves exploiting vulnerabilities in a DNS server to divert traffic away from a legitimate server.

The attacker inserts themselves in the middle of the DNS server and the user’s browser and makes modifications in both to alter the cache. It results in a redirect to a malicious website hosted on the attacker’s local server. 

When a victim is redirected to a malicious website, they’re prompted to enter their login credentials. This reveals their sensitive information to attackers. Moreover, attackers can spoof and trick you into installing malware that might cause more significant disruptions. Organizations can use DNS security software to prevent themselves from DNS spoofing or DNS cache poisoning attacks.

Internet protocol (IP) spoofing

Data is transferred across the internet in the form of broken multiple packets. These packets are reassembled at the end to constitute the original information. They have a source IP address and a destination IP address. Attackers modify these addresses in IP spoofing, tricking the system into believing that they are coming from a trusted source.

Malicious actors use this technique to conduct denial of service (DoS) attacks. It can also be used in a man-in-the-middle attack, where attackers alter packet headers in an IP. When users try to access a URL connected to the maliciously modified web application, they’re directed to the attacker’s website.

Address Resolution Protocol (ARP) Spoofing

Attackers send a falsified ARP message to a local area network in ARP spoofing. It results in linking IP addresses of a legitimate user’s computers or servers to the attackers’ Mac addresses. 

ARP spoofing attacks can only happen in LANs that use ARP. Once the user’s IP address is connected to the attacker’s Mac address, any data transmitted by a user to the host IP address will be accessible to attackers. 

Decryption techniques

When an attacker has intercepted the communication, the next step is to decrypt it without alerting the legitimate parties involved. There are various pathways attackers use to decrypt information.

Browser exploit against SSL/TLS (BEAST)

BEAST enabled man-in-the-middle attackers to reveal information in encrypted SSL/TLS 1.0 sessions. Attackers were able to decrypt unintelligible data by exploiting known theoretical vulnerabilities. The BEAST attack provided an example of how minute theoretical vulnerability, when combined with other security weaknesses, allows attackers to devise a practical cyberattack.

In a BEAST attack, threat actors infect the victim’s computer with malicious Javascripts, intercepting encrypted session cookies. Attackers then compromise cipher block chaining (CBC) to decrypt cookies and authentication tokens.

What is cipher block chaining?

Cipher block chaining is an operational mode of a block cipher where a sequence of bits is encrypted as one block and combined with the previous block of ciphertext. 

 

The cipher key is applicable to the entire block, and each block depends on the previous one for decryption. Sometimes, an initialization vector is used to tie these encrypted data blocks together.

Although, modern browsers aren’t vulnerable to BEAST attacks as many have moved to TLS v1.1 or higher and have implemented additional preventive measures.

Secure sockets layer (SSL) hijacking

SSL hijacking involves an attacker passing forged authentication keys to both the server and client. Although the session appears to be secure, it’s actually controlled by an attacker.

SSL protocol establishes a secure connection between a browser and a server using encryption. Attackers intercept this secure connection and uncover encrypted information by inserting themselves between the server and the client.

HTTPS spoofing

HTTPS spoofing involves an attacker creating a phony website using a domain that appears similar to a legitimate website. For example, the attack (also known as homograph attack) consists of replacing characters in real domain names with non-ASCII characters with similar appearances. 

Attackers also register their SSL certificate to disguise it as a genuine website. Many browsers allow the display of “Punycode hostnames” in their address bar, and victims are unaware that they’re accessing a malicious website.

Also, an attacker can trick a victim into installing a phony certificate in the browser. It contains a digital signature of the compromised application. The victim’s browser then cross-checks the certificate with a list of trusted websites. In this way, attackers can access the victim’s data before it’s transmitted to the application.

SSL stripping

SSL stripping involves attackers downgrading HTTPS to HTTP, enabling them to access communication between the client and the server in an unencrypted format. 

When a client makes a request to the server, an attacker intercepts it and relays it while making an independent legitimate request to the server. As the server responds, the attacker intercepts it and relays it to the client in an unencrypted format. The attacker masquerades as both the server and client and avoids any suspicion in the ongoing communication.

For example, a user sends a request to authenticate their bank account. An attacker intercepts this request and creates a separate legitimate request to the bank’s server. After receiving a response from the server, the attacker returns an unencrypted response to the user with the login page. The attacker steals the information when the user enters their login credentials.

Does VPN protect against MITM attacks?

A virtual private network (VPN) extends a private network across a public network that enables users to browse the internet safely and securely. Organizations generally use VPN software to provide fast, encrypted, and remote access to a company’s private network.

Using a VPN would surely help protect the traffic between your device and the VPN gateway. But once the traffic passes through the VPN gateway, it can be intercepted. Attackers won’t be able to target MITM attacks on individual users, but they can still conduct an indiscriminate attack against all website users.

Cybercriminals have many techniques to penetrate an organization’s cyber defenses. Although VPN offers substantial protection against MITM attacks, it should be accompanied by a comprehensive approach to cybersecurity with relevant security software.

How to detect a MITM attack

Cybersecurity concepts are aligned with more prevention than detection. You have to set robust preventive measures to prevent MITM attacks.

Even though man-in-the-middle attacks are trickier to detect, there are many signs you can look for to limit damage in MITM attacks, including:

  • Odd website address: If you find any suspicious address, you should be careful as it can be an MITM attack. For example, you see https://faceb00k.com instead of https://facebook.com; it’s a possible sign of a MITM attack.
  • Repeated disconnections: Attackers sometimes forcefully disconnect users in the network. When a victim re-enters their login ID and passwords, an attacker can intercept them. Whenever you observe unexpected behavior like these, it can possibly suggest an MITM attack.
  • Using unsecured Wi-Fi connection: Attackers create fake networks with IDs similar to those you know and trick you into using them. They can intercept all traffic flowing across these networks, putting your sensitive data at risk. You should refrain from using an unsecured Wi-Fi network and be careful while using a public one.   

Ensure that you have some sort of tamper detection and page authentication mechanism set, and with the help of digital forensics, you can possibly detect an MITM attack.

How to protect against MITM attacks

Setting preventive measures is more important than detecting MITM while it’s occurring. You need to follow best practices and be careful. 

The best practices to protect against MITM attacks are:

  • Always connect to a secure router that offers a strong encryption mechanism.
  • Change the router’s default password to prevent attackers from compromising your DNS server.
  • Use VPN software to extend a private network over a public network and prevent malicious hackers from deciphering your data.
  • Install browser plugin to enforce HTTPS connection on every request.
  • Use public key encryption to verify the identity of other entities with whom you’re communicating.
  • Use end-to-end encryption for video conferencing and email accounts, and implement multi-factor authentication.
  • Set up malware detection and removal tools and keep them updated.
  • Use password managers to save, prevent, and protect password reuse.
  • Monitor logs to detect anomalies in the network traffic.
  • Use DNS over HTTPS to protect yourself against DNS hijacking attacks.

Prevent or repent – it’s your call! 

Man-in-the-middle attacks can cause significant damage to data security and can lead to legal repercussions. You need to put up a robust defense against such attacks and stay well-informed and aware of the present threat landscape.

Even after setting a strong defense, if you become a victim of a man-in-the-middle attack, you need to maintain an incident response plan to combat such situations.

Learn more about how to manage security incidents and deal with them with a clear action plan.