Ngân hàng đề — AWS Certified Security Specialty
Tìm thấy 445 câu.
Which actions should the company take to secure the images to limit their distribution? (Choose two.)
- A Update the S3 bucket policy to restrict access to a CloudFront origin access control (OAC).
- B Update the website DNS record to use an Amazon Route 53 geolocation record deny list of countries where the company lacks a license.
- C Add a CloudFront geo restriction deny list of countries where the company lacks a license.
- D Update the S3 bucket policy with a deny list of countries where the company lacks a license.
- E Enable the Restrict Viewer Access option in CloudFront to create a deny list of countries where the company lacks a license.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào việc bảo mật hình ảnh lưu trữ trên Amazon S3 và được phân phối qua Amazon CloudFront cho người dùng cuối. 🛡️️ Công ty phát hiện hình ảnh bị truy cập từ các quốc gia mà họ không có giấy phép phân phối (distribution license). Nhiệm vụ là chọn hai hành động để hạn chế phân phối, đảm bảo chỉ người dùng hợp pháp mới truy cập được.
Vấn đề chính:
- S3 là nguồn gốc (origin), CloudFront là CDN để cache và phân phối nhanh.
- Cần chặn truy cập địa lý (geo-restriction) và bảo vệ S3 khỏi truy cập trực tiếp. 📘 Kiến thức cập nhật đến 2026: AWS khuyến nghị sử dụng Origin Access Control (OAC) thay thế OAI cũ (từ 2022), và CloudFront hỗ trợ Geo Restriction với whitelist/denylist quốc gia/tiểu lục địa.
✅ Đáp án đúng (Chọn TWO)
Hai lựa chọn đúng là:
-
Update the S3 bucket policy to restrict access to a CloudFront origin access control (OAC).
Lý do: OAC đảm bảo chỉ CloudFront mới truy cập được S3, ngăn chặn truy cập trực tiếp từ internet hoặc các nguồn khác. Bucket policy sẽ deny tất cả trừ OAC của distribution cụ thể. 🛡️️ Đây là best practice bảo mật origin. -
Add a CloudFront geo restriction deny list of countries where the company lacks a license.
Lý do: CloudFront hỗ trợ Geo Restriction để chặn (deny) hoặc chỉ cho phép (allow) truy cập từ các quốc gia cụ thể. Deny list sẽ block request từ IP của các quốc gia không có license, ngay tại edge location. ⚡ Hiệu quả cao, không ảnh hưởng S3.
📋 Giải thích chi tiết tất cả các phương án
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh, kèm lý do đúng/sai bằng tiếng Việt:
-
Update the S3 bucket policy to restrict access to a CloudFront origin access control (OAC).
✅ ĐÚNG. Phương án này sử dụng OAC (tính năng mới nhất của CloudFront từ 2022, cập nhật 2026 vẫn là chuẩn) để tạo trust relationship giữa CloudFront và S3. Bucket policy chỉ cho phép CloudFront service principal truy cập, deny tất cả public access. Điều này ngăn hotlinking trực tiếp vào S3, buộc mọi request phải qua CloudFront. 🛠️ Best practice theo AWS Well-Architected Framework (Security Pillar). -
Update the website DNS record to use an Amazon Route 53 geolocation record deny list of countries where the company lacks a license.
❌ SAI. Route 53 geolocation routing dùng để chuyển hướng traffic dựa trên vị trí (ví dụ: route đến endpoint khác), không phải để chặn/deny access. Nó không block request mà chỉ resolve DNS khác nhau, không giải quyết được vấn đề truy cập hình ảnh qua CloudFront trực tiếp. 🚫 Không liên quan đến S3/CloudFront security. -
Add a CloudFront geo restriction deny list of countries where the company lacks a license.
✅ ĐÚNG. CloudFront có tính năng Geo Restriction (trong Distribution Settings > Geo Restriction) cho phép thêm deny list quốc gia/tiểu lục địa. CloudFront sẽ return 403 Forbidden cho request từ IP thuộc các quốc gia đó, ngay tại edge. 🎯 Hiệu suất cao, scale global, phù hợp chính xác với yêu cầu limit distribution theo license. -
Update the S3 bucket policy with a deny list of countries where the company lacks a license.
❌ SAI. S3 bucket policy không hỗ trợ deny theo quốc gia trực tiếp (chỉ theo IP ranges, AWS account, VPC, v.v.). Để deny theo country, cần map IP ranges thủ công (khó khăn, không chính xác vì IP động), và không scale tốt. AWS không khuyến nghị vì CloudFront mới là layer xử lý geo. 🔒 Sai lầm phổ biến, dễ bypass qua proxy/VPN. -
Enable the Restrict Viewer Access option in CloudFront to create a deny list of countries where the company lacks a license.
❌ SAI. Restrict Viewer Access (trong Behaviors) dùng cho signed URLs/cookies để kiểm soát thời gian/access key, không liên quan đến geo-restriction. Nó yêu cầu client cung cấp signature hợp lệ, không chặn theo quốc gia. 📵 Nhầm lẫn với Signed URL feature, không giải quyết vấn đề license địa lý.
📘 Tài liệu tham khảo (AWS cập nhật mới nhất 2026)
- CloudFront Geo Restriction: AWS Docs - Restrict geographic distributions 🗺️
- Origin Access Control (OAC): AWS Docs - Restrict access to S3 using OAC 🔐
- S3 Bucket Policy Best Practices: AWS Well-Architected - Security Pillar
- Exam Prep: AWS Certified DevOps Engineer Professional DOP-C02 guide nhấn mạnh combo OAC + Geo Restriction cho CDN security.
Hy vọng phân tích giúp bạn ôn thi hiệu quả! 🚀 Nếu cần ví dụ code policy, hãy hỏi thêm.
A security engineer verified that the associated security groups and network ACLs are allowing the required ports in the inbound direction. However, the vendors cannot connect to the application.
Which solution will provide the vendors access to the application?
- A Modify the security group that is associated with the EC2 instances to have the same outbound rules as inbound rules.
- B Modify the network ACL that is associated with the CIDR range to allow outbound traffic to ephemeral ports.
- C Modify the inbound rules on the internet gateway to allow the required ports.
- D Modify the network ACL that is associated with the CIDR range to have the same outbound rules as inbound rules.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi mô tả một tình huống thực tế trong AWS VPC:
- Công ty đã triển khai các máy chủ EC2 trong VPC, và các nhà cung cấp bên ngoài (vendors) truy cập chúng qua internet.
- Gần đây, họ deploy ứng dụng mới trên các instance EC2 trong một dải CIDR mới (tức là subnet mới với CIDR block khác).
- Kỹ sư bảo mật đã kiểm tra và xác nhận security groups và network ACLs (NACLs) đều cho phép các port inbound cần thiết.
- Vấn đề: Vendors không thể kết nối đến ứng dụng mới này, dù inbound rules đã OK.
🛠️ Nguyên nhân cốt lõi:
- Security Groups (SG) là stateful (tự động cho phép return traffic outbound).
- Network ACLs (NACL) là stateless (phải explicit cho phép cả inbound VÀ outbound).
- Khi vendors (client) kết nối từ internet đến EC2 (server), EC2 cần reply back qua ephemeral ports (cảng tạm thời, thường 1024-65535).
- Subnet mới (CIDR mới) có NACL chưa cho phép outbound traffic đến ephemeral ports, dẫn đến return traffic bị block.
(Kiến thức cập nhật AWS 2023-2026: VPC vẫn giữ nguyên behavior stateless của NACL, ephemeral ports mặc định 1024-65535 theo RFC).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Modify the network ACL that is associated with the CIDR range to allow outbound traffic to ephemeral ports.
Lý do:
- NACL liên kết với subnet (CIDR range mới) là stateless, nên phải explicit allow outbound từ EC2 (source: subnet CIDR) đến ephemeral ports (destination: 1024-65535 hoặc 0/0) để return traffic từ server về client qua internet.
- Inbound đã OK (theo mô tả), chỉ thiếu outbound ephemeral → Giải quyết chính xác vấn đề mà không ảnh hưởng SG hoặc IGW.
- Đây là best practice cho troubleshooting VPC connectivity (AWS Well-Architected Framework: Networking pillar).
📋 Phân tích tất cả các phương án (đúng/sai)
-
❌ SAI: Modify the security group that is associated with the EC2 instances to have the same outbound rules as inbound rules.
Giải thích: Security Groups đã stateful tự động cho phép return traffic (outbound ephemeral) khi inbound được allow. Không cần modify outbound rules (SG outbound mặc định cho phép tất cả). Vấn đề nằm ở NACL, không phải SG → Thay đổi này thừa và không giải quyết. -
✅ ĐÚNG: Modify the network ACL that is associated with the CIDR range to allow outbound traffic to ephemeral ports.
Giải thích: Như trên, NACL của subnet mới (CIDR range) thiếu rule outbound cho ephemeral ports (ví dụ: Outbound: Allow TCP/UDP 1024-65535 từ subnet CIDR đến 0/0). Đây là nguyên nhân chính vì NACL block return traffic → Modify chính xác và hiệu quả nhất. -
❌ SAI: Modify the inbound rules on the internet gateway to allow the required ports.
Giải thích: Internet Gateway (IGW) không có rules inbound/outbound như NACL hay SG; nó chỉ route traffic giữa internet và VPC (route table phải có 0.0.0.0/0 → igw-id). Không tồn tại "inbound rules on IGW" → Phương án sai về kiến trúc AWS. -
❌ SAI: Modify the network ACL that is associated with the CIDR range to have the same outbound rules as inbound rules.
Giải thích: Copy inbound rules (ví dụ: port 80/443) sang outbound sẽ không đủ, vì return traffic dùng ephemeral ports (không phải port server). Phải allow cụ thể ephemeral ports outbound → Phương án này không chính xác, có thể vẫn block traffic.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS VPC User Guide: "Network ACLs" → https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html (stateless behavior & ephemeral ports).
- Troubleshoot VPC Connectivity: https://docs.aws.amazon.com/vpc/latest/userguide/troubleshooting-security-groups-nacls.html.
- AWS Well-Architected Framework (Networking): https://docs.aws.amazon.com/wellarchitected/latest/networking-pillar/welcome.html (best practices NACL).
- Exam DOP-C02 Guide: Q&A về VPC troubleshooting (ephemeral ports là key point).
🛠️ Lời khuyên DevOps: Luôn kiểm tra NACL outbound ephemeral đầu tiên khi troubleshoot internet access! Sử dụng VPC Reachability Analyzer để verify.
After a recent security audit, the company decides to adopt a policy-as-code approach to improve the company's security posture on AWS. The company must prevent the deployment of any infrastructure that would violate a security policy, such as an unencrypted Amazon Elastic Block Store (Amazon EBS) volume.
Which solution will meet these requirements?
- A Turn on AWS Trusted Advisor. Configure security notifications as webhooks in the preferences section of the CI/CD pipeline.
- B Turn on AWS Config. Use the prebuilt rules or customized rules. Subscribe tile CI/CD pipeline to an Amazon Simple Notification Service (Amazon SNS) topic that receives notifications from AWS Config.
- C Create rule sets in AWS CloudFormation Guard. Run validation checks for CloudFormation templates as a phase of the CI/CD process.
- D Create rule sets as SCPs. Integrate the SCPs as a part of validation control in a phase of the CI/CD process.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào việc áp dụng policy-as-code trong môi trường AWS để nâng cao bảo mật, cụ thể là ngăn chặn việc triển khai (deploy) hạ tầng vi phạm chính sách bảo mật qua IaC (Infrastructure as Code) sử dụng AWS CloudFormation templates.
- Bối cảnh: Công ty đã có pipeline CI/CD sẵn để deploy templates CloudFormation. Sau cuộc kiểm toán bảo mật gần đây, họ muốn ngăn chặn trước (prevent) việc deploy bất kỳ hạ tầng nào vi phạm quy tắc, ví dụ như Amazon EBS volume không được mã hóa (unencrypted).
- Yêu cầu chính: Giải pháp phải tích hợp vào pipeline CI/CD, kiểm tra templates trước khi deploy (pre-deployment validation), sử dụng cách tiếp cận policy-as-code (viết quy tắc dưới dạng code để kiểm tra tự động).
- Mục tiêu: Đảm bảo tuân thủ bảo mật ngay từ giai đoạn phát triển/deploy, không chỉ giám sát sau khi triển khai.
Đây là tình huống thực tế trong DevOps trên AWS, nhấn mạnh vào việc kiểm soát IaC để tránh rủi ro bảo mật (security posture).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Create rule sets in AWS CloudFormation Guard. Run validation checks for CloudFormation templates as a phase of the CI/CD process.
Lý do 🛠️:
- AWS CloudFormation Guard (cfn-guard) là công cụ chính thức của AWS dành riêng cho policy-as-code trên CloudFormation templates. Nó cho phép tạo rule sets (bộ quy tắc) để kiểm tra templates trước khi deploy, ví dụ phát hiện EBS volume không encrypt.
- Tích hợp dễ dàng vào giai đoạn CI/CD (như một bước validation), nếu vi phạm thì pipeline fail ngay, ngăn chặn deploy hoàn toàn – chính xác đáp ứng yêu cầu "prevent the deployment".
- Đây là giải pháp native, lightweight, open-source (ra mắt 2021, cập nhật liên tục đến 2026 với hỗ trợ YAML/JSON rules mạnh mẽ hơn), phù hợp nhất cho IaC với CloudFormation. Không cần tài nguyên runtime, chạy local hoặc CI/CD tools như CodePipeline, GitHub Actions.
📋 Giải thích chi tiết tất cả các phương án
Dưới đây là phân tích từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Tôi đánh dấu ✅ cho đúng và ❌ cho sai, kèm giải thích rõ ràng dựa trên tính năng AWS mới nhất (2026).
-
Turn on AWS Trusted Advisor. Configure security notifications as webhooks in the preferences section of the CI/CD pipeline.
❌ Sai vì: AWS Trusted Advisor chỉ cung cấp kiểm tra và khuyến nghị sau khi deploy (post-deployment checks), không validate templates trước deploy. Webhooks chỉ gửi thông báo (notifications), không ngăn chặn pipeline. Không phải policy-as-code thực thụ, chỉ là monitoring thụ động. -
Turn on AWS Config. Use the prebuilt rules or customized rules. Subscribe tile CI/CD pipeline to an Amazon Simple Notification Service (Amazon SNS) topic that receives notifications from AWS Config.
❌ Sai vì: AWS Config ghi nhận và đánh giá cấu hình tài nguyên đã tồn tại (runtime compliance), không kiểm tra CloudFormation templates trước deploy. SNS chỉ gửi alert, không block pipeline. Dù có rules (prebuilt/custom), nó không prevent IaC violations từ gốc. -
Create rule sets in AWS CloudFormation Guard. Run validation checks for CloudFormation templates as a phase of the CI/CD process.
✅ Đúng vì: Như đã giải thích ở trên. cfn-guard chính là giải pháp policy-as-code dành riêng cho CloudFormation, validate templates syntax + rules (ví dụ:EBS.Encrypted == true), tích hợp trực tiếp vào CI/CD phase (fail-fast). Hỗ trợ đầy đủ đến 2026 với rule expressions nâng cao (logic operators, functions). -
Create rule sets as SCPs. Integrate the SCPs as a part of validation control in a phase of the CI/CD process.
❌ Sai vì: Service Control Policies (SCPs) trong AWS Organizations chỉ hạn chế API calls tại mức account/OU (runtime guardrails), không validate CloudFormation templates trước deploy. Không thể tích hợp trực tiếp vào CI/CD phase để check IaC code; SCPs không đọc/parse templates.
📘 Tài liệu tham khảo
- AWS CloudFormation Guard: Tài liệu chính thức AWS (cập nhật 2026: hỗ trợ rule v2.0 với advanced querying).
- CloudFormation Best Practices: AWS Well-Architected Framework - Security Pillar (nhấn mạnh IaC validation).
- DevOps trên AWS: AWS DevOps Guidance - Policy as Code (ví dụ tích hợp cfn-guard vào CodePipeline).
- Exam Prep DOP-C02: AWS Certified DevOps Engineer Professional (2024-2026 blueprint: Domain 3 - Automation & IaC Security).
Giải pháp này giúp công ty đạt zero-trust IaC! 🚀 Nếu cần ví dụ code rule cfn-guard, hãy hỏi thêm nhé!
A security engineer wants to use AWS Secrets Manager to rotate the DB instance credentials automatically. Because of a security policy, the security engineer cannot use the standard AWS Lambda function that Secrets Manager provides to rotate the credentials.
The security engineer deploys a custom Lambda function in the VPC. The custom Lambda function will be responsible for rotating the secret in Secrets Manager. The security engineer edits the DB instance's security group to allow connections from this function. When the function is invoked, the function cannot communicate with Secrets Manager to rotate the secret properly.
What should the security engineer do so that the function can rotate the secret?
- A Add an egress-only internet gateway to the VPC. Allow only the Lambda function's subnet to route traffic through the egress-only internet gateway.
- B Add a NAT gateway to the VPC. Configure only the Lambda function's subnet with a default route through the NAT gateway.
- C Configure a VPC peering connection to the default VPC for Secrets Manager. Configure the Lambda function's subnet to use the peering connection for routes.
- D Configure a Secrets Manager interface VPC endpoint. Include the Lambda function's private subnet during the configuration process.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi xoay quanh một tình huống bảo mật trên AWS:
Một công ty đang chạy Amazon RDS for MySQL trong VPC riêng biệt, và VPC này không được phép gửi/nhận traffic qua internet (tức là môi trường hoàn toàn private, không có public subnet hoặc NAT để ra ngoài).
Một security engineer muốn sử dụng AWS Secrets Manager để tự động rotate credentials của DB instance. Tuy nhiên, do security policy nghiêm ngặt, họ không thể dùng Lambda function mặc định mà Secrets Manager cung cấp. Thay vào đó, họ deploy một custom Lambda function ngay trong VPC này.
Họ đã edit security group của RDS để cho phép Lambda kết nối vào DB. Nhưng khi invoke Lambda, Lambda không thể giao tiếp với Secrets Manager để rotate secret (vì Secrets Manager là service public endpoint, yêu cầu kết nối qua internet hoặc private endpoint).
Vấn đề cốt lõi: Lambda chạy trong private subnet của VPC (không có internet access), cần cách kết nối privately với Secrets Manager mà không vi phạm policy không dùng internet.
Mục tiêu: Tìm giải pháp để Lambda rotate secret thành công. 🛠️
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng: Configure a Secrets Manager interface VPC endpoint. Include the Lambda function's private subnet during the configuration process.
Lý do:
- Interface VPC Endpoint (powered by AWS PrivateLink) cho phép kết nối privately từ VPC private subnet đến Secrets Manager mà không cần internet, NAT gateway hay public IP.
- Khi tạo endpoint, phải include private subnet của Lambda (thông qua route table và security group của endpoint). Lambda sẽ resolve DNS của Secrets Manager (com.amazonaws.[region].secretsmanager) qua endpoint private IP.
- Đây là giải pháp chuẩn AWS cho VPC isolated, hỗ trợ full rotation workflow (get secret, connect DB, update secret). Không vi phạm policy.
- Cập nhật 2026: VPC Endpoints cho Secrets Manager vẫn là interface type (không phải Gateway), hỗ trợ multi-subnet và policy-based access. ✅
📋 Giải thích tất cả các phương án (đúng/sai)
Dưới đây là phân tích từng lựa chọn giữ nguyên văn bản gốc bằng tiếng Anh, kèm giải thích chi tiết bằng tiếng Việt tại sao đúng/sai. Sử dụng kiến thức AWS mới nhất (2024-2026 re:Post & docs).
-
[SAI] Add an egress-only internet gateway to the VPC. Allow only the Lambda function's subnet to route traffic through the egress-only internet gateway.
❌ Sai vì: Egress-only IGW chỉ hỗ trợ IPv6 outbound traffic, không hỗ trợ IPv4 (mà Secrets Manager dùng IPv4). Nó không cho phép inbound và không giải quyết vấn đề kết nối đến AWS service public endpoints. VPC vẫn cần public route cho IPv4, vi phạm yêu cầu "no internet traffic". Không phù hợp rotate secret. -
[SAI] Add a NAT gateway to the VPC. Configure only the Lambda function's subnet with a default route through the NAT gateway.
❌ Sai vì: NAT Gateway yêu cầu public subnet với IGW và internet access để masquerade traffic ra ngoài. Điều này vi phạm policy "VPC must not send/receive traffic through the internet". Lambda có thể connect Secrets Manager qua NAT, nhưng tạo lỗ hổng bảo mật lớn và không private. -
[SAI] Configure a VPC peering connection to the default VPC for Secrets Manager. Configure the Lambda function's subnet to use the peering connection for routes.
❌ Sai vì: Secrets Manager không nằm trong default VPC (nó là managed service global). VPC peering chỉ connect 2 VPC AWS, không route đến service endpoints. Default VPC có internet, nên peering vẫn expose traffic ra ngoài gián tiếp. Không có route mặc định cho Secrets Manager qua peering. -
[ĐÚNG] Configure a Secrets Manager interface VPC endpoint. Include the Lambda function's private subnet during the configuration process.
✅ Đúng vì: Như giải thích ở trên. Endpoint tạo private DNS và IP trong subnet, Lambda resolve và connect trực tiếp qua AWS backbone network. Phải associate private subnet của Lambda để route table tự động update (0.0.0.0/0 -> pl-xxxx). Security group endpoint cho phép Lambda traffic (port 443). Hoàn hảo cho VPC isolated!
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS Docs: VPC Interface Endpoints for Secrets Manager – Hướng dẫn tạo endpoint và Lambda integration.
- AWS re:Post: Lambda in VPC access Secrets Manager – Case study chính xác tình huống này.
- Exam Topic DOP-C02: High-level design cho secure rotation in private VPC.
- Best Practice: Sử dụng endpoint policy để restrict actions (e.g., RotateSecret only).
Hy vọng phân tích này giúp bạn ôn thi DOP-C02 hiệu quả! 🚀 Nếu cần thêm ví dụ code Terraform/CloudFormation, hỏi nhé!
What steps should the security engineer take to check for known vulnerabilities and limit the attack surface? (Choose two.)
- A Use AWS Certificate Manager to encrypt all traffic between the client and application servers.
- B Review the application security groups to ensure that only the necessary ports are open.
- C Use Elastic Load Balancing to offload Secure Sockets Layer encryption.
- D Use Amazon Inspector to periodically scan the backend instances.
- E Use AWS Key Management Service (AWS KMS) to encrypt all the traffic between the client and application servers.
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi tập trung vào một kỹ sư bảo mật (security engineer) đang quản lý ứng dụng web ba tầng (three-tier web application) truyền thống chạy trên các instance Amazon EC2. Ứng dụng này đang bị tấn công ngày càng nhiều từ internet. Nhiệm vụ là chọn hai bước phù hợp nhất để kiểm tra các lỗ hổng bảo mật đã biết (known vulnerabilities) và giảm thiểu bề mặt tấn công (limit the attack surface).
🛠️ Chi tiết ngữ cảnh:
- Three-tier web app: Bao gồm presentation layer (web servers), application layer (app servers), và data layer (database), tất cả chạy trên EC2.
- Vấn đề chính: Tấn công từ internet nhắm vào ứng dụng, đòi hỏi:
- Kiểm tra lỗ hổng: Sử dụng công cụ tự động quét để phát hiện vulnerabilities.
- Giảm bề mặt tấn công: Hạn chế các điểm tiếp xúc không cần thiết, như đóng cổng thừa.
- Đây là câu hỏi kiểu "Choose two" (chọn 2 đáp án đúng), phù hợp với best practices bảo mật AWS, nhấn mạnh nguyên tắc "least privilege" và automated vulnerability scanning.
📘 Kiến thức cập nhật đến 2026: AWS khuyến nghị sử dụng Amazon Inspector (phiên bản mới nhất hỗ trợ EC2, ECS, Lambda với rules packages cập nhật CVE mới nhất) và Security Groups (tích hợp chặt chẽ với VPC, Network ACLs) để bảo vệ EC2 trước các mối đe dọa internet.
✅ Đáp án đúng (Chọn 2)
Hai đáp án đúng là:
- Review the application security groups to ensure that only the necessary ports are open.
- Use Amazon Inspector to periodically scan the backend instances.
Lý do lựa chọn:
- Những bước này trực tiếp giải quyết hai mục tiêu: Review Security Groups giảm bề mặt tấn công bằng cách chỉ mở port cần thiết (ví dụ: chỉ 80/443 cho web tier), tuân thủ AWS Well-Architected Framework (Security Pillar).
- Amazon Inspector quét tự động các lỗ hổng đã biết trên EC2 (như CVE, misconfigurations), với lịch trình định kỳ (periodic scan), giúp phát hiện và remediate nhanh chóng. Đây là giải pháp native AWS hiệu quả nhất cho EC2 mà không cần agent bên thứ ba.
🔍 Giải thích chi tiết từng phương án
Dưới đây là phân tích tất cả 5 phương án, giữ nguyên văn bản gốc bằng tiếng Anh. Mỗi phương án được đánh dấu ✅ (đúng) hoặc ❌ (sai), kèm giải thích rõ ràng bằng tiếng Việt:
-
❌ Use AWS Certificate Manager to encrypt all traffic between the client and application servers.
Phương án này sai vì AWS Certificate Manager (ACM) chỉ cung cấp và quản lý chứng chỉ SSL/TLS miễn phí, không trực tiếp mã hóa traffic. ACM dùng kết hợp với ELB, CloudFront hoặc API Gateway để enable HTTPS, nhưng không quét lỗ hổng hay giảm bề mặt tấn công. Encrypt traffic chỉ giúp bảo mật dữ liệu transit, không giải quyết vulnerabilities hoặc port mở thừa. -
✅ Review the application security groups to ensure that only the necessary ports are open.
Phương án đúng vì Security Groups hoạt động như stateful firewall ở instance-level. Review và chỉ mở port cần thiết (ví dụ: HTTP/HTTPS cho web tier, không mở SSH từ 0.0.0.0/0) trực tiếp giảm bề mặt tấn công từ internet, ngăn chặn reconnaissance và exploits. Đây là bước đầu tiên trong AWS security best practices. -
❌ Use Elastic Load Balancing to offload Secure Sockets Layer encryption.
Phương án sai vì Elastic Load Balancing (ELB/ALB/NLB) offload SSL giúp cải thiện performance (terminate SSL tại load balancer), nhưng không quét lỗ hổng hay giảm bề mặt tấn công gốc. ELB chỉ phân tải và có thể expose ports thêm nếu config sai, không thay thế Inspector hay Security Groups. -
✅ Use Amazon Inspector to periodically scan the backend instances.
Phương án đúng vì Amazon Inspector là dịch vụ vulnerability management native AWS, quét EC2 instances định kỳ (periodic) để phát hiện known vulnerabilities (CVE, network reachability, host config). Kết quả gửi qua SNS/EventBridge, hỗ trợ automation remediate – lý tưởng cho backend instances trong three-tier app. -
❌ Use AWS Key Management Service (AWS KMS) to encrypt all the traffic between the client and application servers.
Phương án sai vì AWS KMS quản lý encryption keys cho data at rest (EBS, S3) hoặc in-transit (qua SDK), không encrypt traffic trực tiếp từ client đến app servers. KMS không thay thế TLS/SSL (cần ACM + ELB), và không liên quan đến quét lỗ hổng hay port security.
📘 Tài liệu tham khảo (Cập nhật 2026)
- Amazon Inspector: AWS Inspector User Guide – Hỗ trợ EC2 scanning với Network Reachability rules (mới 2024+).
- Security Groups: Amazon VPC Security Groups – Best practices trong Well-Architected Framework: Security Pillar.
- AWS Exam Prep: AWS Certified Security - Specialty Exam Guide (2025 update), đề cập trực tiếp các giải pháp này cho EC2 protection.
Hy vọng phân tích này giúp bạn ôn thi hiệu quả! 🚀 Nếu cần thêm ví dụ config, hãy hỏi nhé!
Which solution will meet these requirements with the LEAST management overhead?
- A Pull images from the public container registry. Publish the images to Amazon Elastic Container Registry (Amazon ECR) repositories with scan on push configured in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use identity-based policies to restrict access to which IAM principals can access the images.
- B Pull images from the public container registry. Publish the images to a private container registry that is hosted on Amazon EC2 instances in a centralized AWS account. Deploy host-based container scanning tools to EC2 instances that run Amazon ECS. Restrict access to the container images by using basic authentication over HTTPS.
- C Pull images from the public container registry. Publish the images to Amazon Elastic Container Registry (Amazon ECR) repositories with scan on push configured in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use repository policies and identity-based policies to restrict access to which IAM principals and accounts can access the images.
- D Pull images from the public container registry. Publish the images to AWS CodeArtifact repositories in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use repository policies and identity-based policies to restrict access to which IAM principals and accounts can access the images.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc bảo mật và quản lý container images trong môi trường Amazon ECS trên AWS. Cụ thể:
- Công ty đang chạy ứng dụng container trên ECS.
- Yêu cầu chính:
- Đảm bảo container images không chứa lỗ hổng bảo mật nghiêm trọng (vulnerabilities).
- Chỉ cho phép truy cập từ IAM roles và AWS accounts cụ thể (cross-account và identity-based access control).
- Mục tiêu: Giải pháp với LEAST management overhead (ít công quản lý nhất), nghĩa là ưu tiên dịch vụ managed của AWS để tự động hóa, tránh tự quản lý hạ tầng.
Đây là chủ đề DevSecOps trong AWS, sử dụng Amazon ECR (Elastic Container Registry) làm registry chính cho containers, với tính năng scan on push để tự động quét vulnerabilities (hỗ trợ từ năm 2020 và cập nhật liên tục đến 2026 với image scanning nâng cao, bao gồm Amazon Inspector integration). Kiến thức cập nhật: ECR hỗ trợ repository policies cho cross-account access và identity-based policies cho IAM principals. 🛡️
✅ Đáp án đúng
Phương án ĐÚNG: Pull images from the public container registry. Publish the images to Amazon Elastic Container Registry (Amazon ECR) repositories with scan on push configured in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use repository policies and identity-based policies to restrict access to which IAM principals and accounts can access the images.
Lý do lựa chọn:
- Scan on push trong ECR tự động quét vulnerabilities (high/medium/critical) khi push image, tích hợp Amazon ECR Image Scanning (enhanced mode từ 2023), đảm bảo không có severe vulnerabilities mà không cần tool bên ngoài. 📊
- Centralized ECR account + CI/CD pipeline (như CodePipeline) để deploy cross-account với ít overhead.
- Repository policies (ECR resource policies) kiểm soát access từ specific AWS accounts.
- Identity-based policies kiểm soát specific IAM roles/principals.
- Least overhead: ECR là fully managed, không cần quản lý server, tự động scale, integrate native với ECS. Hoàn hảo cho multi-account strategy (AWS Organizations). 🚀
📋 Giải thích tất cả các phương án
Dưới đây là phân tích từng phương án một, giữ nguyên văn bản gốc tiếng Anh. Mỗi phương án được đánh giá đúng/sai với lý do chi tiết dựa trên best practices AWS DevOps (cập nhật 2026).
-
❌ Phương án SAI 1: Pull images from the public container registry. Publish the images to Amazon Elastic Container Registry (Amazon ECR) repositories with scan on push configured in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use identity-based policies to restrict access to which IAM principals can access the images.
- Lý do sai: Tương tự đáp án đúng nhưng chỉ dùng identity-based policies (IAM policies), thiếu repository policies (resource policies trên ECR repo). Identity-based chỉ kiểm soát principals trong cùng account, không đủ cho cross-account access (specific AWS accounts). Phải dùng cả hai để meet yêu cầu đầy đủ, nếu không sẽ cần thêm delegation phức tạp (nhiều overhead hơn). 🛑
-
❌ Phương án SAI 2: Pull images from the public container registry. Publish the images to a private container registry that is hosted on Amazon EC2 instances in a centralized AWS account. Deploy host-based container scanning tools to EC patching instances that run Amazon ECS. Restrict access to the container images by using basic authentication over HTTPS.
- Lý do sai: Self-hosted registry trên EC2 (như Docker Registry) yêu cầu quản lý thủ công EC2 (patching, scaling, HA), scanning bằng tool host-based (như Trivy/Clair) không tự động như ECR. Access control chỉ basic auth HTTPS kém bảo mật, không hỗ trợ IAM roles/accounts native. High overhead: Phải tự build/maintain infra, không managed, vi phạm "least management". 💥
-
✅ Phương án ĐÚNG: Pull images from the public container registry. Publish the images to Amazon Elastic Container Registry (Amazon ECR) repositories with scan on push configured in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use repository policies and identity-based policies to restrict access to which IAM principals and accounts can access the images.
- Lý do đúng: Như đã giải thích ở phần trên. Kết hợp ECR scanning tự động + dual policies (repo + identity) cho access control chính xác, cross-account seamless qua CI/CD. Fully managed, zero server management. 🌟
-
❌ Phương án SAI 4: Pull images from the public container registry. Publish the images to AWS CodeArtifact repositories in a centralized AWS account. Use a CI/CD pipeline to deploy the images to different AWS accounts. Use repository policies and identity-based policies to restrict access to which IAM principals and accounts can access the images.
- Lý do sai: CodeArtifact dành cho software packages (npm, Maven, NuGet, Python), KHÔNG hỗ trợ container images (Docker/OCI). Không có scanning vulnerabilities cho images, không integrate với ECS/ECR. Policies tồn tại nhưng vô dụng vì format sai. Phải dùng ECR cho containers (AWS khuyến cáo). 🚫
📘 Tài liệu tham khảo (AWS cập nhật mới nhất 2026)
- ECR Image Scanning: Amazon ECR Image Scanning (enhanced scanning với Inspector).
- ECR Policies: Repository Policies cho cross-account.
- Access Control: Identity-based vs Resource-based.
- Best Practices: AWS Well-Architected Framework - Security Pillar (DevOps Lens 2024+), khuyến nghị ECR cho ECS multi-account.
Giải pháp này align hoàn hảo với AWS Landing Zone và multi-account strategy! Nếu cần demo CDK/Terraform, hỏi thêm nhé. 🛠️
On average, the data scientists need 30 days to train models. The S3 bucket has been secured appropriately. The company's data retention policy states that all data that is older than 45 days must be removed from the S3 bucket.
Which action should a security engineer take to enforce this data retention policy?
- A Configure an S3 Lifecycle rule on the S3 bucket to delete objects after 45 days.
- B Create an AWS Lambda function to check the last-modified date of the S3 objects and delete objects that are older than 45 days. Create an S3 event notification to invoke the Lambda function for each PutObject operation.
- C Create an AWS Lambda function to check the last-modified date of the S3 objects and delete objects that are older than 45 days. Create an Amazon EventBridge rule to invoke the Lambda function each month.
- D Configure S3 Intelligent-Tiering on the S3 bucket to automatically transition objects to another storage class.
Xem giải thích
🧩 Giải thích nội dung câu hỏi
Câu hỏi tập trung vào việc thực thi chính sách lưu trữ dữ liệu (data retention policy) trên Amazon S3 bucket chứa dữ liệu nhạy cảm dùng cho huấn luyện mô hình AI/ML bằng Amazon SageMaker. Các nhà khoa học dữ liệu cần khoảng 30 ngày để huấn luyện mô hình, và bucket đã được bảo mật tốt. Chính sách yêu cầu xóa tất cả dữ liệu cũ hơn 45 ngày để tránh lưu trữ lâu dài dữ liệu nhạy cảm.
Vấn đề cốt lõi: Cần một giải pháp tự động, đáng tin cậy và hiệu quả để enforce việc xóa objects dựa trên ngày sửa đổi cuối cùng (last-modified date) sau đúng 45 ngày, mà không ảnh hưởng đến quá trình training (vẫn đủ thời gian 30 ngày + buffer). Đây là tình huống phổ biến trong DevOps/Security trên AWS, ưu tiên sử dụng các tính năng native của S3 để tránh phức tạp hóa với code tùy chỉnh. Kiến thức cập nhật đến 2026: AWS S3 Lifecycle rules vẫn là best practice cho retention policy, hỗ trợ xóa noncurrent versions và objects với granularity cao (từ 1 ngày trở lên).
✅ Đáp án đúng
Configure an S3 Lifecycle rule on the S3 bucket to delete objects after 45 days.
Lý do lựa chọn:
- Đây là giải pháp native, tự động và chính xác nhất của AWS S3. Lifecycle rule sẽ tự động xóa objects sau đúng 45 ngày kể từ last-modified date, không cần code tùy chỉnh, không tốn chi phí Lambda hay EventBridge, và scale vô hạn với mọi kích thước bucket.
- Hoàn hảo cho retention policy: Đảm bảo dữ liệu chỉ tồn tại tối đa 45 ngày (vừa đủ cho 30 ngày training + buffer), giảm rủi ro bảo mật dữ liệu nhạy cảm.
- Theo best practices AWS (Well-Architected Framework - Security Pillar), ưu tiên lifecycle rules cho compliance và cost optimization. ✅
📋 Phân tích tất cả các phương án
-
✅ Configure an S3 Lifecycle rule on the S3 bucket to delete objects after 45 days.
Giải thích đúng: Phương án này sử dụng tính năng S3 Lifecycle management để expire và xóa objects tự động sau 45 ngày (dựa trên CurrentVersion hoặc NoncurrentVersions). Không cần can thiệp thủ công, chạy ngầm hàng ngày bởi S3, chi phí gần như zero, và hỗ trợ MFA Delete/Versioning nếu cần. Đây là cách chuẩn AWS cho retention policy. 🛠️ Hoàn hảo! -
❌ Create an AWS Lambda function to check the last-modified date of the S3 objects and delete objects that are older than 45 days. Create an S3 event notification to invoke the Lambda function for each PutObject operation.
Giải thích sai: Trigger S3 event chỉ kích hoạt Lambda khi PutObject mới (upload/update), nên Lambda chỉ check object mới đó chứ không scan toàn bộ bucket để xóa objects cũ. Objects cũ hơn 45 ngày sẽ không bao giờ bị xóa nếu không có PutObject mới. Không enforce policy toàn diện, dễ miss dữ liệu, tốn chi phí invoke Lambda không cần thiết. 🧨 Không khả thi! -
❌ Create an AWS Lambda function to check the last-modified date of the S3 objects and delete objects that are older than 45 days. Create an Amazon EventBridge rule to invoke the Lambda function each month.
Giải thích sai: EventBridge chạy hàng tháng (không phải hàng ngày), nên việc xóa chỉ xảy ra muộn (có thể trễ 30 ngày) so với 45 ngày yêu cầu. Lambda phải scan toàn bộ bucket (dùng ListObjectsV2), rất tốn kém với dataset lớn (thời gian, chi phí API calls), và không chính xác realtime. Không scale tốt, vi phạm nguyên tắc "least privilege" và efficiency. ⏰ Không đáng tin cậy! -
❌ Configure S3 Intelligent-Tiering on the S3 bucket to automatically transition objects to another storage class.
Giải thích sai: S3 Intelligent-Tiering chỉ tối ưu chi phí bằng cách di chuyển objects giữa các tiers (Frequent/Sporadic/Archive) dựa trên access patterns, không xóa objects. Objects vẫn tồn tại vĩnh viễn trừ khi có lifecycle rule riêng. Không enforce retention policy (xóa sau 45 ngày), chỉ giúp giảm storage cost, không giải quyết vấn đề bảo mật dữ liệu cũ. 💰 Sai mục đích hoàn toàn!
📘 Tài liệu tham khảo
- AWS Documentation (cập nhật 2026): S3 Lifecycle Management – Chi tiết về "Expire current versions" sau 45 ngày.
- AWS Well-Architected Framework: Security Pillar – Recommend lifecycle rules for data retention (aws.amazon.com/architecture/well-architected).
- SageMaker Best Practices: Tích hợp S3 với lifecycle để quản lý training data (docs.aws.amazon.com/sagemaker/latest/dg/data-prep-shared.html).
Giải pháp này đảm bảo compliance, security và efficiency – đúng chuẩn DevOps Engineer Professional! 🚀
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::DOC-EXAMPLE-BUCKET",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:lambda:::function:MyLambdaFunction"
}
}
}
Which change should the security engineer make to the policy to ensure that the Lambda function can read the bucket objects?
-
A
Remove the Condition element. Change the Principal element to the following:
{ "AWS": "arn:aws:lambda:::function:MyLambdaFunction" }
-
B
Change the Action element to the following:
[ "s3:GetObject*", "s3:GetBucket*" ]
- C Change the Resource element to "arn:aws:s3:::DOC-EXAMPLE- BUCKET/*''.
-
D
Change the Resource element to "arn:aws:lambda:::function:MyLambdaFunction". Change the Principal element to the following:
{ "Service": "s3.amazonaws.com" }
Xem giải thích
🧩 Phân tích nội dung câu hỏi
Câu hỏi mô tả tình huống một kỹ sư bảo mật đang khắc phục sự cố cho hàm AWS Lambda có tên MyLambdaFunction. Hàm này gặp lỗi khi cố gắng đọc các đối tượng (objects) từ bucket Amazon S3 có tên DOC-EXAMPLE-BUCKET. Bucket policy hiện tại được cung cấp như sau:
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::DOC-EXAMPLE-BUCKET",
"Condition": {
"ArnLike": {
"aws:SourceArn": "arn:aws:lambda:::function:MyLambdaFunction"
}
}
}
Vấn đề chính: Bucket policy này nhằm cho phép dịch vụ Lambda (lambda.amazonaws.com) thực hiện hành động s3:GetObject trên bucket. Tuy nhiên, policy không hoạt động đúng vì:
- Resource chỉ định ARN của bucket (
arn:aws:s3:::DOC-EXAMPLE-BUCKET), nhưng hành độngs3:GetObjectyêu cầu ARN của các objects bên trong bucket (dạngarn:aws:s3:::bucket-name/*). - Condition sử dụng
aws:SourceArnvới định dạng sai (thiếu region và account ID, đúng phải làarn:aws:lambda:region:account-id:function:MyLambdaFunction).
Để hàm Lambda đọc được objects, cần sửa policy bucket để nó match đúng với request từ Lambda (kết hợp với IAM role của Lambda execution role phải có permission s3:GetObject). Câu hỏi yêu cầu thay đổi nào để đảm bảo Lambda có thể đọc objects từ bucket. (Kiến thức cập nhật AWS 2026: Bucket policy vẫn yêu cầu Resource chính xác cho actions object-level như GetObject, theo IAM/S3 best practices).
✅ Đáp án đúng
Change the Resource element to "arn:aws:s3:::DOC-EXAMPLE- BUCKET/*''.
Lý do lựa chọn:
- Hành động
s3:GetObjectlà object-level action, chỉ áp dụng cho các objects cụ thể trong bucket, không phải bucket root. Resource hiện tại chỉ là ARN bucket nên không match với request đọc objects (dẫn đến policy không apply, request bị deny mặc định). - Thay đổi Resource thành
arn:aws:s3:::DOC-EXAMPLE-BUCKET/*sẽ cho phép tất cả objects trong bucket, làm policy match đúng. - Lưu ý: Condition vẫn cần fix sau (thêm region/account), nhưng thay đổi này là bước cần thiết đầu tiên và trực tiếp giải quyết lỗi đọc objects. AWS khuyến nghị sử dụng
/*cho GetObject trong bucket policy (theo docs mới nhất 2026).
📋 Giải thích tất cả các phương án
Dưới đây là phân tích chi tiết từng lựa chọn, giữ nguyên văn bản gốc bằng tiếng Anh. Tôi đánh dấu ✅ đúng hoặc ❌ sai, kèm giải thích bằng tiếng Việt:
-
❌ [SAI] Remove the Condition element. Change the Principal element to the following:
{ "AWS": "arn:aws:lambda:::function:MyLambdaFunction" }Giải thích sai: Principal
AWSphải là ARN của IAM principal (như role/account), không phải ARN của Lambda function (function ARN không phải entity có credentials). Xóa Condition làm policy quá rộng (cho phép mọi Lambda service), vi phạm least privilege. Không giải quyết vấn đề Resource sai. -
❌ [SAI] Change the Action element to the following:
[ "s3:GetObject*", "s3:GetBucket*" ]Giải thích sai: Mở rộng Action không cần thiết và không fix vấn đề cốt lõi (Resource vẫn là bucket ARN, không match GetObject trên objects).
s3:GetBucket*là bucket-level (như ListBucket), thừa thãi cho việc đọc objects. Wildcard*có thể tăng rủi ro bảo mật không mong muốn. -
✅ [ĐÚNG] Change the Resource element to "arn:aws:s3:::DOC-EXAMPLE- BUCKET/*''. Giải thích đúng: Như phần đáp án trên, đây là thay đổi chính xác để Resource match với objects (
/*bao quát tất cả objects). Policy sẽ apply đúng chos3:GetObjecttừ Lambda service, giải quyết lỗi ngay lập tức (kết hợp fix Condition sau nếu cần). -
❌ [SAI] Change the Resource element to "arn:aws:lambda:::function:MyLambdaFunction". Change the Principal element to the following:
{ "Service": "s3.amazonaws.com" }Giải thích sai: Hoàn toàn đảo ngược logic! Resource phải là S3 resource (bucket/objects), không phải Lambda ARN. Principal
s3.amazonaws.comnghĩa là cho phép S3 service truy cập Lambda (vô nghĩa ở đây). Policy sẽ không bao giờ match request từ Lambda đọc S3.
🛠️ Khuyến nghị bổ sung
- Sau fix Resource, cập nhật Condition đầy đủ:
"aws:SourceArn": "arn:aws:lambda:us-east-1:123456789012:function:MyLambdaFunction"(thay region/account thực tế). - Đảm bảo Lambda execution role có IAM policy:
s3:GetObjecttrênarn:aws:s3:::DOC-EXAMPLE-BUCKET/*. - Test bằng AWS CLI:
aws lambda invoke --function-name MyLambdaFunction output.jsonvà check CloudWatch Logs.
📘 Tài liệu tham khảo (AWS cập nhật 2026)
- AWS S3 Bucket Policies – Ví dụ policy cho Lambda access.
- AWS Lambda Permissions Model – Resource ARN cho object actions.
- IAM Policy Elements: Resource – Xác nhận
/*cho GetObject. - S3 Condition Keys –
aws:SourceArnformat cho Lambda.
Which of the following is a possible reason that the IAM user cannot access the objects in the S3 bucket?
- A The IAM policy needs to allow the kms:DescribeKey permission.
- B The S3 bucket has been changed to use the AWS managed key to encrypt objects at rest.
- C An S3 bucket policy needs to be added to allow the IAM user to access the objects.
- D The KMS key policy has been edited to remove the ability for the AWS account to have full access to the key.
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào vấn đề Access Denied khi một IAM user cố gắng truy cập các object trong S3 bucket. Các yếu tố chính:
- IAM user và S3 bucket cùng thuộc một AWS account.
- Bucket sử dụng SSE-KMS (Server-Side Encryption with AWS KMS keys) với customer managed key (CMK) từ cùng account để mã hóa tất cả object tại rest.
- Không có bucket policy nào được định nghĩa.
- IAM policy của user đã cấp quyền: kms:Decrypt trên CMK, cùng s3:List* và s3:Get* cho bucket và objects.
Vấn đề: Dù IAM policy có vẻ đầy đủ cho S3 và KMS actions, user vẫn bị chặn. Lý do có thể là quyền truy cập KMS key bị hạn chế ở mức key policy, vì với SSE-KMS, việc decrypt object yêu cầu cả IAM policy VÀ KMS key policy phải cho phép. KMS key policy có quyền cao hơn và có thể override IAM policy. Đây là kiến thức cốt lõi trong AWS IAM và S3 encryption (cập nhật đến 2026, không thay đổi cơ bản từ các phiên bản trước).
🛠️ Đáp án đúng:
✅ The KMS key policy has been edited to remove the ability for the AWS account to have full access to the key.
Lý do chọn đáp án này:
Mặc định, CMK policy cho phép root account (và qua đó IAM users) full access (bao gồm kms:Decrypt). Nếu key policy bị chỉnh sửa để loại bỏ quyền full access cho account, IAM user sẽ không thể decrypt dù IAM policy có kms:Decrypt. Đây là nguyên nhân phổ biến nhất khớp với scenario (cùng account, no bucket policy, IAM perms OK). KMS key policy là "source of truth" cho permissions.
📋 Giải thích tất cả các phương án
-
❌ The IAM policy needs to allow the kms:DescribeKey permission.
Sai vì: kms:DescribeKey chỉ dùng để xem metadata của key (như ARN, policy), không bắt buộc cho kms:Decrypt khi truy cập S3 object. IAM policy đã có kms:Decrypt là đủ nếu key policy cho phép. Thêm DescribeKey không giải quyết Access Denied cho GetObject. -
❌ The S3 bucket has been changed to use the AWS managed key to encrypt objects at rest.
Sai vì: Nếu bucket chuyển sang AWS managed key (SSE-S3), sẽ không cần KMS permissions (kms:Decrypt), và user chỉ cần s3:GetObject là OK. Nhưng câu hỏi rõ ràng bucket vẫn dùng customer managed SSE-KMS, nên lỗi vẫn là KMS-related, không phải thay đổi encryption type. -
❌ An S3 bucket policy needs to be added to allow the IAM user to access the objects.
Sai vì: Với cùng AWS account và không có bucket policy (mặc định allow), IAM policy là đủ cho s3:GetObject/ListBucket. Bucket policy chỉ cần nếu cross-account hoặc explicit deny, nhưng ở đây không có deny nào được đề cập. -
✅ The KMS key policy has been edited to remove the ability for the AWS account to have full access to the key.
Đúng vì: KMS key policy kiểm soát ai có thể dùng key (principal). Nếu edit để remove quyền cho account root/IAM users, kms:Decrypt sẽ fail dù IAM policy cho phép. Đây là explicit deny từ key policy (cao hơn IAM policy). Troubleshooting tip: Kiểm tra key policy qua AWS Console/KMS API.
📘 Tài liệu tham khảo (cập nhật AWS 2026)
- AWS Docs: S3 Server-Side Encryption with KMS – Giải thích SSE-KMS yêu cầu IAM + Key Policy.
- AWS Docs: KMS Key Policies – "Key policies are the primary way to manage permissions on KMS keys."
- AWS Well-Architected Framework: Security Pillar – Troubleshooting IAM Access Denied với S3 + KMS.
- Exam Tip (DOP-C02): Luôn kiểm tra key policy trước khi blame IAM policy cho SSE-KMS issues.
Hy vọng phân tích này giúp bạn nắm vững! 🚀 Nếu cần thêm scenario thực hành, hỏi nhé!
Which S3 bucket policy will meet this requirement?
-
A
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "Bool": { "aws:SecureTransport": "true" } }, "Principal": "*" } ] }
-
B
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "Bool": { "aws:SecureTransport": "false" } }, "Principal": "*" } ] }
-
C
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption": "AES256" } }, "Principal": "*" } ] }
-
D
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption": "true" } }, "Principal": "*" } ] }
Xem giải thích
🧩 Phân tích chi tiết nội dung câu hỏi
Câu hỏi tập trung vào việc thực thi chính sách bảo mật cho Amazon S3 bucket theo yêu cầu của công ty: mã hóa tất cả dữ liệu trong quá trình truyền (encryption in transit). Điều này có nghĩa là tất cả các hoạt động S3 phải sử dụng kết nối an toàn như HTTPS/SSL/TLS, không cho phép HTTP không mã hóa.
Security engineer cần tạo S3 bucket policy với hiệu ứng Deny cho tất cả các hành động s3: (s3:*)* nếu dữ liệu không được mã hóa trong quá trình truyền.
- Resource: Áp dụng cho bucket
DOC-EXAMPLE-BUCKETvà các object bên trong (arn:aws:s3:::DOC-EXAMPLE-BUCKET/*). - Principal:
"*"(áp dụng cho tất cả người dùng). - Điều kiện (Condition): Phải kiểm tra secure transport (sử dụng
aws:SecureTransport), không phải mã hóa server-side (SSE). - Mục tiêu: Deny request nếu KHÔNG sử dụng HTTPS (tức là HTTP thuần).
Lưu ý quan trọng từ AWS (cập nhật đến 2026): aws:SecureTransport là biến điều kiện IAM policy kiểm tra xem request đến S3 có qua secure transport (HTTPS) không. Giá trị "true" = secure (HTTPS), "false" = không secure (HTTP). Bucket policy này là cách chuẩn để enforce HTTPS cho S3 (AWS khuyến nghị từ 2014 và vẫn áp dụng trong S3 Access Points, Intelligent-Tiering updates 2025-2026).
📘 Tài liệu tham khảo:
- AWS S3 Bucket Policy Examples - Enforce HTTPS (AWS Docs, cập nhật 2026).
- IAM Policy Elements: Condition - aws:SecureTransport (AWS IAM User Guide).
✅ Đáp án đúng và lý do lựa chọn
Đáp án đúng là phương án thứ 2 (policy với "aws:SecureTransport": "false").
Lý do:
- Policy này Deny tất cả
s3:*khi Conditionaws:SecureTransport: "false"(tức là khi request KHÔNG qua secure transport/HTTPS). - Hoàn toàn khớp yêu cầu encryption in transit (mã hóa dữ liệu đang truyền), vì S3 coi HTTP là không an toàn.
- Đây là best practice của AWS để enforce SSL/TLS, đảm bảo chỉ cho phép request qua HTTPS port 443.
- Hoạt động trên bucket và objects, Principal
"*"chặn tất cả.
🛠️ Giải thích chi tiết từng phương án
Dưới đây là phân tích từng lựa chọn, giữ nguyên code gốc bằng tiếng Anh. Tôi đánh dấu ✅ (đúng) hoặc ❌ (sai), kèm giải thích lý do đúng/sai dựa trên logic AWS S3 policy (cập nhật 2026).
-
Phương án 1 ❌ (SAI):
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "Bool": { "aws:SecureTransport": "true" } }, "Principal": "*" } ] }Lý do sai: Policy Deny khi
aws:SecureTransport: "true"(tức Deny các request AN TOÀN qua HTTPS). Điều này ngược lại hoàn toàn yêu cầu – nó chặn traffic mã hóa và cho phép HTTP không an toàn. Không enforce encryption in transit. -
Phương án 2 ✅ (ĐÚNG):
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "Bool": { "aws:SecureTransport": "false" } }, "Principal": "*" } ] }Lý do đúng: Như đã giải thích ở trên – Deny chính xác khi KHÔNG secure transport (
"false"), buộc tất cả request phải dùng HTTPS. Hoàn hảo cho encryption in transit. -
Phương án 3 ❌ (SAI):
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption": "AES256" } }, "Principal": "*" } ] }Lý do sai: Sử dụng
s3:x-amz-server-side-encryption: "AES256"(SSE-S3 với AES256) – đây là mã hóa server-side (at rest), KHÔNG phải in transit. Policy Deny nếu không chỉ định SSE, nhưng bỏ qua hoàn toàn HTTPS/encryption in transit. Không đáp ứng yêu cầu. -
Phương án 4 ❌ (SAI):
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowSSLRequestsOnly", "Action": "s3:*", "Effect": "Deny", "Resource": [ "arn:aws:s3:::DOC-EXAMPLE-BUCKET", "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*" ], "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption": "true" } }, "Principal": "*" } ] }Lý do sai: Tương tự phương án 3, kiểm tra SSE nhưng giá trị
"true"KHÔNG hợp lệ (S3 chỉ nhận"AES256","aws:kms", hoặc"NONE"). Policy sẽ không hoạt động đúng và vẫn không liên quan đến encryption in transit (chỉ at-rest).
Kết luận: Chỉ phương án 2 enforce đúng encryption in transit qua aws:SecureTransport. Trong thực tế DevOps, kết hợp policy này với CloudTrail để audit! 🚀