OWASP Top 10 Most Critical Web Application Security Risks is a powerful awareness document for web application security. It represents a broad consensus about the most critical security risks to web applications. Project members include a variety of security experts from around the world who have shared their expertise to produce this list. You can read the document that they published here: .
This is a Terraform module which creates AWF WAF resources for protection of your resources from the OWASP Top 10 Security Risks. This module is based on the whitepaper that AWS provides. The whitepaper tells how to use AWS WAF to mitigate those attacks.
To see the example on how to provision the resources only, check Examples section.
But to see the example on how to use this module together with WebACL to fully protect your application, see this page: 
-  : https://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project
-  : https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
-  : https://d0.awsstatic.com/whitepapers/Security/aws-waf-owasp.pdf
-  : https://aws.amazon.com/about-aws/whats-new/2017/07/use-aws-waf-to-mitigate-owasps-top-10-web-application-vulnerabilities/
-  : https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-create-condition.html
-  : https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-rules.html
-  : https://docs.aws.amazon.com/waf/latest/developerguide/working-with-rule-groups.html
-  : https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-working-with.html
-  : https://github.com/traveloka/terraform-aws-waf-webacl-supporting-resources/tree/master/examples
- Can I use only some of the rules? Yes you can. This module will outputs the rules' ID. Attach to WebACL you created only the IDs of the rules that you want.
- Can I provision only some of the rules? No you can't. If you really want to do it, the only solution is to copy-paste match-sets and rules code manually. You must aware that by doing that you will lose support from maintainer of this module.
- Can I modify some match-sets of a rule? No you can't. The same answer to answer question number 2. But if you found something need to be fixed, e.g. match-sets causing lots of false positive, please don't hesitate to create an issue or a pull request to this repository!
This Terraform module has no dependencies to other modules
Created and tested using Terraform version
|create_rule_group||All rules can be grouped into a Rule Group. Unfortunately, AWS WAF Rule Group limit per region is only 3. By setting the value to
|csrf_expected_header||The custom HTTP request header, where the CSRF token value is expected to be encountered||
|csrf_expected_size||The size in bytes of the CSRF token value. For example if it's a canonically formatted UUIDv4 value the expected size would be 36 bytes/ASCII characters.||
|description||The description of these resources.||
|environment||The environment of these resources belong to.||
|max_expected_body_size||Maximum number of bytes allowed in the body of the request. If you do not plan to allow large uploads, set it to the largest payload value that makes sense for your web application. Accepting unnecessarily large values can cause performance issues, if large payloads are used as an attack vector against your web application.||
|max_expected_cookie_size||Maximum number of bytes allowed in the cookie header. The maximum size should be less than 4096, the size is determined by the amount of information your web application stores in cookies. If you only pass a session token via cookies, set the size to no larger than the serialized size of the session token and cookie metadata.||
|max_expected_query_string_size||Maximum number of bytes allowed in the query string component of the HTTP request. Normally the of query string parameters following the ? in a URL is much larger than the URI , but still bounded by the of the parameters your web application uses and their values.||
|max_expected_uri_size||Maximum number of bytes allowed in the URI component of the HTTP request. Generally the maximum possible value is determined by the server operating system (maps to file system paths), the web server software, or other middleware components. Choose a value that accomodates the largest URI segment you use in practice in your web application.||
|product_domain||The name of the product domain these resources belong to.||
|service_name||The name of the service these resources belong to.||
|target_scope||Valid values are
|rule01_sql_injection_rule_id||AWS WAF Rule which mitigates SQL Injection Attacks.|
|rule02_auth_token_rule_id||AWS WAF Rule which blacklists bad/hijacked JWT tokens or session IDs.|
|rule03_xss_rule_id||AWS WAF Rule which mitigates Cross Site Scripting Attacks.|
|rule04_paths_rule_id||AWS WAF Rule which mitigates Path Traversal, LFI, RFI.|
|rule06_php_insecure_rule_id||AWS WAF Rule which mitigates PHP Specific Security Misconfigurations.|
|rule07_size_restriction_rule_id||AWS WAF Rule which mitigates abnormal requests via size restrictions.|
|rule08_csrf_rule_id||AWS WAF Rule which enforces the presence of CSRF token in request header.|
|rule09_server_side_include_rule_id||AWS WAF Rule which blocks request patterns for webroot objects that shouldn't be directly accessible.|
|rule_group_id||AWS WAF Rule Group which contains all rules for OWASP Top 10 protection.|
This module accepting or open for any contributions from anyone, please see the CONTRIBUTING.md for more detail about how to contribute to this module.