47 lines
1.9 KiB
Plaintext
47 lines
1.9 KiB
Plaintext
SecRuleEngine On
|
|
SecRequestBodyAccess On
|
|
SecResponseBodyAccess On
|
|
SecDebugLog /var/log/modsecurity/debug.log
|
|
SecDebugLogLevel 0
|
|
SecAuditLogParts ABIJ
|
|
SecAuditLogType Serial
|
|
SecAuditLog /var/log/modsecurity/audit.log
|
|
|
|
# sql injection
|
|
SecRule ARGS "(?i)(['\"]|--|#|/\*|\*/)" \
|
|
"id:950001,phase:2,deny,status:403,msg:'SQL Injection: Escape or Comment',log,t:urlDecode,t:lowercase"
|
|
|
|
# sql keyword
|
|
SecRule ARGS "(?i)\b(select|insert|update|delete|drop|union|grant|alter|truncate)\b" \
|
|
"id:950002,phase:2,deny,status:403,msg:'SQL Injection: Keyword',log,t:urlDecode,t:lowercase"
|
|
|
|
# sql3 (teste)
|
|
SecRule ARGS|ARGS_NAMES|REQUEST_COOKIES|REQUEST_COOKIES_NAMES|REQUEST_HEADERS|XML:/*|JSON:/* \
|
|
"(?i)(select\s|insert\s|update\s|delete\s|drop\s|union\s|--|#|/\*|\*/|'|\"|%27|%22|<script>|<|>|%3C|%3E|exec\s|system\s|/etc/passwd|\.\./|%00)" \
|
|
"id:950100,phase:2,deny,status:403,msg:'SQL',log,t:urlDecode,t:lowercase"
|
|
|
|
# xss / html injection
|
|
SecRule REQUEST_URI|ARGS "(<.*>)|(%3C.*%3E)" \
|
|
"id:950003,phase:1,deny,status:403,msg:'XSS/HTML INJECTION DETECTED!!!',log"
|
|
|
|
# command injection
|
|
SecRule ARGS "(\"role\".*:.*\"admin\")|exec|cat|more|ls|dir|/etc/passwd" \
|
|
"id:950006,phase:2,deny,status:403,msg:'COMMAND INJECTION DETECTED!!!',log"
|
|
|
|
# path traversal
|
|
SecRule REQUEST_URI|ARGS "\%00|\%2500|\.\./|ftp|metrics|api-docs" \
|
|
"id:950007,phase:2,deny,status:403,msg:'PATH TRAVERSAL ATTEMPT!!!',log"
|
|
|
|
# exposed stuff (redundante ?)
|
|
SecRule REQUEST_URI|ARGS "\%00|\%2500|ftp|metrics|api-docs" \
|
|
"id:950008,phase:2,deny,status:500,msg:'ATTEMPT TO ACCESS FTP, METRICS, API-DOCS!!!',log"
|
|
|
|
# rate limiting on login endpoint
|
|
# (max 5 requests per 30s per IP)
|
|
SecAction \
|
|
"id:950009,phase:1,initcol:ip=%{REMOTE_ADDR},pass,nolog"
|
|
SecRule REQUEST_URI "@streq /rest/user/login" \
|
|
"id:950010,phase:2,pass,nolog,setvar:ip.login_count=+1,expirevar:ip.login_count=30"
|
|
SecRule IP:LOGIN_COUNT "@gt 5" \
|
|
"id:950011,phase:2,deny,status:429,msg:'Rate Limit Exceeded on Login',log"
|