AWS WAF
Web ファイアウォール
悪意のある HTTP request(SQL injection、XSS、bot、不正な IP)を、CloudFront、ALB、API Gateway に到達する前にフィルタリングします。
- コスト$$ ふつう
- 難易度●●●●●
- 未使用でも課金?はい
- AWS マネージド
- 出題試験CLF · SAA · SOA
たとえるならブラックリストや不審な兆候に基づいて出入りする人をチェックする門の警備員のようなものです。
WAF はシステムのどこにある?
WAF が呼び出す
具体例でステップごとに
- ログインページに対して、ボットが 1 分間に何千回もパスワードを試しています。
- AWS WAF でウェブ ACL を作り、サイトの前にある CloudFront に関連付けます。
- SQL インジェクションと XSS をブロックする AWS のマネージドルールを有効にします。自分でルールを書く必要はありません。
- レートベースのルールで、5 分間に /login へ 300 回を超えるリクエストを送った IP をブロックします。
- ボットはエッジで止まり、悪いリクエストがサーバーに届くことはありません。
いつ使う?
✓ 使うべき場面
公開されている Web アプリケーション。
✗ 避けるべき場面
ネットワーク層の DDoS 対策 → Shield、VPC 内のトラフィックのフィルタリング → Network Firewall。
よくある使い方
- managed rules で SQL injection、XSS をブロック
- レート制限でブルートフォース、bot を防止
- IP または国によるブロック
WAF・VPC・CloudFront の違い
| 守る層 | アプリケーション層(HTTP):SQL インジェクション、XSS、ボット | ネットワーク:IP、ポート(セキュリティグループ、NACL) | コンテンツ配信。Shield Standard で DDoS を標準で防御 |
|---|---|---|---|
| 適用先 | CloudFront、ALB、API Gateway、AppSync、Cognito など | VPC 内のリソース | Web サイトの前段 |
| リクエストの中身の理解 | あり(パス、ヘッダー、本文) | なし | 一部(パスやヘッダーでキャッシュ) |
| 課金 | ウェブ ACL、ルール、リクエスト単位 | セキュリティグループは無料 | データ転送量 |
料金はいくら?
- 課金方式: $5/web ACL/月 + $1/rule/月 + $0.60/100 万 request。高度な rule セット(Bot Control、Fraud Control)は追加料金です。
- 無料枠: なし。
Bot Control/Fraud Control は request 単位の課金でかなり高い。環境ごとに別々の web ACL を作成する。
SQL インジェクションや XSS のブロック、単一 IP のレート制限、国単位のブロックなら WAF です。ネットワーク層の DDoS 対策は Shield(対応支援やコスト保護が必要なら Advanced)です。WAF は EC2 や NLB には適用できません。
本番の試験問題に挑戦
1A company's web application consists of multiple Amazon EC2 instances that run behind an Application Load Balancer in a VPC. An Amazon RDS for MySQL DB instance contains the data. The company needs the ability to automatically detect and respond to suspicious or unexpected behavior in its AWS environment. The company already has added AWS WAF to its architecture. What should a solutions architect do next to protect against threats?
- AUse Amazon GuardDuty to perform threat detection. Configure Amazon EventBridge (Amazon CloudWatch Events) to filter for GuardDuty findings and to invoke an AWS Lambda function to adjust the AWS WAF rules.
- BUse AWS Firewall Manager to perform threat detection. Configure Amazon EventBridge (Amazon CloudWatch Events) to filter for Firewall Manager findings and to invoke an AWS Lambda function to adjust the AWS WAF web ACL.
- CUse Amazon Inspector to perform threat detection and to update the AWS WAF rules. Create a VPC network ACL to limit access to the web application.
- DUse Amazon Macie to perform threat detection and to update the AWS WAF rules. Create a VPC network ACL to limit access to the web application.
答えを見る
正解: A
GuardDuty が不審な振る舞いを検出し、EventBridge がその検出結果を受けて Lambda を呼び出し、WAF のルールを自動で更新します。Inspector はソフトウェアの脆弱性スキャン、Macie は機密データの検出であり、脅威の検出には使いません。
2A company runs a web application on Amazon EC2 instances in an Auto Scaling group that has a target group. The company designed the application to work with session affinity (sticky sessions) for a better user experience. The application must be available publicly over the internet as an endpoint. A WAF must be applied to the endpoint for additional security. Session affinity (sticky sessions) must be configured on the endpoint. Which combination of steps will meet these requirements? (Choose two.)
- ACreate a public Network Load Balancer. Specify the application target group.
- BCreate a Gateway Load Balancer. Specify the application target group.
- CCreate a public Application Load Balancer. Specify the application target group.
- DCreate a second target group. Add Elastic IP addresses to the EC2 instances.
- ECreate a web ACL in AWS WAF. Associate the web ACL with the endpoint.
答えを見る
正解: C, E
パブリックな Application Load Balancer はスティッキーセッションに対応し、AWS WAF のウェブ ACL を関連付けられます。NLB や Gateway Load Balancer には WAF を適用できません。
よくある質問
WAF と Shield の違いは何ですか?
WAF はアプリケーション層で HTTP リクエストをフィルタリングし、SQL インジェクション、XSS、ボットのブロックや IP ごとのレート制限を行います。Shield は DDoS 対策で、Shield Standard はすべてのアカウントで無料で有効になっており、有料の Shield Advanced では AWS の DDoS 対応チームのサポートが加わります。
WAF はどこに適用できますか?
CloudFront、Application Load Balancer、API Gateway の REST API、AppSync、Cognito ユーザープール、App Runner、Verified Access に適用できます。EC2 や NLB には直接適用できません。
WAF の料金はどのように決まりますか?
ウェブ ACL の数、各 ACL のルール数、検査したリクエスト数で課金されます。AWS Marketplace のマネージドルールグループや、Bot Control、不正防止などの機能は追加料金がかかります。
AWS 認定試験では WAF について何が問われますか?
マネージドルールによる SQL インジェクションや XSS のブロック、単一 IP からの大量アクセスを防ぐレートベースのルール、地域によるブロック、適切なリソースへの WAF の適用、Shield、Network Firewall、セキュリティグループとの違いなどです。