Skip to content

Commit 3722139

Browse files
committed
Update to version v3.2.0
1 parent 03caa39 commit 3722139

38 files changed

+1726
-170
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
**/.pyc
88
/deployment/open-source/
99
source/tests/__pycache__/
10-
source/log_parser/__pycache__/
10+
source/log_parser/__pycache__/
11+
deployment/global-s3-assets/
12+
deployment/regional-s3-assets/
13+
14+
# coverage
15+
**/coverage
16+
**/package
17+
*coverage*

CHANGELOG.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,35 @@ All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6-
## [2.3.1] - 2019-10-30
6+
## [3.2] - 2021-09-22
77
### Added
8+
- Added IP retention support on Allowed and Denied IP Sets
89
### Changed
9-
- Fixed error handling of intermittent issue: (WAFStaleDataException) when calling the UpdateWebACL
10-
- Upgrade from Node 8 to Node 10 for Lambda function
11-
## [2.3.2] - 2020-02-05
10+
- Bug fixes
11+
## [3.1] - 2020-10-22
12+
### Changed
13+
- Replaced s3 path-style with virtual-hosted style
14+
- Added partition variable to all ARNs
15+
- Updated bug report
16+
## [3.0] - 2020-07-08
1217
### Added
18+
- Added an option to deploy AWS Managed Rules for WebACL on installation
1319
### Changed
14-
- Fixed README file to accurately reflect script params
15-
- Upgraded from Python 3.7 to 3.8
16-
- Changed RequestThreshold min limit from 2000 to 100
20+
- Upgraded from WAF classic to WAFV2 API
21+
- Eliminated dependency on NodeJS and use Python as the standardized programming language
1722
## [2.3.3] - 2020-06-15
1823
### Added
1924
- Implemented Athena optimization: added partitioning for CloudFront, ALB and WAF logs and Athena queries
2025
### Changed
2126
- Fixed potential DoS vector within Bad Bots X-Forward-For header
22-
## [3.0] - 2020-07-08
27+
## [2.3.2] - 2020-02-05
2328
### Added
24-
- Added an option to deploy AWS Managed Rules for WebACL on installation
2529
### Changed
26-
- Upgraded from WAF classic to WAFV2 API
27-
- Eliminated dependency on NodeJS and use Python as the standardized programming language
28-
## [3.1] - 2020-10-22
30+
- Fixed README file to accurately reflect script params
31+
- Upgraded from Python 3.7 to 3.8
32+
- Changed RequestThreshold min limit from 2000 to 100
33+
## [2.3.1] - 2019-10-30
34+
### Added
2935
### Changed
30-
- Replaced s3 path-style with virtual-hosted style
31-
- Added partition variable to all ARNs
32-
- Updated bug report
36+
- Fixed error handling of intermittent issue: (WAFStaleDataException) when calling the UpdateWebACL
37+
- Upgrade from Node 8 to Node 10 for Lambda function

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWS WAF Security Automations
22

3-
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
44
Licensed under the Apache License Version 2.0 (the "License"). You may not use this file except
55
in compliance with the License. A copy of the License is located at http://www.apache.org/licenses/
66
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,

README.md

Lines changed: 118 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,153 @@
1-
# AWS WAF Security Automations
2-
A solution that contains all AWS WAF samples developed so far - waf-reactive-blacklist, waf-bad-bot-blocking, waf-block-bad-behaving and waf-reputation-lists.
1+
**[🚀 Solution Landing Page](https://aws.amazon.com/solutions/implementations/aws-waf-security-automations/>)** | **[🚧 Feature request](https://github.com/awslabs/aws-waf-security-automations/issues/new?assignees=&labels=feature-request%2C+enhancement&template=feature_request.md&title=)** | **[🐛 Bug Report](https://github.com/awslabs/aws-waf-security-automations/issues/new?assignees=&labels=bug%2C+triage&template=bug_report.md&title=)**
32

4-
For the full solution overview visit [AWS WAF Security Automations](https://aws.amazon.com/answers/security/aws-waf-security-automations/).
3+
Note: If you want to use the solution without building from source, navigate to Solution Landing Page
54

6-
## File Structure
7-
This project consists of microservices that facilitate the functional areas of the solution. These microservices are deployed to a serverless environment in AWS Lambda.
5+
## Table of contents
86

9-
```
10-
|-deployment/ [folder containing templates and build scripts]
11-
|-source/
12-
|-access_handler/ [microservice for processing bad bots honeypot endpoint access. This AWS Lambda function intercepts the suspicious request and adds the source IP address to the AWS WAF block list]
13-
|-custom_resource/ [custom helper for CloudFormation deployment template]
14-
|-helper/ [custom helper for CloudFormation deployment dependency check and auxiliary functions]
15-
|-lib/ [library files including waf api calls and other common functions used in the solution]
16-
|-log_parser/ [microservice for processing access logs searching for suspicious behavior and add the corresponding source IP addresses to an AWS WAF block list]
17-
|-reputation_lists_parser/ [microservice for processing third-party IP reputation lists and add malicious IP addresses to an AWS WAF block list]
18-
|-tests/ [unit tests]
19-
|-timer/ [creates a sleep function for cloudformation to pace the creation of ip_sets]
20-
```
7+
- [Solution Overview](#solution-overview)
8+
- [Architecture Diagram](#architecture-diagram)
9+
- [Customizing the Solution](#customizing-the-solution)
10+
- [Prerequisites for Customization](#prerequisites-for-customization)
11+
- [Build](#build)
12+
- [Upload Deployment Assets](#upload-deployment-assets)
13+
- [Deploy](#deploy)
14+
- [File Structure](#file-structure)
15+
- [License](#license)
16+
17+
<a name="solution-overview"></a>
18+
# Solution Overview
19+
20+
The AWS DevOps Monitoring Dashboard solution is a reference implementation that automatically deploys a set of AWS WAF (web application firewall) rules that filter common web-based attacks. Users can select from preconfigured protective features that define the rules included in an AWS WAF web access control list (web ACL). Once deployed, AWS WAF protects your Amazon CloudFront distributions or Application Load Balancers by inspecting web requests.
21+
22+
You can use AWS WAF to create custom, application-specific rules that block attack patterns to ensure application availability, secure resources, and prevent excessive resource consumption.
23+
24+
This solution can be easily installed in your AWS accounts via launching the provided AWS CloudFormation template.
25+
26+
For a detailed solution implementation guide, refer to Solution Landing Page [AWS WAF Security Automations](https://aws.amazon.com/solutions/implementations/aws-waf-security-automations)
27+
28+
<a name="architecture-diagram"></a>
29+
# Architecture Diagram
30+
31+
<p align="center">
32+
<img src="source/image/architecture_diagram.png">
33+
<br/>
34+
</p>
35+
36+
AWS WAF Security Automations architecture
37+
38+
AWS Managed Rules (A): This set of AWS managed core rules provides protection against exploitation of a wide range of common application vulnerabilities or other unwanted traffic.
39+
40+
Manual IP lists (B and C): This component creates two specific AWS WAF rules that allow you to manually insert IP addresses that you want to block or allow.
41+
42+
SQL Injection (D) and XSS (E): The solution configures two native AWS WAF rules that are designed to protect against common SQL injection or cross-site scripting (XSS) patterns in the URI, query string, or body of a request.
43+
44+
HTTP flood (F): This component helps protect against attacks that consist of a large number of requests from a particular IP address, such as a web-layer DDoS attacks or a brute-force login attempt. This feature supports thresholds of less than 100 requests within a 5 minute period.
45+
46+
Scanners and Probes (G): This component parses application access logs searching for suspicious behavior, such as an abnormal amount of errors generated by an origin. It then blocks those suspicious source IP addresses for a customer-defined period of time.
47+
48+
IP Reputation Lists (H): This component is the IP Lists Parser AWS Lambda function which checks third-party IP reputation lists hourly for new ranges to block.
49+
50+
Bad Bots (I): This component automatically sets up a honeypot, which is a security mechanism intended to lure and deflect an attempted attack.
2151

22-
## Getting Started
52+
<a name="customizing-the-solution"></a>
53+
# Customizing the Solution
2354

24-
#### 01. Prerequisites
25-
The following procedures assumes that all of the OS-level configuration has been completed. They are:
55+
<a name="prerequisites-for-customization"></a>
56+
## Prerequisites for Customization
2657

2758
* [AWS Command Line Interface](https://aws.amazon.com/cli/)
2859
* Python 3.8
2960

30-
The AWS WAF Security Automations solution is developed with Python for the microservices that run in AWS Lambda. The latest version has been tested with Python v3.8.
61+
<a name="build"></a>
62+
## Build
3163

32-
#### 02. Clone AWS WAF Security Automations repository
33-
Clone the aws-waf-security-automations GitHub repository:
64+
Building from GitHub source will allow you to modify the solution, such as adding custom actions or upgrading to a new release. The process consists of downloading the source from GitHub, creating Amazon S3 buckets to store artifacts for deployment, building the solution, and uploading the artifacts to S3 in your account.
65+
66+
#### 1. Clone the repository
67+
68+
Clone or download the repository to a local directory on your linux client. Note: if you intend to modify the source code you may wish to create your own fork of the GitHub repo and work from that. This allows you to check in any changes you make to your private copy of the solution.
69+
70+
**Git Clone example:**
3471

3572
```
3673
git clone https://github.com/awslabs/aws-waf-security-automations.git
3774
```
3875

39-
#### 03. Run unit tests
40-
Next, run unit tests to make sure added customization passes the tests
76+
**Download Zip example:**
77+
```
78+
wget https://github.com/awslabs/aws-waf-security-automations/archive/master.zip
79+
```
80+
81+
#### 2. Unit test
82+
Next, run unit tests to make sure your customized code passes the tests
4183

42-
```
43-
cd ./deployment
84+
```
85+
cd <rootDir>/deployment
4486
chmod +x ./run-unit-tests.sh
4587
./run-unit-tests.sh
46-
```
88+
```
89+
90+
#### 3. Create S3 buckets for storing deployment assets
91+
92+
AWS Solutions use two buckets:
4793

48-
#### 04. Declare enviroment variables:
94+
* One global bucket that is access via the http end point. AWS CloudFormation templates are stored here. Ex. "mybucket"
95+
* One regional bucket for each region where you plan to deploy the solution. Use the name of the global bucket as the prefix of the bucket name, and suffixed with the region name. Regional assets such as Lambda code are stored here. Ex. "mybucket-us-east-1"
96+
* The assets in buckets must be accessible by your account
97+
98+
#### 4. Declare enviroment variables
4999
```
50-
export TEMPLATE_OUTPUT_BUCKET=<YOUR_TEMPLATE_OUTPUT_BUCKET> # Name for the S3 bucket where the template will be located
51-
export DIST_OUTPUT_BUCKET=<YOUR_DIST_OUTPUT_BUCKET> # Name for the S3 bucket where customized code will reside
52-
export SOLUTION_NAME="aws-waf-security-automations" # name of the solution
100+
export TEMPLATE_OUTPUT_BUCKET=<YOUR_TEMPLATE_OUTPUT_BUCKET> # Name of the global bucket where CloudFormation templates are stored
101+
export DIST_OUTPUT_BUCKET=<YOUR_DIST_OUTPUT_BUCKET> # Name for the regional bucket where regional assets are stored
102+
export SOLUTION_NAME=<SOLUTION_NAME> # name of the solution.
53103
export VERSION=<VERSION> # version number for the customized code
54-
export AWS_REGION=<AWS_REGION> # region where the distributable is deployed
104+
export AWS_REGION=<AWS_REGION> # region where the solution is deployed
55105
```
56-
#### _Note:_ You must manually create two buckets in S3 called $TEMPLATE_OUTPUT_BUCKET and $DIST_OUTPUT_BUCKET-$AWS_REGION to copy the distribution. The assets in bucket should be publicly accessible. The build-s3-dist.sh script DOES NOT do this and the CloudFormation template expects/references the REGION specific bucket.
57-
58-
#### 05. Build the AWS WAF Security Automations solution for deployment:
106+
#### 5. Build the solution
59107
```
108+
cd <rootDir>/deployment
60109
chmod +x ./build-s3-dist.sh && ./build-s3-dist.sh $TEMPLATE_OUTPUT_BUCKET $DIST_OUTPUT_BUCKET $SOLUTION_NAME $VERSION
61110
```
62-
#### 06. Upload deployment assets to your Amazon S3 buckets:
111+
112+
<a name="upload-deployment-assets"></a>
113+
## Upload deployment assets
63114
```
64-
aws s3 cp ./deployment/global-s3-assets s3://$TEMPLATE_OUTPUT_BUCKET/aws-waf-security-automations/$VERSION --recursive --acl bucket-owner-full-control
65-
aws s3 cp ./deployment/regional-s3-assets s3://$DIST_OUTPUT_BUCKET-$AWS_REGION/aws-waf-security-automations/$VERSION --recursive --acl bucket-owner-full-control
115+
aws s3 cp ./deployment/global-s3-assets s3://$TEMPLATE_OUTPUT_BUCKET/$SOLUTION_NAME/$VERSION --recursive --acl bucket-owner-full-control
116+
aws s3 cp ./deployment/regional-s3-assets s3://$DIST_OUTPUT_BUCKET-$AWS_REGION/$SOLUTION_NAME/$VERSION --recursive --acl bucket-owner-full-control
66117
```
67-
#### _Note:_ You must use proper acl and profile for the copy operation as applicable.
118+
#### _Note:_ You must use proper acl and profile for the copy operation as applicable. Using randomized bucket names is recommended.
119+
120+
<a name="deploy"></a>
121+
## Deploy
68122

69-
#### 07. Deploy the AWS WAF Security Automations solution:
70123
* From your designated Amazon S3 bucket where you uploaded the deployment assets, copy the link location for the aws-waf-security-automations.template.
71124
* Using AWS CloudFormation, launch the AWS WAF Security Automations solution stack using the copied Amazon S3 link for the aws-waf-security-automations.template.
72125

73-
***
126+
<a name="file-structure"></a>
127+
# File structure
128+
129+
This project consists of microservices that facilitate the functional areas of the solution. These microservices are deployed to a serverless environment in AWS Lambda.
130+
131+
<pre>
132+
|-deployment/ [folder containing templates and build scripts]
133+
|-source/
134+
|-access_handler/ [microservice for processing bad bots honeypot endpoint access. This AWS Lambda function intercepts the suspicious request and adds the source IP address to the AWS WAF block list]
135+
|-custom_resource/ [custom helper for CloudFormation deployment template]
136+
|-helper/ [custom helper for CloudFormation deployment dependency check and auxiliary functions]
137+
|-image/ [folder containing images of the solution such as architecture diagram]
138+
|-lib/ [library files including waf api calls and other common functions used in the solution]
139+
|-ip_retention_handler/ [lambda code for setting ip retention and removing expired ips]
140+
|-log_parser/ [microservice for processing access logs searching for suspicious behavior and add the corresponding source IP addresses to an AWS WAF block list]
141+
|-reputation_lists_parser/ [microservice for processing third-party IP reputation lists and add malicious IP addresses to an AWS WAF block list]
142+
|-timer/ [creates a sleep function for cloudformation to pace the creation of ip_sets]
143+
</pre>
74144

75-
Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
145+
<a name="Collection of operational metrics"></a>
146+
# Collection of operational metrics
76147

77-
Licensed under the Apache License, Version 2.0 (the "License");
78-
you may not use this file except in compliance with the License.
79-
You may obtain a copy of the License at
148+
This solution collects anonymous operational metrics to help AWS improve the quality and features of the solution. For more information, including how to disable this capability, please see the [implementation guide](https://docs.aws.amazon.com/solutions/latest/aws-waf-security-automations/appendix-g.html).
80149

81-
http://www.apache.org/licenses/LICENSE-2.0
150+
<a name="license"></a>
151+
# License
82152

83-
Unless required by applicable law or agreed to in writing, software
84-
distributed under the License is distributed on an "AS IS" BASIS,
85-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
86-
See the License for the specific language governing permissions and
87-
limitations under the License.
153+
See license [here](https://github.com/awslabs/aws-waf-security-automations/blob/master/LICENSE.txt)

deployment/aws-waf-security-automations-firehose-athena.template

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Parameters:
4646
Type: String
4747
DeliveryStreamName:
4848
Type: String
49+
UUID:
50+
Type: String
4951

5052
Conditions:
5153
AlbEndpoint: !Equals
@@ -144,6 +146,8 @@ Resources:
144146
Properties:
145147
DeliveryStreamName: !Ref DeliveryStreamName
146148
DeliveryStreamType: DirectPut
149+
DeliveryStreamEncryptionConfigurationInput:
150+
KeyType: AWS_OWNED_CMK
147151
ExtendedS3DestinationConfiguration:
148152
BucketARN: !Ref WafLogBucketArn
149153
BufferingHints:
@@ -404,7 +408,7 @@ Resources:
404408
Type: AWS::Athena::WorkGroup
405409
Condition: AthenaLogParser
406410
Properties:
407-
Name: WAFAddPartitionAthenaQueryWorkGroup
411+
Name: !Join ['-', ['WAFAddPartitionAthenaQueryWorkGroup', !Ref UUID]]
408412
Description: Athena WorkGroup for adding Athena partition queries used by AWS WAF Security Automations Solution
409413
State: ENABLED
410414
RecursiveDeleteOption: true

deployment/aws-waf-security-automations-webacl.template

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Resources:
191191
Scope: !Sub '${RegionScope}'
192192
IPAddressVersion: 'IPV4'
193193
Name: !Sub '${ParentStackName}WhitelistSetIPV4'
194-
Description: 'Allow whitelist for IPV4 addresses'
194+
Description: 'Allow List for IPV4 addresses'
195195
Addresses: []
196196

197197
WAFBlacklistSetV4:
@@ -201,7 +201,7 @@ Resources:
201201
Scope: !Sub '${RegionScope}'
202202
IPAddressVersion: 'IPV4'
203203
Name: !Sub '${ParentStackName}BlacklistSetIPV4'
204-
Description: 'Block blacklist for IPV4 addresses'
204+
Description: 'Block Denied List for IPV4 addresses'
205205
Addresses: []
206206

207207
WAFHttpFloodSetV4:
@@ -259,7 +259,7 @@ Resources:
259259
Scope: !Sub '${RegionScope}'
260260
IPAddressVersion: IPV6
261261
Name: !Sub '${ParentStackName}WhitelistSetIPV6'
262-
Description: 'Allow whitelist for IPV6 addresses'
262+
Description: 'Allow list for IPV6 addresses'
263263
Addresses: []
264264

265265
WAFBlacklistSetV6:
@@ -269,7 +269,7 @@ Resources:
269269
Scope: !Sub '${RegionScope}'
270270
IPAddressVersion: IPV6
271271
Name: !Sub '${ParentStackName}BlacklistSetIPV6'
272-
Description: 'Block blacklist for IPV6 addresses'
272+
Description: 'Block Denied List for IPV6 addresses'
273273
Addresses: []
274274

275275
WAFHttpFloodSetV6:
@@ -356,6 +356,13 @@ Resources:
356356
Variables:
357357
SECONDS: '2'
358358
LOG_LEVEL: !Ref LogLevel
359+
Metadata:
360+
cfn_nag:
361+
rules_to_suppress:
362+
- id: W89
363+
reason: There is no need to run this lambda in a VPC
364+
- id: W92
365+
reason: There is no need for Reserved Concurrency
359366

360367
# Adding a (priority 0) rule for AWS Managed RuleSet, optionally triggered by params
361368

0 commit comments

Comments
 (0)