

# SEC 5  如何保護您的網路資源？
<a name="w2aac19b7c11b5"></a>

任何具有某種網路連線能力的工作負載，無論是網際網路或私有網路，都需要多層防禦來協助保護其不受外部和內部網路威脅的影響。

**Topics**
+ [SEC05-BP01 建立網路層](sec_network_protection_create_layers.md)
+ [SEC05-BP02 控制所有層級的流量](sec_network_protection_layered.md)
+ [SEC05-BP03 自動化網路保護](sec_network_protection_auto_protect.md)
+ [SEC05-BP04 實作檢查和保護](sec_network_protection_inspection.md)

# SEC05-BP01 建立網路層
<a name="sec_network_protection_create_layers"></a>

 將共用連線能力需求的元件分組成許多層。例如：不需存取網際網路的虛擬私有雲端 (VPC) 中的資料庫叢集，應放置在沒有往返網際網路路由的子網路中。在沒有 VPC 的情況下操作的無伺服器工作負載中，與微型服務類似的分層和區隔可以達到相同的目標。 

Amazon Elastic Compute Cloud (Amazon EC2) 執行個體、Amazon Relational Database Service (Amazon RDS) 資料庫叢集等元件，以及共用連線能力要求的 AWS Lambda 函數可分成子網路所組成的層級。例如：不需存取網際網路的 VPC 中的 Amazon RDS 資料庫叢集，應放置在沒有往返網際網路路由的子網路中。此控制項的分層方法可減輕單一層組態錯誤所造成的影響，這可能會允許意外存取。對於 Lambda，您可以在 VPC 中執行函數，以利用 VPC 型控制。

對於可以包含數千個 VPC、AWS 帳戶和內部部署網路的網路連線，您應該使用 [AWS Transit Gateway](http://aws.amazon.com/transit-gateway)。它可作為中樞，控制流量在所有連線網路之間路由的方式，其作用就像輪輻。Amazon Virtual Private Cloud 和 AWS Transit Gateway 之間的流量仍保存在 AWS 私有網路，可減少外部威脅向量，例如分散式拒絕服務 (DDoS) 攻擊和常見入侵程式，例如 SQL 插入、跨網站指令碼、跨網站偽造請求或濫用不完整的身份驗證碼。AWS Transit Gateway 區域間對等也可為區域間的流量加密，不會有單點故障或頻寬瓶頸。

 **若未建立此最佳實務，暴露的風險等級為：** 高 

## 實作指引
<a name="implementation-guidance"></a>
+  在 VPC 中建立子網路：為每一層中建立子網路 (在包含多個可用區域的群組中)，並建立路由表的關聯以控制路由。 
  +  [VPC 和子網路 ](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html)
  +  [路由表 ](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html)

## 資源
<a name="resources"></a>

 **相關文件：** 
+  [AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-chapter.html) 
+ [ Amazon Inspector ](https://aws.amazon.com/inspector)
+  [Amazon VPC 安全性](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Security.html) 
+  [AWS WAF 入門](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html) 

 **相關影片：** 
+  [適用於許多 VPC 的 AWS Transit Gateway 參考架構 ](https://youtu.be/9Nikqn_02Oc)
+  [使用 Amazon CloudFront、AWS WAF 和 AWS Shield 的應用程式加速和保護](https://youtu.be/0xlwLEccRe0) 

 **相關範例：** 
+  [實驗室︰VPC 的自動部署](https://www.wellarchitectedlabs.com/Security/200_Automated_Deployment_of_VPC/README.html) 

# SEC05-BP02 控制所有層級的流量
<a name="sec_network_protection_layered"></a>

  建構網路拓撲時，您應該檢查每個元件的連線需求。例如，如果元件需要網際網路可存取性 (傳入和傳出)、連線至 VPC、邊緣服務和外部資料中心。 

 VPC 可讓您定義橫跨 AWS 區域的網路拓撲，使用您所設定的私有 IPv4 位址範圍，或 AWS 選取的 IPv6 位址範圍。您應該對傳入和傳出流量採用深度防禦方法的多個控制，包括使用安全群組 (狀態檢測防火牆)、網路 ACL、子網路和路由表。在 VPC 內，您可以在可用區域中建立子網路。每個子網都有一個關聯的路由表，定義路由規則，以管理子網路內流量所經過的路徑。您可以透過讓路由前往連接到 VPC 的網際網路或 NAT 閘道，或透過另一個 VPC 來定義網際網路可路由子網路。 

 當執行個體、Amazon Relational Database Service (Amazon RDS) 資料庫或其他服務在 VPC 內啟動時，每個網路介面都有自己的安全群組。此防火牆位於作業系統層之外，可用來定義允許傳入和傳出流量的規則。您還可以定義安全群組之間的關係。例如，資料庫層安全群組內的執行個體，藉由參照套用至所涉及執行個體的安全群組，僅接受來自應用程式層內執行個體的流量。除非您使用非 TCP 通訊協定，否則應該不需要從網際網路直接存取 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體 (即使連接埠受安全群組限制)，無須使用負載平衡器或 [CloudFront](https://aws.amazon.com/cloudfront)。這有助於防止透過作業系統或應用程式問題意外受到存取。子網路也可以連接著網路 ACL，做為無狀態的防火牆。您應該設定網路 ACL 以縮小層級之間允許的流量範圍，並請注意，需要同時定義傳入和傳出規則。 

 有些 AWS 服務會要求元件存取網際網路以進行 API 呼叫，其中 [AWS API 端點](https://docs.aws.amazon.com/general/latest/gr/rande.html) 所在位置。其他 AWS 服務會使用 [VPC 端點](https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints.html) (在您的 Amazon VPC 內)。許多 AWS 服務 (包括 Amazon S3 和 Amazon DynamoDB) 都支援 VPC 端點，而這項技術已廣泛應用於 [AWS PrivateLink](https://aws.amazon.com/privatelink/)。我們建議您使用此方法安全地存取 AWS 服務、第三方服務，以及您在其他 VPC 中託管的專屬服務。AWS PrivateLink 上的所有網路流量都停留在全球 AWS 骨幹網路上，而且永遠不會周遊網際網路。連線只能由服務的消費者啟動，而不能由服務的供應商啟動。使用 AWS PrivateLink 進行外部服務存取可讓您建立沒有網際網路存取的氣隙 VPC，並協助保護您的 VPC 免於外部威脅向量的攻擊。第三方服務可以使用 AWS PrivateLink，允許其客戶透過私有 IP 地址從其 VPC 連線到服務。對於需要對網際網路進行對外連線的 VPC 資產，這些資產可以透過 AWS 受管 NAT 閘道、僅對外網際網路閘道或您建立和管理的 Web 代理進行僅對外 (單向)。

 **若未建立此最佳實務，暴露的風險等級：** 高 

## 實作指引
<a name="implementation-guidance"></a>
+  控制 VPC 中的網路流量：實作 VPC 最佳實務來控制流量。 
  +  [Amazon VPC 安全性](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Security.html) 
  +  [VPC 端點](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints.html) 
  +  [Amazon VPC 安全群組](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html) 
  +  [網路 ACL](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html) 
+  控制邊緣的流量：實作 Amazon CloudFront 等邊緣服務，以提供多一層的保護和其他功能。
  +  [Amazon CloudFront 使用案例](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/IntroductionUseCases.html) 
  +  [AWS Global Accelerator](https://docs.aws.amazon.com/global-accelerator/latest/dg/what-is-global-accelerator.html) 
  +  [AWS Web 應用程式防火牆 (AWS WAF)](https://docs.aws.amazon.com/waf/latest/developerguide/waf-section.html) 
  +  [Amazon Route 53](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/Welcome.html) 
  +  [Amazon VPC 輸入路由](https://aws.amazon.com/about-aws/whats-new/2019/12/amazon-vpc-ingress-routing-insert-virtual-appliances-forwarding-path-vpc-traffic/) 
+  控制私有網路流量：實作可保護工作負載私有流量的服務。
  +  [Amazon VPC 對等互連](https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) 
  +  [Amazon VPC 端點服務 (AWS PrivateLink)](https://docs.aws.amazon.com/vpc/latest/userguide/endpoint-service.html) 
  +  [Amazon VPC Transit Gateway](https://docs.aws.amazon.com/vpc/latest/tgw/what-is-transit-gateway.html) 
  +  [AWS Direct Connect](https://docs.aws.amazon.com/directconnect/latest/UserGuide/Welcome.html) 
  +  [AWS 站點對站點 VPN](https://docs.aws.amazon.com/vpn/latest/s2svpn/VPC_VPN.html) 
  +  [AWS Client VPN](https://docs.aws.amazon.com/vpn/latest/clientvpn-user/user-getting-started.html) 
  +  [Amazon S3 存取點](https://docs.aws.amazon.com/AmazonS3/latest/dev/access-points.html) 

## 資源
<a name="resources"></a>

 **相關文件：** 
+  [AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-section.html) 
+  [Amazon Inspector](https://aws.amazon.com/inspector) 
+  [AWS WAF 入門](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html) 

 **相關影片：** 
+  [適用於許多 VPC 的 AWS Transit Gateway 參考架構](https://youtu.be/9Nikqn_02Oc) 
+  [使用 Amazon CloudFront、AWS WAF 和 AWS Shield 的應用程式加速和保護 ](https://youtu.be/0xlwLEccRe0)

 **相關範例：** 
+  [實驗室︰VPC 的自動部署](https://www.wellarchitectedlabs.com/Security/200_Automated_Deployment_of_VPC/README.html) 

# SEC05-BP03 自動化網路保護
<a name="sec_network_protection_auto_protect"></a>

 自動化保護機制，以借助威脅情報和異常偵測提供自衛網路。例如，可以適應目前威脅並降低其影響的入侵偵測和預防工具。Web 應用程式防火牆即為可將網路保護自動化的範例；例如，使用 AWS WAF Security Automations 解決方案 ([https://github.com/awslabs/aws-waf-security-automations](https://github.com/awslabs/aws-waf-security-automations)) 以自動封鎖來自已知威脅者相關 IP 位址的請求。

 **若未建立此最佳實務，暴露的風險等級為：** 中 

## 實作指引
<a name="implementation-guidance"></a>
+  針對以網頁為基礎的流量進行自動保護：AWS 提供的解決方案使用 AWS CloudFormation 自動部署一組 AWS WAF 規則，專門用於篩選常見網頁式攻擊。使用者可從預先設定的保護功能中進行選擇，以定義 AWS WAF Web 存取控制清單 (web ACL) 中包含的規則。
  +  [AWS WAF 安全自動化](https://aws.amazon.com/solutions/aws-waf-security-automations/) 
+  考慮 AWS Partner 解決方案：AWS 合作夥伴提供數百種領先業界的產品，這些產品與您內部部署環境中的現有控制項相當、相同或互相整合。這些產品可補充現有的 AWS 服務，讓您能夠在雲端和內部部署環境中部署全方位的安全架構，以及擁有更流暢的體驗。
  +  [基礎設施安全](https://aws.amazon.com/security/partner-solutions/#infrastructure_security) 

## 資源
<a name="resources"></a>

 **相關文件：** 
+  [AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-section.html) 
+  [Amazon Inspector](https://aws.amazon.com/inspector) 
+ [Amazon VPC 安全性](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Security.html)
+  [AWS WAF 入門](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html) 

 **相關影片：** 
+  [適用於許多 VPC 的 AWS Transit Gateway 參考架構](https://youtu.be/9Nikqn_02Oc) 
+  [使用 Amazon CloudFront、AWS WAF 和 AWS Shield 的應用程式加速和保護 ](https://youtu.be/0xlwLEccRe0)

 **相關範例：** 
+  [實驗室︰VPC 的自動部署](https://www.wellarchitectedlabs.com/Security/200_Automated_Deployment_of_VPC/README.html) 

# SEC05-BP04 實作檢查和保護
<a name="sec_network_protection_inspection"></a>

 檢查和篩選每個層級的流量。為了檢查您的 VPC 組態並找出潛在的意外存取，您可以使用 [VPC Network Access Analyzer](https://docs.aws.amazon.com/vpc/latest/network-access-analyzer/what-is-vaa.html)。您可以指定您的網路存取要求，並識別未符合它們的潛在網路路徑。對於透過 HTTP 通訊協定進行交易的元件，Web 應用程式防火牆可協助防止常見的攻擊。 [AWS WAF](https://aws.amazon.com/waf) 是一種 Web 應用程式防火牆，可讓您監控和封鎖符合可設定規則的 HTTP 請求；這些請求會轉送到 Amazon API Gateway API、Amazon CloudFront 或 Application Load Balancer。若要開始使用 AWS WAF，您可以將 [AWS 受管規則](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html#getting-started-wizard-add-rule-group) 結合自己的規則，或使用現有的 [合作夥伴整合](https://aws.amazon.com/waf/partners/)。 

 若要跨 AWS Organizations 管理 AWS WAF、AWS Shield Advanced 保護和 Amazon VPC 安全群組，您可以使用 AWS Firewall Manager。它可讓您集中設定和管理所有帳戶和應用程式的防火牆規則，使得共同規則的擴展強制執行更為輕鬆。它也可讓您使用 [AWS Shield Advanced](https://docs.aws.amazon.com/waf/latest/developerguide/ddos-responding.html)或可自動封鎖對 Web 應用程式不必要請求的 [解決方案](https://aws.amazon.com/solutions/aws-waf-security-automations/) ，快速地回應攻擊。Firewall Manager 也會使用 [AWS Network Firewall](https://aws.amazon.com/network-firewall/)。AWS Network Firewall 是一種託管服務，其會使用規則引擎，讓您精細控制有狀態和無狀態網路流量。它支援 [Suricata 相容的](https://docs.aws.amazon.com/network-firewall/latest/developerguide/stateful-rule-groups-ips.html) 開放原始碼入侵防禦系統 (IPS) 規格，供規則用來協助保護您的工作負載。 

 **若未建立此最佳實務，暴露的風險等級為：** 低 

## 實作指引
<a name="implementation-guidance"></a>
+  設定 Amazon GuardDuty：GuardDuty 是威脅偵測服務，可持續監控惡意活動和未經授權的行為，以保護 AWS 帳戶和工作負載。啟用 GuardDuty 並設定自動提醒。 
  +  [Amazon GuardDuty](https://docs.aws.amazon.com/guardduty/latest/ug/what-is-guardduty.html) 
  +  [實驗室︰偵測控制的自動部署](https://wellarchitectedlabs.com/Security/200_Automated_Deployment_of_Detective_Controls/README.html) 
+  設定虛擬私有雲端 (VPC) 流程日誌：VPC 流程日誌讓您可以擷取有關往返 VPC 網路界面 IP 流量的資訊。流程日誌資料可以發佈至 Amazon CloudWatch Logs 和 Amazon Simple Storage Service (Amazon S3)。建立流程日誌後，您可以在選定的目標位置擷取和檢視其資料。
+  考慮 VPC 流量鏡像化：流量鏡像化是一項 Amazon VPC 功能，可用來從 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體的彈性網路界面複製網路流量，然後將流量傳送到頻外安全與監控設備，以進行內容檢查、威脅監控和故障排除。
  +  [VPC 流量鏡像化](https://docs.aws.amazon.com/vpc/latest/mirroring/what-is-traffic-mirroring.html) 

## 資源
<a name="resources"></a>

 **相關文件：** 
+  [AWS Firewall Manager](https://docs.aws.amazon.com/waf/latest/developerguide/fms-section.html) 
+  [Amazon Inspector](https://aws.amazon.com/inspector) 
+  [Amazon VPC 安全性](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Security.html) 
+  [AWS WAF 入門](https://docs.aws.amazon.com/waf/latest/developerguide/getting-started.html) 

 **相關影片：** 
+  [適用於許多 VPC 的 AWS Transit Gateway 參考架構](https://youtu.be/9Nikqn_02Oc) 
+  [使用 Amazon CloudFront、AWS WAF 和 AWS Shield 的應用程式加速和保護](https://youtu.be/0xlwLEccRe0) 

 **相關範例：** 
+  [實驗室︰VPC 的自動部署](https://www.wellarchitectedlabs.com/Security/200_Automated_Deployment_of_VPC/README.html) 