TExcelTAD
Home › Wireless, IoT & Mobile Security › Evil Twins and Certificate Validation in Enterprise Wi-Fi

Evil Twins and Certificate Validation in Enterprise Wi-Fi

An evil twin is an access point that copies a real network's SSID so that clients connect to it instead. Against WPA2-Personal it needs the passphrase to complete the handshake. Against Enterprise networks it can do something worse: run its own authentication server, and if the client doesn't check who it is talking to, collect each user's login exchange. With PEAP-MSCHAPv2, the most common configuration in Windows networks, that exchange can be turned into the user's password hash offline. The attack has been understood for well over a decade, and the fix is entirely on the client side: validate the server certificate. This lesson shows why, how to check a client configuration, and what to log.

The mechanism

  1. The twin advertises LabCorp with WPA2-Enterprise, often with a stronger signal than the real AP, or near a place the real network doesn't reach (a car park, a café across the street).
  2. A client with a saved LabCorp profile associates and starts EAP. The twin's own RADIUS server presents some certificate for the TLS tunnel of PEAP.
  3. If the client accepts that certificate, it runs MSCHAPv2 inside the tunnel. MSCHAPv2 is a challenge–response over the user's NT hash; the twin records the challenge and response.
  4. MSCHAPv2's design reduces breaking a response to recovering a single DES key (published by Marlinspike and Hulton in 2012), so the response leads to the NT hash, which is a password equivalent in Windows networks, and weak passwords fall faster still.

The client couldn't complete the connection (the twin can't derive the right keys without the real server), so the user may see only a failed connection, or not even that. Nothing reaches the real RADIUS server, which logs nothing.

Where the client goes wrong is step 3, and there are several ways:

Client configuration What it accepts
"Do not validate server certificate" any certificate: the twin wins
validates against the system's public CA store, no server name any certificate from any public CA for any domain, which anyone can buy for their own domain
prompts the user "Trust this certificate?" on first use whatever the user clicks; most click "Connect"
trusts only the organisation's RADIUS CA and checks the server name only the real server

A supplicant's decision, modelled

The program creates certificates the way the lab would (Ed25519 keys from fixed labels so the output is stable): the organisation's private Wi-Fi CA and the real radius.lab.test certificate, a twin with a self-signed certificate claiming the same name, and a twin with a certificate from a public CA for a domain the attacker owns. Three client profiles then decide.

python · try it yourself
import datetime, hashlib
from cryptography import x509
from cryptography.x509.oid import NameOID
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey

def key(label):    # deterministic lab keys so the output is stable; real keys come from a secure generator
    return Ed25519PrivateKey.from_private_bytes(hashlib.sha256(label.encode()).digest())

def cert(subject, subject_key, issuer, issuer_key, dns=None, ca=False):
    b = (x509.CertificateBuilder()
         .subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, subject)]))
         .issuer_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, issuer)]))
         .public_key(subject_key.public_key()).serial_number(0x3001)
         .not_valid_before(datetime.datetime(2026, 1, 1)).not_valid_after(datetime.datetime(2028, 1, 1))
         .add_extension(x509.BasicConstraints(ca=ca, path_length=None), critical=True))
    if dns:
        b = b.add_extension(x509.SubjectAlternativeName([x509.DNSName(dns)]), critical=False)
    return b.sign(issuer_key, None)

lab_ca_key, public_ca_key = key("lab-ca"), key("public-ca")
LAB_CA = cert("LabCorp Wi-Fi CA", lab_ca_key, "LabCorp Wi-Fi CA", lab_ca_key, ca=True)
PUBLIC_CA = cert("Some Public Web CA", public_ca_key, "Some Public Web CA", public_ca_key, ca=True)
presented = {
    "real radius.lab.test":           cert("radius.lab.test", key("radius"), "LabCorp Wi-Fi CA", lab_ca_key, "radius.lab.test"),
    "twin: self-signed, same name":    cert("radius.lab.test", key("twin1"), "radius.lab.test", key("twin1"), "radius.lab.test"),
    "twin: public CA, own domain":     cert("wifi-login.example.net", key("twin2"), "Some Public Web CA", public_ca_key, "wifi-login.example.net"),
}

def signed_by(c, ca):
    try:
        ca.public_key().verify(c.signature, c.tbs_certificate_bytes)
        return c.issuer == ca.subject
    except Exception:
        return False

def supplicant_accepts(c, profile):
    if profile["validate"] == "none":
        return "accept (no validation)"
    trusted = [LAB_CA] if profile["validate"] == "lab-ca" else [LAB_CA, PUBLIC_CA]   # "system" = every CA in the OS
    if not any(signed_by(c, ca) for ca in trusted):
        return "REJECT: not issued by a trusted CA"
    if profile.get("server_name"):
        names = c.extensions.get_extension_for_class(x509.SubjectAlternativeName).value.get_values_for_type(x509.DNSName)
        if not any(n == profile["server_name"] or n.endswith("." + profile["server_name"]) for n in names):
            return f"REJECT: name {names} doesn't match {profile['server_name']}"
    return "accept"

profiles = {
    "no validation":                {"validate": "none"},
    "system CAs, no name":          {"validate": "system"},
    "lab CA + server name":         {"validate": "lab-ca", "server_name": "radius.lab.test"},
}
for pname, prof in profiles.items():
    print(f"profile: {pname}")
    for cname, c in presented.items():
        print(f"   {cname:30} -> {supplicant_accepts(c, prof)}")
profile: no validation
   real radius.lab.test           -> accept (no validation)
   twin: self-signed, same name   -> accept (no validation)
   twin: public CA, own domain    -> accept (no validation)
profile: system CAs, no name
   real radius.lab.test           -> accept
   twin: self-signed, same name   -> REJECT: not issued by a trusted CA
   twin: public CA, own domain    -> accept
profile: lab CA + server name
   real radius.lab.test           -> accept
   twin: self-signed, same name   -> REJECT: not issued by a trusted CA
   twin: public CA, own domain    -> REJECT: not issued by a trusted CA

Only the last profile rejects both twins. The middle one is the trap that looks secure: "validates the certificate" with the system's public CAs but no name means any domain-validated certificate passes, and those are free.

The same checks with OpenSSL, in the sandbox, on the lab PKI of the sample files: the real certificate with the right name, the same certificate when the client expects a different name, and a twin certificate made in the session:

bash · try it yourself
S=/opt/sec-samples/pki
openssl req -x509 -newkey ed25519 -keyout twin.key -nodes -subj "/CN=radius.lab.test" -days 30 -out twin.crt 2>/dev/null
echo "== the real server certificate, checked against the lab CA and the expected name"
openssl verify -CAfile $S/ca.crt -verify_hostname www.lab.test $S/lab.test.crt 2>&1
echo "== the same certificate, but the client expects radius.lab.test"
openssl verify -CAfile $S/ca.crt -verify_hostname radius.lab.test $S/lab.test.crt 2>&1
echo "== the evil twin's self-made certificate"
openssl verify -CAfile $S/ca.crt -verify_hostname radius.lab.test twin.crt 2>&1
echo "exit code of the last check: $?"
== the real server certificate, checked against the lab CA and the expected name
/opt/sec-samples/pki/lab.test.crt: OK
== the same certificate, but the client expects radius.lab.test
C = XX, O = ExcelTAD Lab, OU = Web, CN = lab.test
error 62 at 0 depth lookup: hostname mismatch
error /opt/sec-samples/pki/lab.test.crt: verification failed
== the evil twin's self-made certificate
CN = radius.lab.test
error 18 at 0 depth lookup: self-signed certificate
error twin.crt: verification failed
exit code of the last check: 2

Error 62 is the name check doing its job, error 18 the CA check. A supplicant needs both, with the CA restricted to the one that issues the RADIUS certificate. (More on chains and name matching in Chains of Trust and X.509.)

Reviewing real client profiles

The settings have different names per platform; the review asks the same questions:

Platform Where to look Secure setting
wpa_supplicant (Linux, many IoT) network block ca_cert set to the RADIUS CA, domain_suffix_match or domain_match set, phase2 not PAP for TTLS
Windows Wi-Fi profile, PEAP properties (or Intune/GPO) "Verify the server's identity", only the RADIUS CA ticked, "Connect to these servers" filled, no user prompt for new servers
Android Wi-Fi network, CA certificate and Domain fields a CA certificate installed and selected and a Domain set; recent Android versions refuse the old "Do not validate" option
Apple platforms configuration profile (MDM) trusted certificates and trusted server names in the EAP payload

Pushing these settings by device management, instead of letting users configure Wi-Fi by hand, is the only way to get them right across a fleet (MDM and Device Policy).

How evil twins are detected

  • WIDS: your SSID on a BSSID not in the inventory, especially with a different security setting or vendor prefix, or on a channel your APs don't use (Rogue APs and WIDS).
  • Client telemetry: managed devices reporting certificate-validation failures for the corporate SSID.
  • User reports of unexpected certificate prompts on Wi-Fi, which should be treated as security events, not helpdesk noise.
  • RADIUS sees nothing of the twin itself, but a wave of password resets or lockouts after an event can be a late sign.

How it is fixed

  1. Enforce server validation on every client: the organisation's RADIUS CA only (preferably a private CA dedicated to it) and the exact server name; no "trust on first use" prompts.
  2. Move to EAP-TLS with device certificates: there is no password exchange to capture, and a twin can't authenticate to the client.
  3. Retire MSCHAPv2 where possible (Microsoft's Credential Guard blocks MSCHAPv2-based single sign-on to Wi-Fi for that reason); if PEAP stays, validation is non-negotiable.
  4. Use WPA3-Enterprise with PMF required, and keep WIDS watching for your SSIDs.

Pitfalls

  • Using a public CA for the RADIUS certificate "so clients trust it": then any certificate from that CA, for any customer, satisfies clients that don't check the name.
  • Checking the name with a suffix that is too broad (lab.test when the server is radius.lab.test and anyone in the organisation can get certificates under lab.test).
  • Assuming Personal mode is immune: everyone with the passphrase can run a perfect twin of a WPA2-Personal network.

Practice

1. In the program, add a profile {"validate": "lab-ca"} without a server name. Which certificates does it accept, and what risk remains?

It accepts only the real certificate in this set. The remaining risk is any other certificate the lab CA has issued (for another internal server) being presented by a twin; the name check closes that.

2. A user reports "Wi-Fi asked me to trust a new certificate for LabCorp". What do you do?

Treat it as a possible evil twin: record the location and time, check WIDS for unknown BSSIDs with the SSID, ask whether the user accepted, and if so reset the password. Then fix the profile so the prompt can't appear.

3. Why does EAP-TLS remove the password-capture risk entirely?

The client proves itself with a private key that never leaves the device, through a signature the twin can't reuse; there is no password-derived response to record and attack offline.

Test yourself

What does an evil twin gain from a PEAP-MSCHAPv2 client that doesn't validate the server?

  1. Nothing
  2. The MSCHAPv2 challenge and response, which lead to the user's NT hash offline
  3. The PMK of the real network
  4. The RADIUS shared secret

Which client setting rejected both twins in the program?

  1. No validation
  2. System CAs without a name check
  3. Only the organisation's RADIUS CA plus the server name
  4. Trust on first use

What did OpenSSL's error 62 report?

  1. Self-signed certificate
  2. Hostname mismatch
  3. Expired certificate
  4. Unknown CA

Why don't RADIUS logs show the evil-twin attack?

  1. They are encrypted
  2. The client's EAP exchange goes to the twin's own server, not the real one
  3. RADIUS doesn't log
  4. The twin deletes them