考题解析 | 在 AWS 中使用 SSM 安全地管理目标实例


  题目

A company's security engineer is designing an isolation procedure for Amazon EC2 instances as part of an incident response plan. The security engineer needs to isolate a target instance to block any traffic to and from the target instance, except for traffic from the company's forensics team. Each of the company's EC2 instances has its own dedicated security group. The EC2 instances are deployed in subnets of a VPC. A subnet can contain multiple instances. The security engineer is testing the procedure for EC2 isolation and opens an SSH session to the target instance. The procedure starts to simulate access to the target instance by an attacker. The security engineer removes the existing security group rules and adds security group rules to give the forensics team access to the target instance on port 22. After these changes, the security engineer notices that the SSH connection is still active and usable. When the security engineer runs a ping command to the public IP address of the target instance, the ping command is blocked.
What should the security engineer do to isolate the target instance?
A. Add an inbound rule to the security group to allow traffic from 0.0.0.0/0 for all ports. Add an outbound rule to the security group to allow traffic to 0.0.0.0/0 for all ports. Then immediately delete these rules.
B. Remove the port 22 security group rule. Attach an instance role policy that allows AWS Systems Manager Session Manager connections so that the forensics team can access the target instance.
C. Create a network ACL that is associated with the target instance's subnet. Add a rule at the top of the inbound rule set to deny all traffic from 0.0.0.0/0. Add a rule at the top of the outbound rule set to deny all traffic to 0.0.0.0/0.
D. Create an AWS Systems Manager document that adds a host-level firewall rule to block all inbound traffic and outbound traffic. Run the document on the target instance.

  参考答案

B

  需求概括

一家公司的安全工程师正在为 Amazon EC2 实例设计隔离程序,作为事件响应计划的一部分。安全工程师需要隔离目标实例,以阻止除来自公司法证团队(forensics team)的流量之外,与目标实例之间的任何流量。公司每个 EC2 实例都有其自己的专用安全组。EC2 实例部署在 VPC 的子网中。一个子网可以包含多个实例。安全工程师正在测试 EC2 隔离程序,并打开到目标实例的 SSH 会话。程序开始模拟攻击者对目标实例的访问。安全工程师删除现有的安全组规则,并添加安全组规则以允许法证团队通过端口 22 访问目标实例。进行这些更改后,安全工程师注意到 SSH 连接仍然处于活动状态且可用。当安全工程师向目标实例的公共 IP 地址运行 ping 命令时,ping 命令被阻止。安全工程师应该怎么做来隔离目标实例?
安全工程师在设计 EC2 实例隔离程序时,在仅允许法证团队通过端口 22 访问目标实例后,现有的 SSH 连接仍然可用,需要找到正确的方法来隔离目标实例。

  技术分析

安全组:是虚拟防火墙,用于控制进出 EC2 实例的流量。安全组规则是有状态的,即允许返回流量自动,但如果规则被更改,现有的连接可能不会立即受到影响。
网络 ACL:是无状态的,作用于子网级别,可以用于更粗粒度的流量控制。
AWS Systems Manager Session Manager:允许在不打开入站端口的情况下安全地管理 EC2 实例。

  参考解析

技巧:排除明显错误选项,在没有明显错误的选项中选择最合理的选项。

A. 不正确。向安全组添加一条入站规则,允许来自 0.0.0.0/0 的所有端口的流量。向安全组添加一条出站规则,允许到 0.0.0.0/0 的所有端口的流量。然后立即删除这些规则。该方案只是短暂地允许所有流量,然后删除规则,并不能有效地隔离目标实例,现有的 SSH 连接可能仍然存在,不符合隔离要求。
B. 正确。删除端口 22 的安全组规则。附加一个允许 AWS Systems Manager Session Manager 连接的实例角色策略,以便法证团队可以访问目标实例。该方案通过删除端口 22 的安全组规则,阻止了通过该端口的常规访问。使用 AWS Systems Manager Session Manager 可以在不依赖传统 SSH 端口的情况下,为法证团队提供安全的访问方式,符合隔离目标实例同时允许法证团队访问的需求。
C. 不正确。创建一个与目标实例所在子网相关联的网络 ACL。在入站规则集的顶部添加一条规则,拒绝来自 0.0.0.0/0 的所有流量。在出站规则集的顶部添加一条规则,拒绝到 0.0.0.0/0 的所有流量。网络 ACL 作用于子网级别,这样做会阻止子网内所有实例的流量,而不仅仅是目标实例,可能会影响子网内其他正常实例的通信,不是针对目标实例的有效隔离方法。
D. 不正确。
创建一个 AWS Systems Manager 文档,添加一个主机级防火墙规则以阻止所有入站和出站流量。在目标实例上运行该文档。该方案虽然可以阻止所有流量,但使用 AWS Systems Manager 文档添加主机级防火墙规则相对复杂,且可能不是最直接有效的方式来隔离 EC2 实例,同时可能对实例的运行状态产生其他不可预见的影响。