OSI Layers and Common Attacks Targeting Each

Listen to this Post

Featured Image
The OSI (Open Systems Interconnection) model is a framework for understanding network communication, divided into seven layers. Each layer has specific functions and is vulnerable to different cyberattacks.

1. Physical Layer (Layer 1)

Function: Transmission of raw bits over physical media (cables, switches).

Attacks:

  • Wiretapping – Unauthorized interception of physical network signals.
  • Jamming – Disrupting wireless signals to cause denial of service.
  • Hardware tampering – Physically altering network devices.

You Should Know:

  • Use encrypted cables (e.g., fiber optics) to prevent wiretapping.
  • Monitor signal strength to detect jamming attacks.
  • Secure hardware access with locks and surveillance.

2. Data Link Layer (Layer 2)

Function: Node-to-node data transfer, MAC addressing.

Attacks:

  • MAC spoofing – Forging MAC addresses to bypass filtering.
  • ARP spoofing/poisoning – Redirecting traffic via fake ARP replies.
  • Switch port stealing – Exploiting switch vulnerabilities to hijack ports.

You Should Know:

 Prevent ARP spoofing with static ARP entries 
arp -s <IP> <MAC> 
 Enable port security on switches 
switchport port-security mac-address sticky 

3. Network Layer (Layer 3)

Function: Routing and IP addressing.

Attacks:

  • IP spoofing – Faking IP addresses to bypass filters.
  • Route injection – Manipulating routing tables.
  • DoS/DDoS (ICMP flood, Smurf attack) – Overloading networks with traffic.

You Should Know:

 Block ICMP flood with iptables 
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT 
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP 

4. Transport Layer (Layer 4)

Function: End-to-end communication, TCP/UDP.

Attacks:

  • TCP SYN flood – Exhausting server resources with half-open connections.
  • UDP flood – Overwhelming targets with UDP packets.
  • Port scanning – Identifying open ports for exploitation.

You Should Know:

 Mitigate SYN flood with SYN cookies 
sysctl -w net.ipv4.tcp_syncookies=1 
 Limit UDP flood 
iptables -A INPUT -p udp -m limit --limit 100/s -j ACCEPT 

5. Session Layer (Layer 5)

Function: Session control between devices.

Attacks:

  • Session hijacking – Stealing active sessions.
  • SSL/TLS exploits – Breaking encryption to intercept data.

You Should Know:

 Force HTTPS to prevent SSL stripping 
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains"; 

6. Presentation Layer (Layer 6)

Function: Data translation, encryption, compression.

Attacks:

  • SSL stripping – Downgrading HTTPS to HTTP.
  • Data interception – Decrypting sensitive data.
  • Code injection (via encoding flaws) – Exploiting improper data handling.

You Should Know:

 Check for weak ciphers 
openssl ciphers -v 'ALL:eNULL' | grep -E 'SSLv3|TLSv1' 

7. Application Layer (Layer 7)

Function: User interface and application services (HTTP, DNS, etc.).

Attacks:

  • Phishing – Tricking users into revealing credentials.
  • SQL injection – Manipulating databases via input fields.
  • Cross-site scripting (XSS) – Injecting malicious scripts.
  • DNS poisoning – Redirecting users to fake sites.

You Should Know:

 Prevent SQL injection with parameterized queries (Python example) 
cursor.execute("SELECT  FROM users WHERE username = %s", (user_input,)) 

What Undercode Say

Understanding OSI layers and their vulnerabilities is crucial for cybersecurity. Implementing proper defenses at each layerβ€”such as encryption, rate limiting, and secure configurationsβ€”can mitigate risks. Always monitor network traffic, apply patches, and enforce strict access controls.

Prediction

As networks evolve, attackers will develop more sophisticated multi-layer attacks. AI-driven security tools will become essential for real-time threat detection across all OSI layers.

Expected Output:

A structured guide on OSI layer attacks with actionable Linux/Windows commands for defense.

References:

Reported By: Dharamveer Prasad – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass βœ…

Join Our Cyber World:

πŸ’¬ Whatsapp | πŸ’¬ Telegram