Trang chủ/Chương 13

Chương 13: Security & Encryption

Tổng Quan

Bảo mật chiếm 30% đề thi SAA (Domain 1). Chương này bao gồm mã hóa (encryption), quản lý khóa, và các dịch vụ bảo vệ ứng dụng.


1. AWS KMS (Key Management Service)

1.1 Đặc điểm

  • Quản lý encryption keys cho hầu hết dịch vụ AWS.
  • Tích hợp với: S3, EBS, RDS, Lambda, SQS, SSM...
  • Audit: Mọi lần sử dụng key được ghi trong CloudTrail.

1.2 Loại Keys

LoạiQuản lý bởiRotationUse case
AWS Owned KeysAWS (ẩn)Tự độngMặc định, miễn phí
AWS Managed KeysAWS (visible)Tự động (1 năm)aws/s3, aws/ebs
Customer Managed Keys (CMK)BạnTùy chọn (bật/tắt)Kiểm soát hoàn toàn, audit

1.3 Envelope Encryption

  • Data > 4KB → KMS không mã hóa trực tiếp.
  • KMS tạo Data Encryption Key (DEK) → DEK mã hóa data → KMS mã hóa DEK.
  • Kết quả: Encrypted data + Encrypted DEK lưu cùng nhau.

1.4 KMS Key Policy

  • Tương tự S3 Bucket Policy — kiểm soát ai truy cập key.
  • Mặc định: Root account có full access.
  • Custom: Chỉ định users/roles cụ thể.

1.5 KMS Multi-Region Keys

  • Replicate key sang Regions khác (cùng key ID/material).
  • Mã hóa ở Region A → Giải mã ở Region B (không cần cross-region API call).

2. AWS CloudHSM

  • Hardware Security Module - thiết bị phần cứng chuyên dụng cho mã hóa.
  • Bạn quản lý hoàn toàn keys (AWS không thể truy cập).
  • Use case: Compliance yêu cầu FIPS 140-2 Level 3, bạn cần toàn quyền kiểm soát keys.
KMSCloudHSM
Key managementAWS + CustomerChỉ Customer
HardwareMulti-tenantSingle-tenant (riêng bạn)
ComplianceFIPS 140-2 Level 2FIPS 140-2 Level 3

3. SSM Parameter Store vs Secrets Manager

Parameter StoreSecrets Manager
GiáFree tier (Standard)~$0.40/secret/tháng
Auto Rotation❌ (cần Lambda tự code)✅ Tích hợp sẵn (RDS, Redshift, DocumentDB)
Cross-account
Use caseConfig values, ít thay đổiDB passwords, API keys cần rotation

💡 Exam Tip: Đề nói "auto rotation for database credentials" → Secrets Manager.


4. AWS Certificate Manager (ACM)

  • Tạo và quản lý SSL/TLS certificates miễn phí.
  • Tự động renew certificates.
  • Tích hợp: ALB, CloudFront, API Gateway.
  • KHÔNG hỗ trợ EC2 (phải tự cài cert trên EC2).

5. AWS WAF & Shield

5.1 AWS WAF (Web Application Firewall)

  • Bảo vệ khỏi Layer 7 attacks (SQL injection, XSS, bad bots).
  • Đặt trên: ALB, API Gateway, CloudFront, AppSync.
  • Dùng Web ACL với rules để Allow/Block/Count requests.
  • Có thể block theo: IP, country, request rate, URL patterns.

5.2 AWS Shield

Shield StandardShield Advanced
GiáMiễn phí (tự động)$3,000/tháng
Bảo vệLayer 3/4 DDoSLayer 3/4/7 DDoS
Hỗ trợKhông24/7 DDoS Response Team
Cost protectionKhôngHoàn phí DDoS scaling costs

5.3 AWS Firewall Manager

  • Quản lý tập trung WAF rules, Shield, Security Groups cho nhiều accounts (Organizations).

6. Các Dịch Vụ Bảo Mật Khác

Dịch vụMô tả
Amazon GuardDutyPhát hiện threats bằng ML (DNS logs, VPC Flow Logs, CloudTrail). Không cần cài software.
Amazon InspectorScan vulnerabilities trên EC2 instances và container images (ECR).
Amazon MaciePhát hiện sensitive data (PII) trong S3 bằng ML.
AWS ConfigTheo dõi và đánh giá compliance của tài nguyên AWS. Lưu lịch sử config changes.

Exam Tips 💡

  1. KMS là lựa chọn mặc định cho encryption. CloudHSM khi cần FIPS 140-2 Level 3.
  2. Secrets Manager cho auto-rotation DB passwords. Parameter Store cho config đơn giản.
  3. ACM cho SSL certs trên ALB/CloudFront (miễn phí, auto-renew).
  4. WAF trên ALB/CloudFront để chặn SQL injection, XSS.
  5. Shield Standard = miễn phí DDoS protection. Advanced = $3K/tháng cho protection mạnh hơn.
  6. GuardDuty = threat detection. Inspector = vulnerability scanning. Macie = sensitive data in S3.

Câu Hỏi Ôn Tập 📝

Câu 1: Ứng dụng cần mã hóa data và bạn cần audit log mọi lần sử dụng encryption key. Dùng gì?

Xem đáp án

AWS KMS Customer Managed Key (CMK). Mọi API call đến KMS được ghi trong CloudTrail → audit log đầy đủ.

Câu 2: Database RDS cần password rotation tự động mỗi 30 ngày. Lưu password ở đâu?

Xem đáp án

AWS Secrets Manager. Hỗ trợ auto-rotation tích hợp sẵn cho RDS, Redshift, DocumentDB.

Câu 3: Website bị tấn công SQL injection qua API. Cách bảo vệ?

Xem đáp án

Triển khai AWS WAF trên ALB hoặc API Gateway với rules chặn SQL injection patterns.


⬅️ Chương 12: Decoupling & Messaging | Chương 14: Monitoring & Logging ➡️