HEX
Server: Apache
System: Linux dinesh8149 5.15.98-grsec-sharedvalley-2.lc.el8.x86_64 #1 SMP Thu Mar 9 09:07:30 -03 2023 x86_64
User: usesambura1 (1212012)
PHP: 7.0.33
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //etc/nginx/modsec/crs-setup-wordpress-context7.conf
# ------------------------------------------------------------------------
# CONFIGURAÇÃO CRS PARA WORDPRESS RATE LIMITING
# Baseado na documentação oficial OWASP Core Rule Set
# Versão Context7 - Configuração Assertiva
# ------------------------------------------------------------------------

#
# -- [[ CONFIGURAÇÕES BÁSICAS DO MODSECURITY ]] --
#
# Configurar engine do ModSecurity
SecRuleEngine On
SecRequestBodyAccess On
SecResponseBodyAccess On
SecResponseBodyMimeType text/plain text/html text/xml application/json

#
# -- [[ CONFIGURAÇÕES DE PARANOIA LEVEL ]] --
#
# Definir nível de paranoia (1-4, onde 4 é mais restritivo)
SecAction \
    "id:900000,\
    phase:1,\
    nolog,\
    pass,\
    t:none,\
    setvar:tx.blocking_paranoia_level=2,\
    setvar:tx.detection_paranoia_level=2"

#
# -- [[ CONFIGURAÇÕES DE ANOMALY SCORING ]] --
#
# Definir pontuações de anomalia
SecAction \
    "id:900001,\
    phase:1,\
    nolog,\
    pass,\
    t:none,\
    setvar:tx.critical_anomaly_score=5,\
    setvar:tx.error_anomaly_score=4,\
    setvar:tx.warning_anomaly_score=3,\
    setvar:tx.notice_anomaly_score=2"

# Limites de bloqueio por anomalia
SecAction \
    "id:900002,\
    phase:1,\
    nolog,\
    pass,\
    t:none,\
    setvar:tx.inbound_anomaly_score_threshold=5,\
    setvar:tx.outbound_anomaly_score_threshold=4"

#
# -- [[ CONFIGURAÇÕES ESPECÍFICAS WORDPRESS ]] --
#
# Configurações para WordPress
SecAction \
    "id:900010,\
    phase:1,\
    nolog,\
    pass,\
    t:none,\
    setvar:tx.wordpress_rate_limit_enabled=1,\
    setvar:tx.wordpress_login_attempts_limit=5,\
    setvar:tx.wordpress_login_block_time=300,\
    setvar:tx.wordpress_xmlrpc_attempts_limit=3,\
    setvar:tx.wordpress_xmlrpc_block_time=600,\
    setvar:tx.wordpress_ajax_requests_limit=50"

#
# -- [[ CONFIGURAÇÕES DE VARIÁVEIS GLOBAIS ]] --
#
# Inicializar variáveis globais de transação
SecAction \
    "id:900020,\
    phase:1,\
    nolog,\
    pass,\
    t:none,\
    setvar:tx.inbound_anomaly_score_pl1=0,\
    setvar:tx.inbound_anomaly_score_pl2=0,\
    setvar:tx.inbound_anomaly_score_pl3=0,\
    setvar:tx.inbound_anomaly_score_pl4=0"

#
# -- [[ CONFIGURAÇÕES DE AUDITORIA ]] --
#
# Configurar auditoria
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
SecAuditLogType Serial
SecAuditLog /var/log/modsec_audit.log

# Partes do log de auditoria
SecAuditLogParts ABDEFHIJZ

#
# -- [[ CONFIGURAÇÕES DE DETECÇÃO DE EVASÃO ]] --
#
# Detectar tentativas de evasão
SecAction \
    "id:900030,\
    phase:1,\
    nolog,\
    pass,\
    t:none,\
    setvar:tx.crs_validate_utf8_encoding=1,\
    setvar:tx.arg_name_length=100,\
    setvar:tx.arg_length=400,\
    setvar:tx.total_arg_length=64000,\
    setvar:tx.max_num_args=255,\
    setvar:tx.max_file_size=1048576,\
    setvar:tx.combined_file_sizes=1048576"

#
# -- [[ WHITELIST DE IPs (OPCIONAL) ]] --
#
# Whitelist de IPs confiáveis (descomente e configure conforme necessário)
# SecRule REMOTE_ADDR "@ipMatch 192.168.1.0/24,127.0.0.1" \
#     "id:900040,\
#     phase:1,\
#     nolog,\
#     pass,\
#     t:none,\
#     setvar:tx.wordpress_whitelist_ip=1"

#
# -- [[ CONFIGURAÇÕES DE EXCLUSÃO ]] --
#
# Exclusões para WordPress (reduzir falsos positivos)
SecRuleUpdateActionById 920230 "pass"  # Multipart/form-data
SecRuleUpdateActionById 920300 "pass"  # Missing Accept Header
SecRuleUpdateActionById 920440 "pass"  # URL file extension

#
# -- [[ CONFIGURAÇÕES DE RESPOSTA ]] --
#
# Configurar página de erro customizada
SecRule TX:INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_threshold}" \
    "id:900050,\
    phase:2,\
    block,\
    status:403,\
    log,\
    logdata:'Anomaly Score Exceeded: %{TX.INBOUND_ANOMALY_SCORE}',\
    msg:'Inbound Anomaly Score Exceeded (Total Score: %{TX.INBOUND_ANOMALY_SCORE})',\
    tag:'application-multi',\
    tag:'language-multi',\
    tag:'platform-multi',\
    tag:'attack-generic'"

# Marca de fim da configuração
SecMarker "END-CRS-SETUP-WORDPRESS"