Sub topic 13
VLAN Hopping: Switch Spoofing and Double Tagging
This chapter assumes you know how access and trunk ports work, what the native VLAN is, and how the 802.1Q tag is laid out. VLAN hopping is an attack in which a host sends traffic into a VLAN it was never assigned to. There are two classic techniques. Both abuse default or sloppy trunk configuration, and both are fixed by configuration, not by new hardware.
Attack 1: Switch spoofing
Some switch ports negotiate their mode with the Dynamic Trunking Protocol (DTP). A port left in dynamic desirable or dynamic auto will form a trunk if the other side asks for one.
An attacker's host sends DTP frames that make it look like a switch. The port becomes a trunk. The attacker can now send and receive tagged frames for every VLAN the trunk allows, which by default is all of them.
This is why the trunk negotiation chapter recommends turning DTP off. The fix has two parts:
- Force every user-facing port to
switchport mode access. This stops the port from ever becoming a trunk. - Use
switchport nonegotiateon real trunks, and set them toswitchport mode trunkstatically.
Attack 2: Double tagging
Double tagging works even when the attacker's port is a correct access port. It needs two conditions:
- The attacker's access port is in the same VLAN as the trunk's native VLAN.
- The switches are connected by an 802.1Q trunk that sends native VLAN frames untagged.
The attacker builds a frame with two 802.1Q tags. The outer tag carries the native VLAN. The inner tag carries the victim VLAN.
Step by step:
- Switch 1 receives the frame on an access port in VLAN 1. It treats the frame as belonging to the native VLAN.
- When sending it out the trunk, Switch 1 sees that the outer tag matches the native VLAN. It strips that tag, as it does for all native VLAN traffic.
- The frame now carries only the inner tag, VLAN 20. Switch 2 reads it as a normal VLAN 20 frame and delivers it to the victim.
Two limits apply. The attack is one-way, because replies carry no matching double tag. It also cannot cross a router, so it is mostly useful for injecting single packets, such as a crafted UDP datagram, into the victim VLAN.
You can inspect such a frame with Scapy in a lab you own:
from scapy.all import Ether, Dot1Q, IP, ICMP
frame = (
Ether(dst="ff:ff:ff:ff:ff:ff")
/ Dot1Q(vlan=1)
/ Dot1Q(vlan=20)
/ IP(dst="192.168.20.255")
/ ICMP()
)
frame.show()Mitigation configuration
Combine the fixes. The native VLAN should be one that no user port uses.
vlan 999
name NATIVE_UNUSED
!
interface GigabitEthernet0/1
switchport mode access
switchport access vlan 10
switchport nonegotiate
!
interface GigabitEthernet0/24
switchport mode trunk
switchport trunk native vlan 999
switchport trunk allowed vlan 10,20
switchport nonegotiateWith this setup, no access port is in VLAN 999, so an attacker cannot match the native VLAN. The access port cannot trunk, so spoofing fails. The allowed list also limits what a rogue trunk could reach.
Summary of the two attacks
| Attack | Requirement | Fix |
|---|---|---|
| Switch spoofing | Port negotiates DTP | Static access mode, `nonegotiate` |
| Double tagging | Attacker in native VLAN | Unused native VLAN, allowed lists |
Exercise
A user port is set to switchport mode access in VLAN 1, and the trunk to the next switch uses native VLAN 1. Which attack is possible, and what is the smallest change that stops it?
Show answer
Double tagging is possible, because the attacker's VLAN equals the native VLAN. Change the trunk's native VLAN to an unused VLAN such as 999 on both ends, and keep user ports out of that VLAN. Switch spoofing is already blocked by the static access mode.
Exercise
Why can't an attacker using double tagging receive replies from the victim?
Show answer
The reply frame is a normal single-tagged VLAN 20 frame. It is never given the attacker's outer native VLAN tag, so it does not return to the attacker's VLAN.