Cyberattacks at Each OSI Layer and How to Defend Against Them

Attacks can target every layer of the OSI model.

Jul 19, 2025 - 09:52
Updated: 
105.7k

Cyber Threats, Scams & Online Safety in Cybersecurity & Ethical Hacking · Explainer

Cybersecurity Foundations

Cyberattacks at Each OSI Layer and How to Defend Against Them

Quick answer: Attacks can target every layer of the OSI model. At the physical layer, attackers tamper with cables or jam Wi-Fi; at the data link layer, they use MAC flooding, ARP spoofing and VLAN hopping; at the network layer, IP spoofing and routing attacks; at the transport layer, SYN floods and port scans; at the session layer, session hijacking; at the presentation layer, TLS downgrade and certificate attacks; and at the application layer, SQL injection, cross-site scripting, DNS attacks and phishing. Defences are layered too: physical security, switch protections, filtering and anti-spoofing, DDoS mitigation, secure session handling, strong TLS and secure coding.

Key takeaways

  • Lower-layer attacks often enable higher-layer ones, such as ARP spoofing leading to credential theft.
  • Switch features (port security, DHCP snooping, Dynamic ARP Inspection) stop many layer 2 attacks.
  • TLS with certificate validation protects against interception at higher layers.
  • Most breaches exploit layer 7: applications and people.
  • The OSI model is a teaching tool; real protocols do not map perfectly.

Table of Contents

What Attacks Target Each Layer?

LayerExample attacksDefences
7 ApplicationSQL injection, XSS, DNS spoofing, phishingSecure coding, WAF, DNSSEC, MFA
6 PresentationTLS downgrade, weak ciphers, fake certificatesTLS 1.2/1.3 only, HSTS, certificate validation
5 SessionSession hijacking, fixationSecure cookies, session rotation, timeouts
4 TransportSYN floods, port scanningSYN cookies, rate limiting, firewalls
3 NetworkIP spoofing, ICMP floods, route hijackingIngress filtering, ACLs, RPKI
2 Data linkMAC flooding, ARP spoofing, VLAN hopping, rogue DHCPPort security, DAI, DHCP snooping, 802.1X
1 PhysicalCable tapping, device theft, Wi-Fi jammingPhysical security, locked racks, monitoring

The OSI model is defined in ISO/IEC 7498-1; techniques are catalogued in MITRE ATT&CK.

How Do You Defend Layers 1 and 2?

Lock network closets and disable unused switch ports. On managed switches, enable protections against MAC flooding, rogue DHCP servers and ARP spoofing:

! Cisco IOS example
interface range GigabitEthernet1/0/1 - 24
 switchport mode access
 switchport port-security
 switchport port-security maximum 2
 switchport nonegotiate              ! prevents DTP-based VLAN hopping
!
ip dhcp snooping
ip dhcp snooping vlan 10
ip arp inspection vlan 10
interface GigabitEthernet1/0/48
 ip dhcp snooping trust
 ip arp inspection trust

See Cisco's Dynamic ARP Inspection guide. 802.1X ensures only authenticated devices connect.

How Do You Defend Layers 3 and 4?

  • Apply ingress and egress filtering to block spoofed source addresses.
  • Use RPKI to protect BGP route announcements.
  • Enable SYN cookies on servers (net.ipv4.tcp_syncookies=1 on Linux).
  • Use DDoS protection services for public services, per CISA's DDoS guidance.
  • Close unneeded ports and monitor scans.

How Do You Defend Layers 5 and 6?

  • Set cookies with Secure, HttpOnly and SameSite; rotate session IDs after login.
  • Allow only TLS 1.2 and 1.3 (RFC 8446) with strong ciphers.
  • Enable HSTS (RFC 6797) to prevent downgrade to HTTP.
  • Never disable certificate validation in apps or scripts.
# Check which TLS versions a server accepts
nmap --script ssl-enum-ciphers -p 443 example.com

How Do You Defend Layer 7?

Most real breaches happen here. Follow the OWASP Top 10: parameterised queries, output encoding, server-side authorization, and input validation. Use DNSSEC (RFC 4033) and trusted resolvers, phishing-resistant MFA and user training. See common network and application attacks.

How Can You Practise Safely?

Build an isolated lab with virtual machines or GNS3/EVE-NG, practise attacks such as ARP spoofing on your own lab network only, and confirm that switch protections block them. WebAsha's CCNA and ethical hacking courses include such labs. Related: how computer networks work.

References

Frequently Asked Questions

MAC flooding, ARP spoofing, VLAN hopping and rogue DHCP servers.

Enable DHCP snooping and Dynamic ARP Inspection on switches, and use encrypted protocols.

A transport-layer DoS attack that sends many TCP SYN packets to exhaust server resources.

Stealing or forging a session token to take over a logged-in user’s session.

The application layer (layer 7), including web application flaws and phishing.

An attack that sends traffic into a VLAN the attacker should not reach, often via switch trunk negotiation.

Allow only TLS 1.2 and 1.3, use strong ciphers and enable HSTS.

It is mainly a reference model; real protocols follow TCP/IP, but OSI helps organise thinking about attacks.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.