Recipe 11-1: Detecting Large File Sizes
This recipe shows you how to use ModSecurity to enforce limits on the size of file uploads.
Ingredients
- OWASP ModSecurity Core Rule Set (CRS)
- modsecurity_crs_10_setup.conf
- modsecurity_crs_23_request_limits.conf
- ModSecurity
- FILES_SIZES variable
- FILES_COMBINED_SIZE variable
- @gt operator
CWE-119: Uncontrolled Resource Consumption (“Resource Exhaustion”)
Sample Attack
If the target web application does not restrict the size of files accepted for a file uploading resource, attackers may be able to cause a denial-of-service condition by filling up the local disk storage on the web server.
Preventing Large File Uploads
You can implement file upload restrictions using the following ModSecurity rules. The OWASP ModSecurity Core Rule Set includes the following variable definitions in the modsecurity_crs_10_setup.conf ...