Security Explained8 min read1 October 2026

What Is a Man-in-the-Middle Attack? How Hackers Intercept Your Data

A man-in-the-middle attack is when a hacker secretly intercepts communications between two parties. Learn how MITM attacks work, what they target, and how to defend against them.

By Yrzo AI — UK cybersecurity specialists

The Attack You Cannot See

You are browsing a familiar website. You log in normally. Nothing looks wrong. What you do not know is that someone is sitting between your device and the server, reading everything you send and receive — including the credentials you just typed.

That is a man-in-the-middle attack. The technical challenge is not the interception itself; once an attacker is positioned correctly, reading the traffic is trivial. The challenge is getting into position. This article covers how they do it, what they do once they are there, and how the defences on a properly configured website prevent it.

Getting Into Position: The Interception Methods

**Rogue Wi-Fi hotspots** are the most common real-world vector. An attacker sets up a Wi-Fi access point with a plausible name — "Airport_Free_WiFi", "Pret_Guest", "Hotel_Lobby". Devices connect automatically, or users connect willingly. All traffic now routes through the attacker's hardware. They see everything — every page visited, every form submitted, every credential typed.

**ARP spoofing** works on local networks you are already connected to. The Address Resolution Protocol maps IP addresses to MAC addresses on a local network. An attacker sends forged ARP messages claiming that their MAC address corresponds to the IP of the default gateway. Nearby devices update their ARP tables and start sending their outbound traffic to the attacker instead of the real router. The attacker forwards it along to the real destination — the network keeps working, nobody notices, but all traffic passes through an extra hop in the middle.

**DNS spoofing** corrupts the DNS cache of a victim's device. DNS is the system that translates "mybank.com" into an IP address. When the victim's device looks up a domain, the attacker's poisoned cache returns the IP of a server the attacker controls rather than the real one. The victim connects to what looks like the right site, but is not.

**SSL stripping** is the technique that makes HTTPS protection exploitable when it is not fully enforced. When a user navigates to http://mybank.com, the real site responds with a redirect to https://mybank.com. An attacker in the middle can intercept that initial HTTP request before the redirect, serve the victim an HTTP version of the site themselves, and relay requests to the real HTTPS site on the victim's behalf. The victim's browser shows HTTP, not HTTPS — but many users do not notice, and many older browsers do not warn loudly enough. The attacker reads everything in plaintext.

What Happens After Interception

Once positioned, an attacker has options depending on their objective.

**Credential harvesting** — username and password submissions are captured as they pass through. The attacker can replay these to authenticate as the victim.

**Session hijacking** — authentication cookies contain session tokens that prove a user is already logged in. Captured cookies can be injected into the attacker's own browser to impersonate the victim without needing their password at all.

**Data injection** — the attacker can modify pages in transit. They can inject malicious JavaScript into every page a victim loads, insert fake form fields to collect additional data, or alter API responses to change displayed information (changing a displayed bank account number in a payment confirmation, for instance).

**Eavesdropping** — passively reading confidential communications, internal documents, or API responses without modifying anything. Often the goal when targeting corporate intelligence.

The Defences That Matter for a UK Website

**HTTPS everywhere** — not just on login pages. An attacker can hijack a session from an HTTP page even if the login itself was over HTTPS, by intercepting session cookies sent in subsequent HTTP requests. Every resource on every page must be served over HTTPS.

**HSTS (HTTP Strict Transport Security)** — this response header tells browsers never to connect to the site over HTTP under any circumstances. A browser that has seen a valid HSTS header for your domain will refuse an HTTP connection even if an attacker tries to serve them one. This is the direct defence against SSL stripping. The header looks like this:

`Strict-Transport-Security: max-age=31536000; includeSubDomains; preload`

Set max-age to at least one year. The `preload` flag submits your domain to browser preload lists, ensuring HSTS protection even on a user's first ever visit.

**Secure and HttpOnly cookie flags** — `Secure` prevents a cookie from being transmitted over HTTP, so even if a victim visits an HTTP version of your page, session cookies stay behind. `HttpOnly` prevents JavaScript from reading the cookie, defeating some XSS-based session theft.

**Valid SSL certificate from a trusted CA** — an attacker using a self-signed certificate or a certificate from an untrusted authority triggers browser warnings. Users clicking past certificate warnings is the one scenario where MITM attacks can succeed even against a nominally HTTPS site.

**Mixed content** — if an HTTPS page loads resources (images, scripts, stylesheets) over HTTP, cookies for those resources are not protected by the Secure flag. Browsers block mixed active content (scripts and iframes) but not always passive content (images). Check your site has no mixed content.

**Certificate Transparency monitoring** — CT logs record every TLS certificate issued for any domain. If an attacker somehow obtains a fraudulent certificate for your domain from a rogue certificate authority, CT monitoring will catch it. Google's Certificate Transparency project makes this auditable.

What Yrzo AI Checks for MITM Protection

Yrzo AI's 75-check scan includes the core MITM defences:

HTTPS enforcement — does your site redirect all HTTP traffic to HTTPS, or are there HTTP pages serving content without a redirect?

HSTS header — is Strict-Transport-Security set with an appropriate max-age, and does it include subdomains?

SSL certificate — is the certificate valid, not expired, and issued by a trusted certificate authority?

Secure cookie flags — do session and authentication cookies carry the Secure attribute?

Mixed content — does any page load resources over HTTP that could expose session cookies or allow content injection?

A site missing any of these is a site where MITM interception is technically viable. The fixes are configuration changes — most can be deployed in under an hour once identified.

Scan at yrzoai.dev. Under 20 minutes, from £99.

Find out if your website has these vulnerabilities

Yrzo AI runs 110+ automated security checks and delivers a full report in under 20 minutes. Starting from £149.

Scan your website →