บทที่ 19 · Part 4 — Network Security
Network Architecture & Segmentation
Security zones, north-south/east-west, default-deny ingress/egress, firewall/WAF, microsegmentation, private connectivity และ privileged access
การวาง database ใน private subnet ลด direct Internet exposure แต่ถ้า application ทุก service, CI runner และ support host เข้าถึง database port ด้วย credential กว้าง compromise 1 จุดยังไปถึง ข้อมูลทั้งหมด Segmentation มีเป้าหมายลด reachability และ blast radius ไม่ใช่สร้าง “network ที่ไว้ใจได้”
Learning Outcomes
- แบ่ง security zone/plane ตาม trust, data และ privilege ได้
- แยก north-south กับ east-west controls ได้
- ออกแบบ default-deny ingress/egress โดยมี dependency inventory ได้
- แยกหน้าที่ firewall, WAF, proxy, gateway และ load balancer ได้
- ใช้ microsegmentation/private connectivity/privileged access โดยยังตรวจ identity/authorization ได้
Segment ตาม Trust และ Blast Radius
zone ควรสะท้อน:
- exposure: public, partner, internal, management
- data classification และ regulatory scope
- workload identity/privilege
- change/lifecycle owner
- failure/availability requirement
- monitoring/response capability
การแบ่งตามชื่อทีมอย่างเดียวทำให้ service ที่ trust ต่างกันอยู่ zone เดียว
แยก Planes ที่มีผลต่างกัน
- Data plane ประมวลผล customer/business traffic
- Control plane เปลี่ยน configuration/deployment/policy
- Management plane privileged human operation
- Observability plane รับ log/metric/trace และอาจเห็นข้อมูลละเอียด
control/management compromise มักมี blast radius สูงกว่า 1 API request จึงต้องแยก path/identity
North-South และ East-West
| Direction | Traffic | Controls |
|---|---|---|
| North-south | เข้า/ออก boundary เช่น Internet/partner | CDN, DDoS, WAF, gateway, egress proxy/firewall |
| East-west | ระหว่าง workload/data ภายใน | service identity, microsegmentation, network policy, mTLS |
การป้องกัน edge อย่างเดียวไม่หยุด compromised workload เคลื่อน lateral ภายใน และการเปิด east-west ทุก port ทำให้ account/service compromise ขยายวงง่าย
Default-Deny Ingress
อนุญาตจาก source identity/zone → destination service → protocol/port ที่จำเป็น:
ALLOW public-edge -> transfer-api : TLS/443
ALLOW transfer-api -> ledger-db : TLS/5432
DENY all other paths
อย่าใช้ CIDR กว้างแทน workload identity เมื่อ platform รองรับ identity-based policy และอย่าลืม:
- health check/source ranges
- failover/secondary region/path
- service discovery/DNS
- monitoring/response access
- migration/job/backup ที่มี lifecycle ชัด
rule ต้องมี owner, purpose, expiry/review และ telemetry ว่าใช้จริงหรือไม่
Egress Control สำคัญเท่า Ingress
compromised workload ต้องส่งข้อมูลหรือเรียก control plane ออกไป Egress design ควร inventory:
- external API/partner destinations
- DNS, NTP/time, certificate/OCSP ตาม ecosystem
- package/update/registry
- telemetry/logging
- cloud service/control plane endpoints
- backup/replication
control หลายชั้น:
- route/NAT/firewall/proxy
- DNS resolver/policy/log
- destination/domain/IP policy พร้อมข้อจำกัด
- VPC/private endpoints และ endpoint policy
- workload identity/credential scope
- response/redirect/size validation ที่ application
domain allowlist อย่างเดียวมี DNS/redirect/compromised-provider risk และ dynamic SaaS endpoints ต้องมี change/exception process
Default-Deny ที่ไม่มี Dependency Inventory สร้าง Outage
rollout แบบ observe → alert → limited enforce → expand พร้อม owner/runbook ดีกว่าเปิด deny ทั่วระบบ
แล้วแก้ด้วย 0.0.0.0/0 ถาวรเมื่อ service ล่ม
Firewall, WAF, Proxy และ Gateway ต่างกัน
| Component | เห็น/ทำได้ | ไม่เข้าใจโดยตัวมันเอง |
|---|---|---|
| Network firewall | IP/protocol/port/state และบาง deep inspection | user/account/business object |
| WAF | HTTP request pattern/rule/bot signal | transaction invariant/authorization ทั้งหมด |
| Reverse proxy/LB | TLS termination, routing, header policy, load distribution | business permission |
| API gateway | auth integration, route, quota, schema บางส่วน | downstream object/state invariant |
| Egress proxy | destination/protocol/logging | intent ของ compromised process เสมอไป |
วาง control ใกล้ invariant และใช้ edge control ลด noise/load ไม่ยก WAF เป็นตัวแก้ code/design flaw
DMZ ไม่ใช่ Trusted Middle
DMZ/edge zone มี exposure สูง จึงควรมี privilege ต่ำและ path จำกัด:
- ไม่ถือ data/key ที่ไม่จำเป็น
- origin รับเฉพาะ edge identity/path
- edge compromise ไป data zone โดยตรงไม่ได้
- configuration/artifact signed/controlled
- log/telemetry ออกทาง restricted path
- admin access แยกจาก public listener
การ terminate TLS ที่ DMZ ต้องป้องกัน hop ต่อและ forwarded identity headers
Microsegmentation
แบ่ง east-west policy ต่อ workload/service มากกว่า subnet ใหญ่:
- default deny ต่อ namespace/service identity
- allow caller→callee operation/path ตาม capability
- mTLS/workload identity สำหรับ peer
- policy version + deployment coordination
- telemetry deny/allow และ staged rollout
network policy ลด reachable sockets ส่วน application auth บังคับ action/resource ทั้งคู่จำเป็น service mesh อาจช่วย identity/mTLS/policy แต่เพิ่ม control-plane/certificate/config complexity
VPN และ Private Connectivity
VPN, peering, private link หรือ leased connection ลด public path แต่ไม่ได้ทำ peer/device/account trusted:
- authenticate user/workload/device ต่อ resource
- restrict route/prefix/service ไม่ advertise ทั้ง network โดยไม่จำเป็น
- resolve overlapping CIDR/DNS และ transitive route
- inspect/log ตาม data policy
- revoke partner/vendor access และ test expiry
- application authorization ยังทำงาน
partner connection ควรเข้า partner ingress zone ไม่ route ตรงสู่ data plane
Privileged Access ไม่ควรพึ่ง Bastion อย่างเดียว
เป้าหมายคือ short-lived, identity-aware, audited access โดยลด inbound path:
- federation + phishing-resistant MFA
- just-in-time role/session
- managed session/remote command ที่ไม่เปิด SSH/RDP เมื่อทำได้
- source/device posture ตาม policy
- command/session audit ที่ป้องกัน tamper
- no shared account/key
- break-glass แยก, alert และ post-review
bastion ที่มี standing key และ route ทุก subnet กลายเป็น high-value pivot ต้อง harden/patch/isolate และไม่เก็บ customer data
Admin Portal Boundary
admin portal ไม่ควรเป็น public app ที่เพิ่ม role check เพียงชั้นเดียว พิจารณา:
- separate origin/ingress และ workforce identity
- managed device/identity-aware access
- function/property authorization + maker-checker
- no direct database query สำหรับ routine action
- session recording/audit ตาม privacy policy
- bulk export/impersonation controls
- emergency availability path ที่ซ้อมแล้ว
Data Zone
database/object store/secret/KMS endpoint ต้องรับจาก workload identity/path ที่จำเป็น:
- แยก read/write/admin/migration/backup role
- application ใช้ least-privilege schema/API
- DB admin path แยก routine service path
- encrypt channel และ verify peer
- query/audit/backup access มี owner
- data exfiltration path รวม snapshot/export/replica
private address ไม่ป้องกัน IAM/control-plane API ที่สร้าง snapshot หรือแก้ policy
Availability และ Choke Points
firewall/proxy/gateway ที่เป็น control อาจเป็น single point/bottleneck:
- multi-zone/instance และ capacity plan
- symmetric routing/state behavior
- health check/failover ที่ไม่ bypass policy
- config rollout/rollback
- dependency timeout/degraded mode
- bypass prevention และ emergency change audit
test failure ไม่ใช่เพียง happy-path connectivity
Review Checklist
- zone/plane แบ่งตาม trust/data/privilege/blast radius ไม่ใช่ชื่อทีม
- public, partner, admin, CI/CD, observability และ data paths แยกชัด
- ingress allow ระบุ source-destination-protocol-purpose-owner
- egress inventory รวม DNS/time/update/telemetry/cloud/partner
- WAF/firewall/gateway ไม่ถูกใช้แทน application authorization
- east-west มี workload identity + microsegmentation ตาม risk
- VPN/private connection ยังตรวจ identity/device/resource
- privileged access short-lived/audited/no shared key และ break-glass ถูกทดสอบ
- data zone ครอบคลุม snapshot/export/control-plane paths
- choke points มี capacity/HA/failure/bypass tests
สรุป
Segmentation ลด reachability และ blast radius แต่ไม่สร้าง trusted network Architecture ที่ดีแยก data/control/admin planes, บังคับ ingress/egress และใช้ identity/authorization ทุก boundary พร้อมออกแบบ availability ของ control เอง