Chapter 4: Network, Web, and Social Engineering Attacks
Learning Objectives
Classify network attacks including protocol-based, DoS, DDoS, and man-in-the-middle attacks
Analyze web application attacks: SQL injection, command injection, and cross-site scripting (XSS)
Identify social engineering attack vectors including AI-generated phishing techniques
Map attack indicators to detection and prevention strategies
Section 1: Network Protocol Attacks
Network protocols were largely designed for reliability and interoperability, not security. Attackers exploit the implicit trust baked into ARP, DNS, VLAN tagging, and BGP to redirect traffic, impersonate hosts, or manipulate routing at global scale.
1.1 ARP Spoofing
ARP maps IP addresses to MAC addresses on a local segment. Because ARP has no authentication, any host can broadcast a forged reply claiming to own any IP, and neighboring devices will update their caches.
Host A wants to reach the gateway (192.168.1.1) and has its MAC cached.
Attacker broadcasts: "192.168.1.1 is at ATTACKER_MAC" — a gratuitous ARP reply.
Host A updates its cache — all gateway-bound traffic now flows to the attacker.
Attacker forwards traffic onward (MitM) or drops it (DoS).
Detection: Duplicate IP-to-MAC entries in ARP tables; sudden MAC changes in switch CAM tables; arpwatch/XArp alerts on gratuitous replies.
Prevention: Dynamic ARP Inspection (DAI) validates ARP packets against DHCP snooping tables; static ARP entries for critical hosts; 802.1X port authentication.
1.2 DNS Cache Poisoning
DNS resolvers cache responses for performance. Cache poisoning injects fraudulent records so queries for a legitimate domain return an attacker-controlled IP. The classic Kaminsky attack raced forged responses against the legitimate authoritative server, exploiting predictable transaction IDs.
Consequences: Users redirected to phishing clones; MX records poisoned to intercept email; certificate validation undermined.
Prevention: DNSSEC (signs records cryptographically); DNS over HTTPS (DoH) / DNS over TLS (DoT); randomized source ports and transaction IDs; short TTLs on critical records.
1.3 VLAN Hopping
Technique
Mechanism
Prerequisite
Switch Spoofing
Attacker's NIC negotiates a trunk link via DTP, gaining access to all VLANs
Port in dynamic desirable/auto mode
Double Tagging
Two 802.1Q tags; outer tag stripped by first switch, inner tag routes to target VLAN
Attacker on native VLAN; native VLAN on trunk
Prevention: Disable DTP (switchport nonegotiate); change native VLAN to unused ID (not VLAN 1); prune unused VLANs from trunks.
1.4 BGP Hijacking
BGP has no cryptographic authentication in the base protocol. A malicious AS can announce more-specific prefixes to divert global traffic. The 2008 Pakistan Telecom/YouTube incident accidentally redirected YouTube globally for two hours. The 2019 Rostelecom incident briefly redirected financial institution traffic.
Prevention: RPKI (cryptographic Route Origin Authorizations); BGPsec (signs full AS path); BGPmon anomaly monitoring.
sequenceDiagram
participant V as Host A (Victim)
participant A as Attacker
participant G as Gateway (192.168.1.1)
Note over V,G: Normal state — Host A cache: 192.168.1.1 → GW_MAC
A->>V: Gratuitous ARP Reply "192.168.1.1 is at ATTACKER_MAC"
A->>G: Gratuitous ARP Reply "HOST_A_IP is at ATTACKER_MAC"
Note over V: ARP cache poisoned
V->>A: Traffic destined for Gateway
A->>G: Attacker forwards (MitM)
G->>A: Response destined for Host A
A->>V: Attacker forwards (MitM)
Note over A: Attacker inspects/modifies all traffic
Key Points — Network Protocol Attacks
ARP has no authentication; DAI validates ARP against DHCP snooping binding tables to prevent spoofing
DNS poisoning redirects users silently — DNSSEC adds cryptographic verification of DNS record origin
VLAN hopping via DTP negotiation is prevented by disabling DTP on all access ports (switchport nonegotiate)
BGP hijacking can redirect internet-scale traffic — RPKI adds Route Origin Authorizations to validate prefix announcements
All four attacks exploit the same fundamental flaw: implicit trust without cryptographic verification
Check Your Knowledge — Section 1
1. Which mechanism prevents ARP spoofing by validating ARP packets against a DHCP snooping binding table?
A. 802.1X port authentication
B. Dynamic ARP Inspection (DAI)
C. DNSSEC
D. BGPsec
2. An attacker sends a frame with two 802.1Q tags to reach a VLAN they are not authorized on. This technique is called:
A. Switch Spoofing
B. ARP flooding
C. Double Tagging
D. Trunk poisoning
3. The 2008 Pakistan Telecom incident is a real-world example of which attack type?
A. DNS Cache Poisoning
B. BGP Hijacking
C. ARP Spoofing
D. VLAN hopping via DTP
Section 2: Denial of Service Attacks
A DoS attack makes a resource unavailable by overwhelming it with requests, exhausting protocol state, or consuming computational capacity. When originating from many distributed sources (a botnet), it becomes a DDoS attack.
UDP Flood: High-rate UDP packets to random ports; target must process each and send ICMP unreachable replies — exhausting CPU and bandwidth. Spoofed IPs prevent return traffic.
ICMP Smurf Flood: ICMP echo requests to broadcast address with victim's spoofed source IP; every host replies to the victim (amplification).
Amplification Attacks: Exploit protocols with large response/request ratios. DNS up to 179×; NTP monlist up to 556×; Memcached UDP up to 51,000×.
Protocol Attacks (Layer 3/4 — State Table Exhaustion)
SYN Flood: Floods TCP SYN packets with spoofed IPs. Server allocates a TCB for each SYN before handshake completes; half-open connections persist 75 seconds. Table fills — legitimate connections refused.
ACK/RST Flood: Forces stateful devices to perform expensive lookups for packets not matching any session.
DDoS targets three distinct resources: bandwidth (volumetric), connection state (protocol), or server compute (application)
SYN floods exploit the TCP three-way handshake — server allocates state before authentication completes
SYN cookies eliminate state table vulnerability by encoding session state in the sequence number
Amplification attacks use protocols with high response/request ratios (Memcached: up to 51,000×) and spoofed source IPs
No single mitigation defeats all DDoS categories — layered defense (scrubbing + SYN cookies + CDN) is required
Check Your Knowledge — Section 2
4. A SYN flood attack is most accurately classified as which type of DDoS?
A. Volumetric — Bandwidth Exhaustion
B. Application-Layer — Resource Exhaustion
C. Protocol — State Table Exhaustion
D. Amplification — Reflection Attack
5. Which mitigation technique encodes TCP connection state in the SYN-ACK's sequence number to prevent state table exhaustion?
A. Traffic Scrubbing
B. BGP Blackholing
C. SYN Cookies
D. Anycast CDN
6. Memcached UDP is notable in DDoS amplification because its amplification factor can reach approximately:
A. 30×
B. 179×
C. 556×
D. 51,000×
Section 3: Man-in-the-Middle and Interception Attacks
MitM attacks position the attacker between two communicating parties so all traffic flows through them. The victim believes they are communicating directly with the legitimate peer.
3.1 ARP-Based MitM
ARP spoofing poisons both the victim's ARP cache (gateway IP → attacker MAC) and the gateway's cache (victim IP → attacker MAC). With IP forwarding enabled on the attacker's system, traffic relays transparently while being inspected or modified.
3.2 SSL Stripping
SSL stripping downgrades an HTTPS connection to HTTP, allowing the attacker (already in MitM position) to intercept plaintext traffic even when the server supports TLS.
Victim's browser requests http://bank.example.com
Attacker intercepts the HTTP request
Attacker establishes a legitimate HTTPS connection to the server
Attacker serves victim an HTTP version, replacing all https:// links with http://
Victim communicates in plaintext to the attacker — no obvious browser warning
Prevention: HSTS instructs browsers to always use HTTPS for a domain; HSTS Preloading embeds the domain in browser preload lists before first connection; 301 redirects with HSTS headers.
sequenceDiagram
participant B as Victim Browser
participant A as Attacker (MitM)
participant S as Legitimate Server (HTTPS)
B->>A: HTTP GET http://bank.example.com
Note over A: Intercepts HTTP request
A->>S: HTTPS GET https://bank.example.com
S-->>A: HTTPS Response (encrypted TLS)
Note over A: Decrypts, replaces https:// with http://
A-->>B: HTTP Response (plaintext) — links downgraded
B->>A: HTTP POST credentials in PLAINTEXT
Note over A: Credentials captured!
A->>S: HTTPS POST forwarded
Note over B: No padlock. No warning. Victim unaware.
3.3 Session Hijacking
Method
Description
Cookie theft via XSS
Malicious script reads document.cookie and exfiltrates tokens
Network sniffing
Intercepts unencrypted cookies on HTTP or after SSL stripping
Predictable session IDs
Guesses or brute-forces sequentially generated tokens
Session fixation
Forces victim to use an attacker-chosen session ID before authentication
Prevention:HttpOnly (prevents JS access) and Secure (HTTPS only) cookie flags; SameSite=Strict to prevent CSRF-assisted hijacking; regenerate session tokens on privilege escalation; short timeouts.
Key Points — MitM and Interception
MitM requires gaining a position in the traffic path first — most commonly via ARP spoofing on LANs or rogue Wi-Fi APs
SSL stripping exploits the initial HTTP request before HTTPS is established — HSTS prevents this by enforcing HTTPS before any connection
HSTS Preloading removes the "first connection" window of vulnerability by hardcoding HTTPS in browser binaries
Session cookies must carry both HttpOnly and Secure flags to resist theft via XSS and plaintext interception
Session fixation is defeated by regenerating the session token immediately after authentication
Check Your Knowledge — Section 3
7. SSL stripping attacks are most effectively prevented by which mechanism?
A. TLS 1.3 enforcement on the server
B. HTTP Strict Transport Security (HSTS)
C. IPsec tunnel between client and server
D. Certificate pinning in the web server config
8. Which cookie attribute prevents a session token from being accessed by JavaScript running in the browser?
A. Secure
B. SameSite=Strict
C. HttpOnly
D. Domain=.example.com
Section 4: Web Application Attacks
Web applications represent one of the largest attack surfaces in modern IT. The OWASP Top 10 provides a consensus ranking of the most critical risks. Injection vulnerabilities (A03) have consistently ranked at the top.
4.1 SQL Injection (SQLi)
SQLi occurs when untrusted input is incorporated into a database query without sanitization, letting an attacker alter query logic.
A vulnerable login query:
SELECT * FROM users WHERE username = '$username' AND password = '$password';
With input ' OR 1=1 -- as the username:
SELECT * FROM users WHERE username = '' OR 1=1 --' AND password = 'anything';
1=1 is always true; -- comments out the password check. Returns all users — typically grants admin access.
Type
Description
Example
In-band (Classic)
Results returned in application response
Error-based, union-based
Blind
Inferred from true/false behavior or timing
Boolean-based, time-based (SLEEP())
Out-of-band
Data exfiltrated via alternate channel
DNS lookups, xp_cmdshell
Prevention: Parameterized queries/prepared statements (single most effective control); input validation; least-privilege DB accounts; WAF as defense-in-depth.
# Vulnerable
cursor.execute("SELECT * FROM users WHERE id = " + user_input)
# Safe (parameterized)
cursor.execute("SELECT * FROM users WHERE id = ?", (user_input,))
4.2 Command Injection
User-supplied input passed unsanitized to a system shell allows execution of arbitrary OS commands with the web server's privileges.
Common chaining operators:; (always), && (if first succeeds), || (if first fails), $() (command substitution).
Prevention: Avoid shell calls entirely; use language-native libraries; if unavoidable use shell=False parameterized APIs; whitelist input characters; least-privileged web server account.
4.3 Cross-Site Scripting (XSS)
Type
Persistence
Attack Vector
Reflected
None — in URL param
Crafted link sent to victim; search page echoes param
Stored
Saved in DB
Any user viewing content is attacked; forum post with script
DOM-Based
None — client-side only
Vulnerable JS reads location.hash, writes to innerHTML
Prevention: Output encoding (HTML-encode all user data before rendering); Content Security Policy (CSP) blocks inline script execution; HttpOnly cookies prevent theft; avoid innerHTML/eval() — use textContent.
4.4 OWASP Top 10 Overview
Rank
Category
Relationship to This Chapter
A01
Broken Access Control
Session hijacking, privilege escalation
A02
Cryptographic Failures
SSL stripping, weak session tokens
A03
Injection
SQL injection, command injection, XSS
A04
Insecure Design
Architectural flaws enabling MitM, logic bypass
A05
Security Misconfiguration
VLAN misconfig, open DNS resolvers
A06
Vulnerable/Outdated Components
Libraries with known SQLi/XSS vulnerabilities
A07
Identification/Authentication Failures
Session fixation, weak credential storage
A08
Software/Data Integrity Failures
Unsigned software updates, CI/CD attacks
A09
Security Logging/Monitoring Failures
Inability to detect injection or DoS events
A10
Server-Side Request Forgery (SSRF)
Internal network probing via web application
Key Points — Web Application Attacks
All injection attacks (SQLi, command injection, XSS) share one root cause: user input interpreted as code rather than data
Parameterized queries are the single most effective control against SQL injection — the query structure is fixed at compile time
Stored XSS is more dangerous than reflected XSS because it persists and automatically executes for every visitor
Content Security Policy (CSP) provides defense-in-depth against XSS by blocking inline script execution even if injection occurs
OWASP A03: Injection encompasses SQLi, command injection, and XSS — the most prevalent web risk category
Check Your Knowledge — Section 4
9. An attacker enters ' OR 1=1 -- into a login form. Which attack is this?
A. Command injection
B. Reflected XSS
C. SQL injection — authentication bypass
D. Session fixation
10. Which XSS type persists in the database and executes for every user who views the infected content?
A. Reflected XSS
B. DOM-Based XSS
C. Stored (Persistent) XSS
D. Out-of-band XSS
11. Under OWASP Top 10 2021/2025, SQL injection, command injection, and XSS are grouped under:
A. A01: Broken Access Control
B. A03: Injection
C. A07: Identification Failures
D. A02: Cryptographic Failures
Section 5: Social Engineering and AI-Enhanced Attacks
Technical defenses can block most automated exploits, which is precisely why adversaries target the human layer. Generative AI has dramatically lowered the skill barrier and raised the realism ceiling for social engineering attacks.
5.1 Phishing Attack Taxonomy
Variant
Target
Channel
Distinguishing Feature
Phishing
Mass audience
Email
Generic lure (bank, shipping, prize)
Spear phishing
Specific individual/org
Email
Personalized using OSINT on target
Whaling
C-suite executives
Email
High-value lure (legal, regulatory, board)
Vishing
Individual
Voice call
Impersonates IT support, IRS, bank
Smishing
Individual
SMS
Fake delivery notification, 2FA codes
Quishing
Individual
QR code
Bypasses URL scanners
5.2 Traditional Social Engineering Vectors
Pretexting: Fabricated scenario to build trust before a request ("I'm from IT security...")
Baiting: Malware-laden USB drives in parking lots — curiosity triggers execution
Tailgating: Following an authorized person through a secured physical door
Quid Pro Quo: Offering "free IT help" in exchange for credentials
Watering Hole: Compromising a website frequently visited by the target organization
5.3 Generative AI and the New Attack Landscape
As of 2024-2025, 82.6% of phishing emails are AI-influenced, generating contextually accurate, grammatically perfect messages tailored to the recipient's industry, role, and recent activities scraped from LinkedIn, GitHub, and press releases. Traditional phishing tell-tales (grammar errors, generic salutations) have been eliminated.
AI voice cloning statistics (2024-2025):
Voice cloning achieves 85% accuracy from 3 seconds of audio; up to 95% accuracy with more samples
Vishing attacks surged 442-449% year-over-year in 2024-2025
Deepfake-enabled vishing rose over 1,600% in Q1 2025 vs. Q4 2024
35% of people cannot distinguish a cloned voice from the real person; 25% of employees have been deceived
AI-generated fraud costs organizations avg. $14M/year; global losses projected $40B by 2027
Hong Kong CFO incident (2024): An employee attended a video conference with apparent colleagues including the CFO — all were AI-generated deepfake avatars. The employee authorized a ~$25 million USD wire transfer, believing the request was legitimate. Deepfakes have reached quality sufficient to deceive trained professionals in real-time video contexts.
5.4 AI-Enhanced Attack Patterns
Pattern
Description
Help desk impersonation
Cloned voice calls employee posing as IT support, requests password reset or MFA change
Executive fraud (BEC 2.0)
Cloned executive voice or deepfake video authorizes fraudulent financial transaction
AI spear phishing
AI scrapes LinkedIn/GitHub/corporate sites; generates hyper-personalized email
Biometric bypass
Deepfake video/audio defeats facial recognition or voice auth in KYC processes
Hybrid multi-channel
AI email followed by voice call to "verify" — mutual reinforcement lowers suspicion
5.5 Detection and Awareness Strategies
Technical controls: STIR/SHAKEN (cryptographic caller ID signing); liveness detection (randomized challenge for biometrics); AI-based email analysis; DMARC/DKIM/SPF (prevent domain spoofing).
Procedural controls: Out-of-band verification for any high-risk request using a separately established trusted channel; pre-arranged code words for executive/finance teams; callback procedures using independently looked-up numbers.
Awareness training updates for AI era:
AI eliminates grammar/spelling as phishing indicators — train employees not to rely on these
Demonstrate voice-cloning examples so employees understand the realism achievable
Train verification procedures for urgent, out-of-policy financial or access requests
Conduct simulated AI phishing campaigns to measure resilience
Establish a "verification culture" where out-of-band confirmation is normalized and rewarded