Vị trí An ninh mạng trong Mô hình OSI – Sự thật & Hiểu lầm
Câu hỏi chứa đựng một giả định sai: An ninh mạng KHÔNG chỉ quan tâm 3 tầng Application (7), Transport (4), Network (3). Thực tế, bảo mật phải triển khai ở TẤT CẢ 7 TẦNG (Defense in Depth). Tuy nhiên, 3 tầng này nhận sự chú ý nhiều nhất do đặc thẩm giao thức và vector tấn công.
Tại sao 3 tầng này "nổi bật" nhất?
Tầng 7 – Application Layer (Điểm tiếp xúc người dùng & dữ liệu)
- Giao thức: HTTP/HTTPS, DNS, SMTP/IMAP/POP, FTP, SSH, RDP, Database protocols
- Tấn công: SQLi, XSS, CSRF, RCE, API abuse, Credential stuffing, Business logic flaw
- Bảo mật: WAF, API Gateway, Secure Coding, Input Validation, AuthZ/AuthN (OAuth/OIDC/SAML), DLP
- Lý do quan trọng: Dữ liệu business logic nằm đây. Kẻ tấn công nhắm trực tiếp giá trị (data, transaction).
Tầng 4 – Transport Layer (Kiểm soát phiên & Luồng dữ liệu)
- Giao thức: TCP, UDP, SCTP, QUIC (HTTP/3)
- Tấn công: TCP SYN Flood, TCP RST Injection, UDP Reflection/Amplification, Port Scanning, Session Hijacking
- Bảo mật: TLS/SSL (chạy trên TCP), DTLS (trên UDP), TCP SYN Cookie, Rate Limiting, Connection Tracking (Stateful Firewall)
- Lý do quan trọng: Cổng (port) là "cửa vào" dịch vụ. Stateful firewall làm việc chủ yếu ở đây (5-tuple: src/dst IP, src/dst port, protocol).
Tầng 3 – Network Layer (Định tuyến & Chuyển gói)
- Giao thức: IP (IPv4/IPv6), ICMP, ICMPv6, IPsec (AH/ESP), OSPF, BGP, IS-IS
- Tấn công: IP Spoofing, DDoS (Volumetric), Routing Hijacking (BGP), Tunnel/VPN Abuse, Fragmentation Attack
- Bảo mật: IPsec VPN, ACL (Router/Firewall), uRPF (Unicast Reverse Path Forwarding), BGPsec, RPKI, FlowSpec, DDoS Mitigation (Scrubbing Center)
- Lý do quan trọng: RanH giới mạng (perimeter), routing infrastructure, VPN termination – tất cả ở Layer 3.
Những tầng "bị quên" nhưng CỰC KỲ QUAN TRỌNG
Tầng 2 – Data Link Layer (Mạng cục bộ – LAN)
- Tấn công: ARP Spoofing/Poisoning (MITM), MAC Flooding (CAM Table Overflow), VLAN Hopping (Double Tagging, Switch Spoofing), STP Manipulation, DHCP Snooping Bypass, Rogue DHCP/RA
- Bảo mật: Port Security, DHCP Snooping, Dynamic ARP Inspection (DAI), IP Source Guard, BPDU Guard/Root Guard, Private VLAN, 802.1X (NAC), MACsec (802.1AE)
- Thực tế: Hầu hết tấn công nội bộ (Insider, Compromised host) bắt đầu từ Layer 2. Switch security là hàng rào đầu tiên trong LAN.
Tầng 1 – Physical Layer (Vật lý)
- Tấn công: Cable tapping (Fiber/Copper), Hardware implant, Evil Maid, TEMPEST (EM radiation), Power/Environmental sabotage
- Bảo mật: Physical Access Control (Badge, Biometric, Mantrap), Cable Management/Conduit, Fiber Monitoring (OTDR), TEMPEST Shielding, Port Security (Disable unused ports), Asset Tracking
- Thực tế: Nếu kẻ xấu cắm dây vào switch port mở → Layer 2/3/4/7 controls đều bypass được.
Tầng 5 – Session Layer & Tầng 6 – Presentation Layer
- TLS/SSL nằm giữa Layer 4-7 (thường phân loại Layer 5/6). Quản lý session, encryption, compression, serialization.
- Tấn công: SSL/TLS Vulnerabilities (POODLE, BEAST, CRIME, BREACH, Heartbleed, Logjam, Sweet32), Certificate Hijacking, Session Replay, Downgrade Attack
- Bảo mật: TLS 1.2/1.3 only, Strong Cipher Suites, Certificate Pinning, HSTS, Certificate Transparency Monitoring, OCSP Stapling
Ma trận kiểm soát bảo mật theo tầng OSI (Defense in Depth)
| Tầng OSI | Kiểm soát chính | Công nghệ/Ví dụ | Mức độ chú trọng thực tế |
|---|---|---|---|
| 7 Application | App Security, WAF, API Sec, DLP, AuthZ/AuthN | ModSecurity, Kong, Okta, Microsoft Purview | Rất cao (Business logic) |
| 6 Presentation | Encryption, Encoding, Serialization Security | TLS 1.3, JWT/JWE, Protobuf/Avro validation | Cao (Crypto implementation) |
| 5 Session | Session Management, TLS Handshake | Secure Cookie, Session Timeout, TLS Resumption | Cao (TLS config) |
| 4 Transport | Stateful Firewall, Rate Limit, DoS Protection | iptables/nftables, Palo Alto, FortiGate, SYN Cookie | Rất cao (Perimeter/Edge) |
| 3 Network | Routing Security, IPsec, DDoS Mitigation | BGPsec, RPKI, IPsec VPN, Cloudflare/Arbor/Akamai | Rất cao (Edge/DC Interconnect) |
| 2 Data Link | Port Security, DAI, DHCP Snooping, 802.1X, MACsec | Cisco Catalyst, Aruba, FortiSwitch, NAC | Cao (Internal LAN Security) |
| 1 Physical | Physical Access, Cable Security, Port Disable | Data Center Physical Sec, Port Lock, Fiber Monitor | Trung bình (Thường tách team Facilities) |
Kết luận
An ninh mạng phải bảo vệ tất cả 7 tầng. Câu hỏi "chỉ quan tâm 3 tầng" phản ánh thực tế ngân sách, công cụ, và visibility tập trung ở L3-L4-L7 vì:
- Dữ liệu giá trị & logic nghiệp vụ ở L7
- Cổng dịch vụ & TLS ở L4/L5-L6
- Ranh giới mạng & Routing ở L3
Nhưng bỏ qua L1-L2 là hổng lớn – kẻ tấn công nội bộ, lateral movement, MITM, pivoting đều khai thác L1-L2. Kiến trúc hiện đại (Zero Trust, Micro-segmentation, SASE) chính là nỗ lực mở rộng kiểm soát xuống tận L2 (workload identity) và L1 (device attestation).