Bảo mật mạng & Zero TrustNetwork Security & Zero Trust
Thuộc bộ kiến thức DevSecOps Roadmap.
Tổng quan
Bảo mật mạng (network security) là lớp phòng thủ theo chiều sâu (defense-in-depth) kiểm soát cách traffic được phép di chuyển — giữa internet và hệ thống của bạn, giữa các zone bên trong môi trường, và giữa từng workload riêng lẻ. Trong bối cảnh DevSecOps, bảo mật mạng không chỉ là mối quan tâm ở perimeter do một team networking riêng sở hữu; nó được biểu diễn dưới dạng code (security group, network policy, firewall rule) nằm trong cùng repository và pipeline với application code, và ngày càng được xây dựng xoay quanh Zero Trust thay vì một mạng nội bộ được tin tưởng đứng sau một perimeter được gia cố kỹ.
Note này tập trung vào các khái niệm và quyết định mà một DevSecOps engineer cần: firewall, IDS/IPS và ACL làm gì và cách suy luận về rule của chúng; cách thiết kế network zone và segmentation sao cho một breach ở một chỗ không biến thành breach ở mọi chỗ; cách suy nghĩ và giảm thiểu tấn công DDoS; và cách Zero Trust Architecture định hình lại bảo mật mạng xoay quanh identity và việc xác minh liên tục thay vì vị trí mạng. Để tìm hiểu sâu hơn về cơ chế cấp thiết bị của firewall, ACL và IDS/IPS (luồng packet, chi tiết bên trong stateful inspection, cú pháp ACL kiểu Cisco, VLAN hopping, ARP poisoning, v.v.), xem Network Engineer — Network Security, viết từ góc nhìn network engineering. Note này xây dựng trên nền tảng đó và áp dụng vào cách các tổ chức cloud-native, vận hành theo pipeline hiện đại thiết kế và vận hành mạng một cách an toàn.
Đây là tài liệu giáo dục bảo mật mang tính phòng thủ (defensive): mục tiêu là hiểu các cơ chế kiểm soát này đủ sâu để thiết kế, cấu hình và audit chúng đúng cách — không phải để vượt qua (bypass) chúng.
Kiến thức nền tảng
Firewall — tóm tắt nhanh
Firewall thực thi một chính sách quy định traffic nào được phép đi qua một ranh giới (boundary). Có ba thế hệ mà một DevSecOps engineer cần nhận biết:
| Loại | Kiểm tra | Tính stateful | Ứng dụng phổ biến hiện nay |
|---|---|---|---|
| Packet-filtering | Chỉ header IP/port/protocol, theo từng packet | Stateless — mỗi packet được đánh giá độc lập | Hiếm khi đứng riêng; là nền tảng của ACL đơn giản và NACL trên cloud |
| Stateful inspection | Header + trạng thái kết nối (theo dõi phiên TCP/UDP) | Stateful — chỉ cần cho phép chiều khởi tạo, traffic trả về được tự động cho phép | Security group trên cloud, phần lớn firewall on-prem, host firewall (iptables/nftables, Windows Firewall) |
| Next-Generation Firewall (NGFW) | Header, state, và payload — nhận diện ứng dụng/người dùng, nội dung đã giải mã TLS, IPS tích hợp, threat intelligence | Stateful + deep packet inspection | Perimeter/edge, firewall segmentation nội bộ, tương đương trên cloud-native (AWS Network Firewall, Azure Firewall Premium) |
Trong môi trường cloud, tương đương hàng ngày của một stateful firewall là security group (stateful, áp dụng ở cấp instance/ENI) kết hợp với network ACL (stateless, áp dụng ở ranh giới subnet) — xem note Cloud để biết chi tiết theo từng provider. Điểm mấu chốt về vận hành cho DevSecOps: firewall rule nên được định nghĩa dưới dạng code (Terraform, CloudFormation, Kubernetes NetworkPolicy) và trải qua cùng quy trình review/CI như application code, chứ không phải chỉnh sửa thủ công trên console hay thiết bị.
IDS vs IPS
Cả Intrusion Detection System và Intrusion Prevention System đều phân tích traffic để tìm pattern độc hại; khác biệt nằm ở việc điều gì xảy ra sau khi phát hiện điều đáng ngờ.
| Khía cạnh | IDS (Intrusion Detection System) | IPS (Intrusion Prevention System) |
|---|---|---|
| Vị trí đặt | Out-of-band, theo dõi một bản sao của traffic (qua SPAN/mirror port hoặc tap) | Inline, nằm trực tiếp trên đường đi của traffic |
| Hành động khi phát hiện | Chỉ cảnh báo — ghi log, phát alarm, thông báo cho SOC/SIEM | Có thể chủ động chặn, drop packet, reset kết nối, hoặc cách ly nguồn |
| Ảnh hưởng của false positive | Alert gây nhiễu, không gián đoạn dịch vụ | Có thể drop traffic hợp lệ — rủi ro về availability nếu tinh chỉnh không tốt |
| Overhead hiệu năng | Thấp hơn (phân tích trên bản sao) | Cao hơn (phải kiểm tra và quyết định real-time, tăng độ trễ) |
| Chế độ thất bại (failure mode) | Vốn đã “fail open” (traffic đã đi qua rồi) | Phải cấu hình rõ ràng fail-open hay fail-closed |
Phương pháp phát hiện (áp dụng cho cả IDS và IPS):
- Signature-based — so khớp traffic với cơ sở dữ liệu các pattern tấn công đã biết (giống signature của antivirus). Nhanh, tỷ lệ false-positive thấp với threat đã biết, nhưng không nhận ra được tấn công mới/zero-day và dễ bị né tránh bằng những biến thể nhỏ. Ví dụ: rule Snort/Suricata so khớp byte pattern của một exploit cụ thể.
- Anomaly-based — xây dựng baseline về traffic/hành vi “bình thường” (khối lượng traffic, cách dùng protocol, pattern kết nối) và gắn cờ những sai lệch. Có thể bắt được tấn công mới và zero-day, nhưng tỷ lệ false-positive cao hơn và cần thời gian tune/học.
- Hybrid — hầu hết sản phẩm hiện đại (ví dụ: Suricata, module IPS/NGFW thương mại) kết hợp cả hai, cộng thêm reputation feed và phát hiện dựa trên hành vi/ML để có tín hiệu phong phú hơn.
NIDS vs HIDS: một Network IDS/IPS (Suricata, Snort, Zeek) theo dõi traffic trên đường truyền tại một điểm nghẽn (span port, inline tap); một Host IDS/IPS (OSSEC, Wazuh, Falco cho container) theo dõi hoạt động trên một host hoặc container đơn lẻ — file integrity, process execution, syscall. Trong pipeline DevSecOps, các công cụ kiểu HIDS chạy dưới dạng sidecar hoặc DaemonSet (ví dụ: Falco trong Kubernetes) thường liên quan hơn so với network tap cổ điển, vì traffic east-west bên trong một cluster hoặc overlay network là vô hình đối với một NIDS ở perimeter.
ACL (Access Control List)
ACL là một danh sách có thứ tự các rule permit/deny được so khớp với đặc điểm của traffic. Hai dạng cốt lõi:
| Loại | So khớp trên | Độ chi tiết | Vị trí đặt điển hình |
|---|---|---|---|
| Standard ACL | Chỉ địa chỉ IP nguồn | Thô | Gần đích (vì không thể lọc theo service/đích) |
| Extended ACL | IP nguồn, IP đích, protocol, port nguồn/đích | Chi tiết | Gần nguồn (lọc traffic càng sớm càng tốt) |
Ba quy tắc cần khắc cốt ghi tâm:
- Thứ tự quan trọng — rule được đánh giá từ trên xuống dưới, và rule khớp đầu tiên sẽ thắng; một “deny” rộng đặt trên một “permit” cụ thể sẽ âm thầm chặn permit đó và không bao giờ được xử lý tới.
- Implicit deny (deny ngầm định) — gần như mọi hiện thực ACL đều kết thúc bằng một “deny all” vô hình sau rule tường minh cuối cùng. Nếu không có gì khớp, traffic bị drop. Đây chính là biểu hiện thực tế của default-deny / least privilege ở tầng mạng.
- Hướng (direction) — ACL được áp dụng theo từng interface, theo từng hướng (inbound vs outbound); cùng một danh sách rule có thể mang ý nghĩa rất khác nhau tùy vào việc nó được gắn theo hướng nào.
Ví dụ extended ACL (cú pháp Cisco IOS) cho phép HTTPS tới web tier từ bất kỳ đâu, SSH chỉ từ subnet quản trị, và deny mọi thứ còn lại:
ip access-list extended WEB-TIER-IN
permit tcp any host 10.0.1.10 eq 443
permit tcp 10.0.100.0 0.0.0.255 host 10.0.1.10 eq 22
deny ip any any log
!
interface GigabitEthernet0/1
ip access-group WEB-TIER-IN in
Ý định tương đương được biểu diễn dưới dạng Kubernetes NetworkPolicy (namespace default-deny, sau đó allow tường minh) — phiên bản cloud-native, thân thiện với pipeline của ACL ở trên:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: web-tier
spec:
podSelector: {}
policyTypes: ["Ingress", "Egress"]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-https-from-anywhere
namespace: web-tier
spec:
podSelector:
matchLabels: { app: web }
policyTypes: ["Ingress"]
ingress:
- from: []
ports:
- protocol: TCP
port: 443
Chú ý ba nguyên tắc trên vẫn áp dụng: một default-deny tường minh, các allow rule được thu hẹp phạm vi, và cách đánh giá mang tính cộng dồn (rule NetworkPolicy của Kubernetes được OR với nhau — không có kiểu “khớp đầu tiên thắng” như ACL của Cisco, đây là khác biệt quan trọng cần lưu ý khi chuyển đổi giữa hai mô hình).
Để tìm hiểu sâu hơn về cú pháp ACL, wildcard mask và cơ chế cấu hình theo từng thiết bị, xem Network Engineer — Network Security § ACLs.
Khái niệm chính
Network segmentation và secure zoning
Segmentation chia mạng thành các zone tách biệt để việc một zone bị compromise không tự động cho phép truy cập vào mọi zone khác — nó giới hạn blast radius (phạm vi ảnh hưởng) của kẻ tấn công và làm chậm hoặc chặn đứng lateral movement (di chuyển ngang).
| Zone/kỹ thuật | Mục đích | Ví dụ |
|---|---|---|
| DMZ (demilitarized zone) | Chứa các hệ thống cần truy cập được từ internet, tách biệt khỏi mạng nội bộ đáng tin cậy | Web server public, reverse proxy, mail gateway |
| Internal zone (zone nội bộ) | Nhóm các hệ thống nội bộ theo mức độ tin cậy hoặc chức năng để traffic xuyên zone phải đi qua một policy enforcement point | VLAN người dùng, VLAN server/app, VLAN database, VLAN quản trị |
| Microsegmentation | Thực thi chính sách chi tiết, thường theo từng workload — xuống tới từng pod, container, hoặc VM — bất kể topology vật lý/mạng | Kubernetes NetworkPolicy, security group theo từng service trên cloud, service mesh mTLS + authorization policy (Istio, Linkerd) |
Tại sao segmentation quan trọng đến vậy trong thực tế: hầu hết các breach nghiêm trọng không phải là “kẻ tấn công vào được một server và thế là xong” — mà là một chuỗi: chỗ đứng chân ban đầu (ví dụ: một web app dễ tổn thương trong DMZ) → di chuyển ngang (tới database hoặc hệ thống admin nội bộ) → leo thang đặc quyền (privilege escalation) → exfiltration (đánh cắp dữ liệu). Segmentation phá vỡ chuỗi này ở bước thứ hai. Nếu không có nó, một container bị compromise thường có thể tới được mọi service khác trong một mạng phẳng; với microsegmentation đúng cách, chính container đó chỉ có thể tới các service cụ thể mà NetworkPolicy/security group của nó cho phép tường minh — mọi thứ còn lại là implicit deny.
Nguyên tắc thiết kế segmentation:
- Segment theo mức độ tin cậy và blast-radius, không chỉ theo phòng ban — production vs. staging, hệ thống trong phạm vi PCI vs. mọi thứ khác, hệ thống chứa PII vs. hệ thống không chứa.
- Thực thi default-deny giữa các zone; chỉ allow tường minh những luồng mà kiến trúc đã ghi chép thực sự cần (điều này khớp trực tiếp với ví dụ ACL/NetworkPolicy ở trên).
- Đặt một policy enforcement point (firewall, ranh giới security group, sidecar service mesh) tại mọi ranh giới zone — segmentation không có enforcement chỉ là một sơ đồ trên giấy.
- Trong môi trường Kubernetes/cloud-native, mặc định dùng NetworkPolicy default-deny ở cấp namespace cộng với allow rule tường minh cho từng service, phản chiếu mô hình DMZ/zone nội bộ ở cấp workload.
Chiến lược giảm thiểu DDoS
Tấn công Distributed Denial of Service (DDoS) nhắm vào việc làm cạn kiệt availability của mục tiêu — băng thông, trạng thái kết nối, hoặc năng lực ứng dụng — bằng traffic từ nhiều nguồn phân tán. Việc giảm thiểu hiệu quả phụ thuộc vào việc nhận diện tầng nào đang bị tấn công.
| Loại tấn công | Tầng OSI | Cạn kiệt cái gì | Ví dụ | Giảm thiểu chính |
|---|---|---|---|---|
| Volumetric | L3/L4 | Băng thông mạng | UDP/ICMP flood, khuếch đại DNS/NTP | Anycast + scrubbing center, dịch vụ DDoS protection của ISP/cloud thượng nguồn, blackhole nguồn cực đoan |
| Protocol | L3/L4 | Bảng trạng thái kết nối của server/thiết bị mạng | SYN flood, ping of death, tấn công phân mảnh packet | SYN cookie, giới hạn số kết nối trên stateful firewall, rate limiting ở edge |
| Application-layer | L7 | Năng lực compute/database của ứng dụng/backend | HTTP flood, slow POST (Slowloris), lạm dụng API vào endpoint tốn kém | Rule WAF, rate limiting theo client/IP/API key, CAPTCHA/trang challenge, caching (CDN), validate request |
Các kỹ thuật giảm thiểu cốt lõi, dùng kết hợp:
- Rate limiting — giới hạn số request theo nguồn (IP, API key, người dùng) trong một khoảng thời gian; áp dụng ở edge (CDN/WAF), load balancer, API gateway, và tầng ứng dụng.
- Traffic scrubbing — chuyển hướng traffic đáng ngờ qua một scrubbing center hoặc dịch vụ DDoS protection trên cloud (AWS Shield, Cloudflare Magic Transit/Spectrum, Azure DDoS Protection) để lọc traffic độc hại và chỉ chuyển tiếp traffic sạch về origin.
- Anycast routing — quảng bá cùng một địa chỉ IP từ nhiều điểm hiện diện (point of presence) phân tán về mặt địa lý để traffic tấn công volumetric được hấp thụ và pha loãng trên nhiều địa điểm thay vì dồn vào một origin duy nhất.
- CDN/edge caching — phục vụ nội dung tĩnh và có thể cache từ edge node để một luồng request ồ ạt không bao giờ chạm tới hạ tầng origin.
- Overprovisioning và autoscaling — hấp thụ những đợt burst ngắn, dù riêng nó không ngăn được một tấn công đủ lớn và có thể biến thành kịch bản “scale tới phá sản” tốn kém nếu không kết hợp với rate limiting.
- Lọc theo geo/reputation IP — chặn hoặc thách thức traffic từ những dải/khu vực không có mối quan hệ kinh doanh hợp pháp nào với dịch vụ, như một bộ lọc thô ban đầu.
- BCP38 / anti-spoofing tại edge mạng — việc ISP và nhà vận hành mạng lọc packet có địa chỉ nguồn giả mạo làm giảm hiệu quả của tấn công khuếch đại và phản xạ trên toàn ngành (bối cảnh liên quan dù phần lớn được thực thi ở thượng nguồn, không phải bởi chủ sở hữu ứng dụng).
Một kế hoạch ứng phó DDoS (một phần của incident response) nên xác định: ai công bố sự cố, tầng giảm thiểu nào kích hoạt tự động (rule CDN/WAF) so với cần quyết định của con người (liên hệ nhà cung cấp scrubbing thượng nguồn), và cách truyền đạt tình trạng trong suốt sự cố.
Zero Trust Architecture (NIST SP 800-207)
Zero Trust đảo ngược mô hình bảo mật mạng truyền thống. Bảo mật perimeter kiểu “castle-and-moat” (lâu đài-hào nước) truyền thống giả định rằng bất cứ thứ gì bên trong ranh giới mạng đều tương đối đáng tin cậy — một khi thiết bị hoặc người dùng đã ở trong mạng nội bộ, họ thường có thể tiếp cận một loạt tài nguyên khác với rất ít ma sát bổ sung. Zero Trust giả định điều ngược lại: không người dùng, thiết bị, hay vị trí mạng nào được tin tưởng mặc định, bất kể request xuất phát từ đâu — mọi request đều phải được xác thực (authenticate), phân quyền (authorize), và mã hóa, liên tục, dựa trên identity và ngữ cảnh (context) thay vì vị trí mạng. Điều này được thể hiện trong khẩu hiệu “never trust, always verify”.
Các nguyên tắc cốt lõi từ NIST SP 800-207:
- Mọi nguồn dữ liệu và dịch vụ tính toán đều được coi là resource — mọi resource đều cần access control, không có ngoại lệ vì “nằm trong nội bộ”.
- Mọi giao tiếp đều được bảo mật bất kể vị trí mạng — việc ở trên LAN của công ty không mang lại tin cậy ngầm định; traffic được mã hóa và xác thực như nhau bất kể xuất phát từ nội bộ hay bên ngoài.
- Quyền truy cập vào từng resource riêng lẻ được cấp theo từng phiên (per-session) — trust được đánh giá và cấp cho một phiên/request đơn lẻ, không phải một cách dai dẳng cho thiết bị hay người dùng sau khi đã xác thực một lần.
- Quyền truy cập được xác định bởi policy động — được đánh giá dựa trên identity, tình trạng/độ khỏe của thiết bị (device posture), thuộc tính hành vi, và ngữ cảnh môi trường (thời gian, vị trí, threat intelligence), không chỉ dựa trên một vai trò (role) tĩnh.
- Tổ chức giám sát và đo lường tính toàn vẹn cùng tư thế bảo mật của mọi tài sản (asset) sở hữu và liên quan — tình trạng sức khỏe/patch của thiết bị được đưa vào quyết định truy cập.
- Mọi xác thực và phân quyền resource đều động và được thực thi nghiêm ngặt trước khi cho phép truy cập — đánh giá lại liên tục, không phải “xác thực một lần, tin tưởng mãi mãi”.
- Tổ chức thu thập càng nhiều thông tin càng tốt về trạng thái hiện tại của asset, hạ tầng mạng, và giao tiếp, và dùng nó để cải thiện tư thế bảo mật — logging và telemetry phản hồi ngược lại vào policy.
Các thành phần kiến trúc (mô hình NIST 800-207):
- Policy Engine (PE) — thành phần ra quyết định; đánh giá một request dựa trên policy và tín hiệu bên ngoài (threat intelligence, dữ liệu identity provider, device posture) và đưa ra quyết định allow/deny.
- Policy Administrator (PA) — thực thi quyết định của PE bằng cách thiết lập hoặc chấm dứt đường giao tiếp (ví dụ: phát hành credential/token có thời hạn ngắn, cấu hình PEP).
- Policy Enforcement Point (PEP) — thành phần thực sự chặn/kiểm soát kết nối dựa trên chỉ thị của PA (một gateway, proxy, sidecar, hoặc agent đứng trước resource). Đây là phần thực tế, hàng ngày mà một DevSecOps engineer cấu hình — về bản chất, mỗi service có perimeter nhỏ của riêng nó.
PE + PA kết hợp lại thường được gọi chung là Policy Decision Point (PDP), đối lập với PEP nằm gần resource hơn.
Cơ chế then chốt hiện thực hóa Zero Trust trong thực tế:
- Identity-centric access (truy cập lấy identity làm trung tâm) — quyết định truy cập được neo vào identity đã được xác thực mạnh (identity người dùng và/hoặc workload/service qua chứng chỉ mTLS hoặc SPIFFE/SPIRE), không phải IP nguồn hay network segment. Đây là lý do Zero Trust và IAM không thể tách rời — xem Identity and Access Management để biết về xác thực, phân quyền, và thiết kế truy cập least-privilege.
- Microsegmentation — thực thi policy theo từng workload (xem ở trên) sao cho ngay cả sau khi xác thực, một workload chỉ có thể tới các dependency cụ thể mà nó cần, không hơn.
- Kiểm tra tình trạng thiết bị/endpoint — xác minh thiết bị gửi request được quản lý, đã patch, và tuân thủ chính sách trước khi cấp quyền truy cập, không chỉ xác minh credential của người dùng.
- ZTNA (Zero Trust Network Access) — thay thế truy cập từ xa dựa trên VPN truyền thống kiểu “kết nối vào mạng, rồi tin tưởng mọi thứ” bằng truy cập môi giới (brokered), đã xác minh identity, theo từng ứng dụng (ví dụ: Google BeyondCorp, Cloudflare Access, Zscaler Private Access). Người dùng không bao giờ được đặt “vào trong mạng”; mỗi kết nối tới ứng dụng được phân quyền riêng lẻ.
- Credential ngắn hạn và xác minh liên tục — session token, credential của service, và chứng chỉ có thời hạn ngắn và được cấp lại/xác minh lại thường xuyên thay vì được tin tưởng vô thời hạn sau một lần đăng nhập.
Defense-in-depth áp dụng vào thiết kế mạng
Zero Trust không thay thế firewall, IDS/IPS, hay segmentation — nó là nguyên lý tổ chức gắn kết chúng lại với nhau, với identity là lớp kết nối. Một mạng được thiết kế tốt áp dụng tất cả những điều này cùng nhau, theo từng lớp:
- Lớp 1Edge / CDN / WAFPerimeter: NGFW/WAF, DDoS scrubbing, anycast
- Lớp 2DMZdịch vụ public-facing, reverse proxy
- Lớp 3Mạng lõi nội bộSegmentation: zone nội bộ, VLAN/subnet, NACL; đi qua policy enforcement point — extended ACL / stateful FW
- Lớp 4Users và ServicesMicrosegmentation: NetworkPolicy theo workload / security group / service-mesh mTLS
- Lớp 5PEPpolicy enforcement point theo từng service — sidecar/gateway. Lớp identity Zero Trust: mọi request được xác thực và phân quyền bất kể xuất phát từ zone nào
- Lớp 6ResourceDetection: IDS/IPS (NIDS tại điểm nghẽn, HIDS theo từng host/container), logging tập trung tới SIEM
Mỗi lớp giả định rằng những lớp “bên ngoài” nó có thể thất bại: firewall perimeter có thể bị cấu hình sai, một host trong DMZ có thể bị compromise, kẻ tấn công có thể có được credential trông có vẻ hợp lệ — việc xác minh liên tục, dựa trên identity ở mọi hop của Zero Trust chính là thứ giới hạn mức độ lan rộng của một thất bại đơn lẻ đó, và IDS/IPS cùng logging tập trung là thứ biến “chúng ta đã bị breach” thành “chúng ta phát hiện trong vài phút, không phải vài tháng”. Điều này mở rộng trực tiếp mô hình defense-in-depth từ note Giới thiệu DevSecOps sang cụ thể tầng mạng.
Bảo mật perimeter truyền thống vs. Zero Trust
| Khía cạnh | Perimeter truyền thống (“castle-and-moat”) | Zero Trust |
|---|---|---|
| Cơ sở của trust | Vị trí mạng (bên trong = tin cậy, bên ngoài = không tin cậy) | Identity và ngữ cảnh (người dùng, thiết bị, workload) — vị trí không phải là tín hiệu tin cậy |
| Perimeter | Một ranh giới được gia cố duy nhất (firewall ở edge) | Không có perimeter duy nhất; mọi resource tự thực thi ranh giới của riêng nó (PEP) |
| Traffic nội bộ | Phần lớn được tin cậy sau khi qua perimeter (mạng nội bộ phẳng) | Được xác thực và phân quyền ở mọi request, mã hóa khi truyền |
| Độ chi tiết truy cập | Rộng — truy cập cấp VLAN/subnet một khi đã kết nối | Chi tiết — theo từng resource, từng phiên, least-privilege |
| Mô hình truy cập từ xa | VPN — đặt người dùng từ xa “vào trong mạng” | ZTNA — môi giới truy cập tới từng ứng dụng riêng lẻ, người dùng không bao giờ gia nhập mạng |
| Rủi ro lateral movement | Cao — compromise một host thường làm lộ nhiều host khác | Thấp — microsegmentation và xác thực theo từng request giới hạn resource có thể tiếp cận |
| Cơ sở của policy | Rule tĩnh (IP/subnet/port) | Policy động (identity, device posture, hành vi, tín hiệu rủi ro) |
| Chế độ thất bại | Điểm lỗi đơn (single point of failure) — phá được perimeter, tiếp cận được mọi thứ bên trong | Defense-in-depth theo thiết kế — compromise một credential/phiên không cấp quyền truy cập rộng |
| Nơi thực thi | Thiết bị mạng ở edge | Phân tán — mọi ranh giới service/workload |
Zero Trust không có nghĩa là “không có bảo mật mạng” hay “không có firewall” — segmentation, ACL, IDS/IPS, và phòng thủ perimeter đều vẫn hiện diện; Zero Trust bổ sung một bước kiểm tra identity-và-ngữ-cảnh bắt buộc ở mọi hop thay vì dựa vào vị trí mạng như một tín hiệu tin cậy ngầm định. Trong thực tế, hầu hết tổ chức chuyển sang Zero Trust theo từng bước, phủ thêm identity-aware proxy và microsegmentation lên một mạng đã được segment sẵn thay vì thay thế toàn bộ trong một đêm.
Best Practices
- Default-deny ở mọi nơi — ở cấp firewall/ACL, cấp namespace Kubernetes, và cấp policy Zero Trust. Chỉ allow tường minh, cho những luồng đã được ghi chép và thực sự cần thiết.
- Coi network policy là code — firewall rule, security group, và manifest
NetworkPolicyphải nằm trong version control, trải qua review pull request, và được áp dụng qua CI/CD, không chỉnh sửa thủ công trên console hay thiết bị. - Segment theo blast radius, không phải theo sự tiện lợi — tách production khỏi non-production, và cách ly các hệ thống xử lý dữ liệu nhạy cảm/theo quy định, dù điều đó có nghĩa là phải quản lý nhiều zone hơn.
- Giả định perimeter sẽ bị breach — đầu tư nhiều vào internal segmentation, microsegmentation, và xác minh identity ngang bằng với firewall ở edge; một breach ở một lớp không được phép lan rộng theo tầng.
- Ưu tiên ZTNA hơn VPN truy cập phẳng cho truy cập từ xa/bên thứ ba — môi giới truy cập theo từng ứng dụng thay vì đặt bất kỳ bên nào từ xa “vào trong mạng”.
- Khớp vị trí đặt và chế độ của IDS/IPS với khẩu vị rủi ro (risk tolerance) — chỉ dùng IPS (inline, chặn) ở những nơi false positive đã được hiểu rõ và tinh chỉnh; bắt đầu detection mới ở chế độ IDS (chỉ cảnh báo) và nâng lên chế độ chặn khi đã đủ tin cậy.
- Quan sát traffic east-west, không chỉ north-south — triển khai detection ở cấp host/container (Falco, Wazuh, telemetry của service mesh) vì một NIDS ở perimeter không thể thấy traffic giữa các service nội bộ.
- Thiết kế và diễn tập ứng phó DDoS trước khi tấn công xảy ra, không phải trong lúc tấn công — biết rõ giảm thiểu nào là tự động (rule CDN/WAF, rate limit) và giảm thiểu nào cần quyết định của con người, và thử nghiệm chuyển đổi sang nhà cung cấp scrubbing.
- Kết hợp network control với identity mạnh — network segmentation mà không có xác thực/phân quyền mạnh là Zero Trust chưa hoàn chỉnh; xem Identity and Access Management để biết phần identity của phương trình này.
- Liên tục kiểm thử các control của bạn — xác thực ACL, ranh giới segmentation, và việc thực thi policy Zero Trust bằng các công cụ và kỹ thuật trong Security Testing Tools, không chỉ ở thời điểm thiết kế ban đầu.
Tài liệu tham khảo
- NIST SP 800-207 — Zero Trust Architecture
- NIST SP 800-53 — Security and Privacy Controls for Information Systems and Organizations
- Cloudflare Learning Center — What is Zero Trust?
- Cloudflare Learning Center — What is a DDoS Attack?
- Cloudflare Learning Center — Firewall vs. IDS vs. IPS
- OWASP — Network Segmentation Cheat Sheet
- Kubernetes — Network Policies documentation
- Network Engineer — Network Security (đào sâu cấp thiết bị)
Part of the DevSecOps Roadmap knowledge base.
Overview
Network security is the layer of defense-in-depth that controls how traffic is allowed to move — between the internet and your systems, between zones inside your environment, and between individual workloads. In a DevSecOps context, network security is not just a perimeter concern owned by a networking team; it is expressed as code (security groups, network policies, firewall rules) that lives in the same repositories and pipelines as application code, and it is increasingly built around Zero Trust rather than a trusted internal network behind a hardened perimeter.
This note focuses on the concepts and decisions a DevSecOps engineer needs: what firewalls, IDS/IPS, and ACLs do and how to reason about their rules; how to design network zones and segmentation so a breach in one place doesn’t become a breach everywhere; how to think about and mitigate DDoS attacks; and how Zero Trust Architecture reframes network security around identity and continuous verification instead of location. For the deeper device-level mechanics of firewalls, ACLs, and IDS/IPS (packet flow, stateful inspection internals, Cisco-style ACL syntax, VLAN hopping, ARP poisoning, etc.), see Network Engineer — Network Security, which covers this from a network engineering perspective. This note builds on that foundation and applies it to how modern, cloud-native, pipeline-driven organizations design and operate networks securely.
This is defensive security education: the goal is to understand these controls well enough to design, configure, and audit them correctly — not to bypass them.
Fundamentals
Firewalls — a brief recap
A firewall enforces a policy of what traffic is permitted to cross a boundary. Three generations matter for a DevSecOps engineer to recognize:
| Type | Inspects | Statefulness | Typical use today |
|---|---|---|---|
| Packet-filtering | IP/port/protocol headers only, per packet | Stateless — each packet judged in isolation | Rare standalone; underlies simple ACLs and cloud NACLs |
| Stateful inspection | Headers + connection state (tracks the TCP/UDP session) | Stateful — only need to allow the initiating direction, return traffic auto-permitted | Cloud security groups, most on-prem firewalls, host firewalls (iptables/nftables, Windows Firewall) |
| Next-Generation Firewall (NGFW) | Headers, state, and payload — application/user identity, TLS-inspected content, embedded IPS, threat intelligence | Stateful + deep packet inspection | Perimeter/edge, internal segmentation firewalls, cloud-native equivalents (AWS Network Firewall, Azure Firewall Premium) |
In cloud environments, the everyday equivalent of a stateful firewall is the security group (stateful, applied at the instance/ENI level) paired with a network ACL (stateless, applied at the subnet boundary) — see the Cloud notes for provider-specific details. The key operational point for DevSecOps: firewall rules should be defined as code (Terraform, CloudFormation, Kubernetes NetworkPolicy) and go through the same review/CI process as application code, not be edited by hand in a console.
IDS vs IPS
Both Intrusion Detection Systems and Intrusion Prevention Systems analyze traffic for malicious patterns; the difference is what happens once something suspicious is found.
| Aspect | IDS (Intrusion Detection System) | IPS (Intrusion Prevention System) |
|---|---|---|
| Placement | Out-of-band, monitors a copy of traffic (via SPAN/mirror port or tap) | Inline, sits directly in the traffic path |
| Action on detection | Alerts only — logs, raises an alarm, notifies SOC/SIEM | Can actively block, drop the packet, reset the connection, or quarantine the source |
| Impact of a false positive | Noisy alert, no service disruption | Can drop legitimate traffic — availability risk if tuned poorly |
| Performance overhead | Lower (analysis happens on a copy) | Higher (must inspect and decide in real time, adds latency) |
| Failure mode | Fails open by nature (traffic already passed) | Must be explicitly configured fail-open vs fail-closed |
Detection methods (apply to both IDS and IPS):
- Signature-based — matches traffic against a database of known attack patterns (like antivirus signatures). Fast, low false-positive rate for known threats, but blind to novel/zero-day attacks and easily evaded by small variations. Example: Snort/Suricata rules matching a specific exploit’s byte pattern.
- Anomaly-based — builds a baseline of “normal” traffic/behavior (traffic volume, protocol usage, connection patterns) and flags deviations. Can catch novel and zero-day attacks, but has a higher false-positive rate and requires a tuning/learning period.
- Hybrid — most modern products (e.g., Suricata, commercial NGFW/IPS modules) combine both, plus reputation feeds and behavioral/ML-based detection for a richer signal.
NIDS vs HIDS: a Network IDS/IPS (Suricata, Snort, Zeek) watches traffic on the wire at a chokepoint (span port, inline tap); a Host IDS/IPS (OSSEC, Wazuh, Falco for containers) watches activity on a single host or container — file integrity, process execution, syscalls. In a DevSecOps pipeline, HIDS-style tools running as sidecars or DaemonSets (e.g., Falco in Kubernetes) are often more relevant than classic network taps, because east-west traffic inside a cluster or overlay network is invisible to a perimeter NIDS.
ACLs (Access Control Lists)
An ACL is an ordered list of permit/deny rules matched against traffic characteristics. Two core forms:
| Type | Matches on | Granularity | Typical placement |
|---|---|---|---|
| Standard ACL | Source IP address only | Coarse | Close to the destination (since it can’t filter by service/destination) |
| Extended ACL | Source IP, destination IP, protocol, source/destination port | Fine-grained | Close to the source (filter traffic as early as possible) |
Three rules to internalize:
- Order matters — rules are evaluated top-to-bottom, and the first match wins; a broad “deny” placed above a specific “permit” silently blocks the permit and never gets reached.
- Implicit deny — nearly every ACL implementation ends with an invisible “deny all” after the last explicit rule. If nothing matches, the traffic is dropped. This is the practical expression of default-deny / least privilege at the network layer.
- Direction — ACLs are applied per-interface, per-direction (inbound vs outbound); the same list of rules can mean something very different depending on which direction it’s bound to.
Example extended ACL (Cisco IOS syntax) allowing HTTPS to a web tier from anywhere, SSH only from a management subnet, and denying everything else:
ip access-list extended WEB-TIER-IN
permit tcp any host 10.0.1.10 eq 443
permit tcp 10.0.100.0 0.0.0.255 host 10.0.1.10 eq 22
deny ip any any log
!
interface GigabitEthernet0/1
ip access-group WEB-TIER-IN in
Equivalent intent expressed as a Kubernetes NetworkPolicy (default-deny namespace, then explicit allows) — the cloud-native, pipeline-friendly analogue of the ACL above:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: web-tier
spec:
podSelector: {}
policyTypes: ["Ingress", "Egress"]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-https-from-anywhere
namespace: web-tier
spec:
podSelector:
matchLabels: { app: web }
policyTypes: ["Ingress"]
ingress:
- from: []
ports:
- protocol: TCP
port: 443
Notice the same three principles apply: an explicit default-deny, narrowly scoped allow rules, and evaluation that is additive (Kubernetes NetworkPolicy rules are OR’d together — there’s no “first match wins” ordering the way Cisco ACLs have, which is a meaningful difference to be aware of when translating one model to the other).
For deeper ACL syntax, wildcard masks, and per-device configuration mechanics, see Network Engineer — Network Security § ACLs.
Key Concepts
Network segmentation and secure zoning
Segmentation divides a network into isolated zones so that compromising one zone does not automatically grant access to every other zone — it limits an attacker’s blast radius and slows or stops lateral movement.
| Zone/technique | Purpose | Example |
|---|---|---|
| DMZ (demilitarized zone) | Hosts systems that must be reachable from the internet, isolated from the trusted internal network | Public-facing web servers, reverse proxies, mail gateways |
| Internal zones | Group internal systems by trust level or function so cross-zone traffic must pass a policy enforcement point | User VLAN, server/app VLAN, database VLAN, management VLAN |
| Microsegmentation | Fine-grained, often per-workload policy enforcement — down to individual pods, containers, or VMs — regardless of physical/network topology | Kubernetes NetworkPolicy, cloud security groups per service, service mesh mTLS + authorization policy (Istio, Linkerd) |
Why segmentation matters so much in practice: most serious breaches are not “attacker gets into one server and it’s over” — they are a chain: initial foothold (e.g., a vulnerable web app in the DMZ) → lateral movement (to a database or internal admin system) → privilege escalation → exfiltration. Segmentation breaks this chain at the second step. Without it, a single compromised container can often reach every other service in a flat network; with proper microsegmentation, that same container can only reach the specific services its NetworkPolicy/security group explicitly allows — everything else is an implicit deny.
Segmentation design guidelines:
- Segment by trust level and blast-radius, not just by department — production vs. staging, PCI-scoped systems vs. everything else, systems holding PII vs. systems that don’t.
- Enforce default-deny between zones; explicitly allow only the flows a documented architecture actually needs (this pairs directly with the ACL/NetworkPolicy examples above).
- Put a policy enforcement point (firewall, security group boundary, service mesh sidecar) at every zone boundary — segmentation without enforcement is just a diagram.
- In Kubernetes/cloud-native environments, default to namespace-level default-deny NetworkPolicies plus explicit allow rules per service, mirroring the DMZ/internal-zone model at the workload level.
DDoS mitigation strategy
A Distributed Denial of Service (DDoS) attack aims to exhaust a target’s availability — bandwidth, connection state, or application capacity — using traffic from many distributed sources. Effective mitigation depends on recognizing which layer is being attacked.
| Attack category | OSI layer | What it exhausts | Example | Primary mitigation |
|---|---|---|---|---|
| Volumetric | L3/L4 | Network bandwidth | UDP/ICMP floods, DNS/NTP amplification | Anycast + scrubbing centers, upstream ISP/cloud DDoS protection service, blackholing extreme sources |
| Protocol | L3/L4 | Server/network device connection-state tables | SYN flood, ping of death, fragmented packet attacks | SYN cookies, stateful firewall connection limits, rate limiting at the edge |
| Application-layer | L7 | Application/backend compute or database capacity | HTTP flood, slow POST (Slowloris), API abuse against expensive endpoints | WAF rules, rate limiting per client/IP/API key, CAPTCHA/challenge pages, caching (CDN), request validation |
Core mitigation techniques, used in combination:
- Rate limiting — cap requests per source (IP, API key, user) over a time window; applied at the edge (CDN/WAF), load balancer, API gateway, and application layers.
- Traffic scrubbing — redirect suspicious traffic through a scrubbing center or cloud DDoS protection service (AWS Shield, Cloudflare Magic Transit/Spectrum, Azure DDoS Protection) that filters malicious traffic and forwards only clean traffic to the origin.
- Anycast routing — announce the same IP address from multiple geographically distributed points of presence so volumetric attack traffic is absorbed and diluted across many locations instead of overwhelming a single origin.
- CDN/edge caching — serve static and cacheable content from edge nodes so a flood of requests never reaches origin infrastructure at all.
- Overprovisioning and autoscaling — absorb short bursts, though this alone doesn’t stop a sufficiently large attack and can turn into a costly “scale to bankruptcy” scenario if not paired with rate limiting.
- Geo/IP reputation filtering — block or challenge traffic from ranges/regions with no legitimate business relationship to the service, as a coarse first filter.
- BCP38 / anti-spoofing at the network edge — ISPs and network operators filtering packets with spoofed source addresses reduces the effectiveness of amplification and reflection attacks industry-wide (relevant context even though it’s mostly enforced upstream, not by the application owner).
A DDoS response plan (part of incident response) should define: who declares an incident, which mitigation layer engages automatically (CDN/WAF rules) vs. requires a human decision (contacting an upstream scrubbing provider), and how to communicate status during the event.
Zero Trust Architecture (NIST SP 800-207)
Zero Trust flips the traditional network security model. Traditional “castle-and-moat” perimeter security assumes that anything inside the network boundary is relatively trustworthy — once a device or user is on the internal network, it can typically reach a wide range of other resources with comparatively little additional friction. Zero Trust assumes the opposite: no user, device, or network location is trusted by default, no matter where the request originates from — every request must be authenticated, authorized, and encrypted, continuously, based on identity and context rather than network location. This is captured in the slogan “never trust, always verify.”
Core principles from NIST SP 800-207:
- All data sources and computing services are considered resources — every resource requires access control, without exception for being “internal.”
- All communication is secured regardless of network location — being on the corporate LAN grants no implicit trust; traffic is encrypted and authenticated the same whether it originates internally or externally.
- Access to individual resources is granted per-session — trust is evaluated and granted for a single session/request, not persistently for a device or user once authenticated.
- Access is determined by dynamic policy — evaluated based on identity, device posture/health, behavioral attributes, and environmental context (time, location, threat intelligence), not just a static role.
- The enterprise monitors and measures the integrity and security posture of all owned and associated assets — device health/patch status feeds into access decisions.
- All resource authentication and authorization are dynamic and strictly enforced before access is allowed — continuous re-evaluation, not “authenticate once, trust forever.”
- The enterprise collects as much information as possible about the current state of assets, network infrastructure, and communications and uses it to improve its security posture — logging and telemetry feed back into policy.
Architectural components (NIST 800-207 model):
- Policy Engine (PE) — the decision-making component; evaluates a request against policy and outside signals (threat intelligence, identity provider data, device posture) and produces an allow/deny decision.
- Policy Administrator (PA) — executes the PE’s decision by establishing or terminating the communication path (e.g., issuing a short-lived credential/token, configuring the PEP).
- Policy Enforcement Point (PEP) — the component that actually gates the connection based on the PA’s instruction (a gateway, proxy, sidecar, or agent sitting in front of the resource). This is the practical, everyday piece a DevSecOps engineer configures — every service, in effect, gets its own tiny perimeter.
Together, PE + PA are often referred to as the Policy Decision Point (PDP) as a pair, contrasted with the PEP that sits closer to the resource.
Key mechanisms that implement Zero Trust in practice:
- Identity-centric access — access decisions are anchored on strongly authenticated identity (user and/or workload/service identity via mTLS certificates or SPIFFE/SPIRE), not source IP or network segment. This is why Zero Trust and IAM are inseparable — see Identity and Access Management for authentication, authorization, and least-privilege access design.
- Microsegmentation — enforcing per-workload policy (see above) so that even after authentication, a workload can only reach the specific dependencies it needs, nothing more.
- Device/endpoint posture checks — verifying the requesting device is managed, patched, and compliant before granting access, not just verifying the user’s credentials.
- ZTNA (Zero Trust Network Access) — replaces traditional VPN-based “connect to the network, then trust everything” remote access with per-application, identity-verified, brokered access (e.g., Google BeyondCorp, Cloudflare Access, Zscaler Private Access). The user never gets placed “on the network” at all; each application connection is individually authorized.
- Short-lived credentials and continuous verification — session tokens, service credentials, and certificates are short-lived and re-issued/re-verified frequently rather than trusted indefinitely after a single login.
Defense-in-depth applied to network design
Zero Trust does not replace firewalls, IDS/IPS, or segmentation — it is the organizing principle that ties them together with identity as the connective layer. A well-designed network applies all of these together, layered:
- Layer 1Edge / CDN / WAFPerimeter: NGFW/WAF, DDoS scrubbing, anycast
- Layer 2DMZpublic-facing services, reverse proxies
- Layer 3Internal core networkSegmentation: internal zones, VLANs/subnets, NACLs; reached through a policy enforcement point — extended ACL / stateful FW
- Layer 4Users and ServicesMicrosegmentation: per-workload NetworkPolicy / security groups / service-mesh mTLS
- Layer 5PEPper-service policy enforcement point — sidecar/gateway. Zero Trust identity layer: every request authenticated and authorized regardless of which zone it came from
- Layer 6ResourceDetection: IDS/IPS (NIDS at chokepoints, HIDS per host/container), centralized logging to SIEM
Each layer assumes the ones “outside” it can fail: the perimeter firewall might be misconfigured, a DMZ host might get compromised, an attacker might obtain valid-looking credentials — Zero Trust’s continuous, identity-based verification at every hop is what limits how far that single failure can propagate, and IDS/IPS plus centralized logging is what turns “we were breached” into “we detected it in minutes, not months.” This directly extends the defense-in-depth model from the DevSecOps Introduction into the network layer specifically.
Traditional perimeter security vs. Zero Trust
| Dimension | Traditional perimeter (“castle-and-moat”) | Zero Trust |
|---|---|---|
| Trust basis | Network location (inside = trusted, outside = untrusted) | Identity and context (user, device, workload) — location is not a trust signal |
| Perimeter | A single hardened boundary (firewall at the edge) | No single perimeter; every resource enforces its own boundary (PEP) |
| Internal traffic | Largely trusted once past the perimeter (flat internal network) | Authenticated and authorized on every request, encrypted in transit |
| Access granularity | Broad — VLAN/subnet-level access once connected | Fine-grained — per-resource, per-session, least-privilege |
| Remote access model | VPN — places the remote user “on the network” | ZTNA — brokers access to individual applications, user never joins the network |
| Lateral movement risk | High — compromise of one host often exposes many others | Low — microsegmentation and per-request auth limit reachable resources |
| Policy basis | Static rules (IP/subnet/port) | Dynamic policy (identity, device posture, behavior, risk signals) |
| Failure mode | Single point of failure — breach the perimeter, reach everything inside | Defense-in-depth by design — compromising one credential/session doesn’t grant broad access |
| Where enforced | Network edge devices | Distributed — every service/workload boundary |
Zero Trust does not mean “no network security” or “no firewalls” — segmentation, ACLs, IDS/IPS, and perimeter defenses are all still present; Zero Trust adds a mandatory identity-and-context check at every hop instead of relying on network position as an implicit trust signal. In practice, most organizations migrate to Zero Trust incrementally, layering identity-aware proxies and microsegmentation onto an existing segmented network rather than replacing it overnight.
Best Practices
- Default-deny everywhere — at the firewall/ACL level, the Kubernetes namespace level, and the Zero Trust policy level. Explicit allows only, for documented, necessary flows.
- Treat network policy as code — firewall rules, security groups, and
NetworkPolicymanifests belong in version control, go through pull request review, and are applied via CI/CD, not edited by hand in a console or on a device. - Segment by blast radius, not convenience — separate production from non-production, and isolate systems handling regulated/sensitive data, even if it means more zones to manage.
- Assume the perimeter will be breached — invest as much in internal segmentation, microsegmentation, and identity verification as in the edge firewall; a breach of one layer must not cascade.
- Prefer ZTNA over flat VPN access for remote/third-party access — broker access per-application rather than placing any remote party “inside the network.”
- Match IDS/IPS placement and mode to risk tolerance — use IPS (inline, blocking) only where false positives are well understood and tuned; start new detections in IDS (alert-only) mode and graduate to blocking once confidence is high.
- Instrument east-west traffic, not just north-south — deploy host/container-level detection (Falco, Wazuh, service mesh telemetry) since a perimeter NIDS cannot see traffic between internal services.
- Design and rehearse DDoS response before an attack, not during one — know which mitigations are automatic (CDN/WAF rules, rate limits) and which require a human decision, and test failover to scrubbing providers.
- Pair network controls with strong identity — network segmentation without strong authentication/authorization is incomplete Zero Trust; see Identity and Access Management for the identity side of this equation.
- Continuously test your controls — validate ACLs, segmentation boundaries, and Zero Trust policy enforcement with the tools and techniques covered in Security Testing Tools, not just at initial design time.
References
- NIST SP 800-207 — Zero Trust Architecture
- NIST SP 800-53 — Security and Privacy Controls for Information Systems and Organizations
- Cloudflare Learning Center — What is Zero Trust?
- Cloudflare Learning Center — What is a DDoS Attack?
- Cloudflare Learning Center — Firewall vs. IDS vs. IPS
- OWASP — Network Segmentation Cheat Sheet
- Kubernetes — Network Policies documentation
- Network Engineer — Network Security (device-level deep dive)