You're right, nothing is blocked, because I raised the inbound and
outbound anomaly thresholds to 10000. What I'm trying to achieve though
(following the tutorial), is to make sure the anomaly scores for every
request, blocked and non-blocked, are logged to Nginx error.log, hence
the extra SecAction 980131.
Now I've disabled 980131 and re-activated 980130. When I set the anomaly
thresholds back to 5, the request is blocked but still none of the
messages from RESPONSE-980-CORRELATION.conf are logged.
I followed the request in modsec_debug.log with debug log level set to
9. It looks like TX:executing_anomaly_score is correctly set to 5 but
not logged. Instead, it's trying to log TX:INBOUND_ANOMALY_SCORE, which
seems empty (""). Maybe that's why it doesn't show up in the nginx
error.log. Are we logging the wrong variable here? Here's the output,
starting with the logging phase:
[1629895323] [/index.html?exec=/bin/bash] [4] Starting phase LOGGING.
(SecRules 5)
[1629895323] [/index.html?exec=/bin/bash] [9] This phase consists of 46
rule(s).
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 912110) Executing
operator "Eq" with param "0" against TX:dos_burst_time_slice.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:dos_burst_time_slice)
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars updated.
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 1.
[1629895323] [/index.html?exec=/bin/bash] [4] Executing chained rule.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 0) Executing
operator "Eq" with param "0" against TX:dos_counter_threshold.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:dos_counter_threshold)
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars updated.
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 1.
[1629895323] [/index.html?exec=/bin/bash] [4] Executing chained rule.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 0) Executing
operator "Eq" with param "0" against TX:dos_block_timeout.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:dos_block_timeout)
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars updated.
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 1.
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: nolog
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: skipAfter
[1629895323] [/index.html?exec=/bin/bash] [5] Setting skipAfter for:
END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [4] Running (disruptive)
action: pass.
[1629895323] [/index.html?exec=/bin/bash] [8] Running action pass
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912140'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912150'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912160'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912161'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912170'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912019'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [9] Skipped rule id '912171'
due to a SecMarker: END-DOS-PROTECTION-CHECKS
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980100) Executing
operator "Ge" with param "1" against TX:regex(LEAKAGE\\\/ERRORS).
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:regex(LEAKAGE\\\/ERRORS))
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 0.
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars cleaned.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980110) Executing
operator "Ge" with param "1" against
TX:regex(AVAILABILITY\\\/APP_NOT_AVAIL).
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:regex(AVAILABILITY\\\/APP_NOT_AVAIL))
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 0.
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars cleaned.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980115) Executing
unconditional rule...
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 5
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 5
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 5
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 5
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: log
[1629895323] [/index.html?exec=/bin/bash] [9] Saving transaction to logs
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: auditlog
[1629895323] [/index.html?exec=/bin/bash] [9] Saving transaction to logs
[1629895323] [/index.html?exec=/bin/bash] [4] Running (disruptive)
action: pass.
[1629895323] [/index.html?exec=/bin/bash] [8] Running action pass
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980120) Executing
operator "Lt" with param "5" Was: "" against TX:INBOUND_ANOMALY_SCORE.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "5"
(Variable: TX:INBOUND_ANOMALY_SCORE)
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 0.
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars cleaned.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980130) Executing
operator "Ge" with param "5" Was: "" against TX:INBOUND_ANOMALY_SCORE.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "5"
(Variable: TX:INBOUND_ANOMALY_SCORE)
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars updated.
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 1.
[1629895323] [/index.html?exec=/bin/bash] [4] Running (non-disruptive)
action: tag
[1629895323] [/index.html?exec=/bin/bash] [9] Rule tag: event-correlation
[1629895323] [/index.html?exec=/bin/bash] [9] Saving msg: Inbound
Anomaly Score Exceeded (Total Inbound Score: 5 -
SQLI=0,XSS=0,RFI=0,LFI=0,RCE=5,PHPI=0,HTTP=0,SESS=0): individual
paranoia level scores: 5, 0, 0, 0
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: log
[1629895323] [/index.html?exec=/bin/bash] [9] Saving transaction to logs
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: auditlog
[1629895323] [/index.html?exec=/bin/bash] [9] Saving transaction to logs
[1629895323] [/index.html?exec=/bin/bash] [4] Running (disruptive)
action: pass.
[1629895323] [/index.html?exec=/bin/bash] [8] Running action pass
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980140) Executing
operator "Ge" with param "4" Was: "" against TX:OUTBOUND_ANOMALY_SCORE.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:OUTBOUND_ANOMALY_SCORE)
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 0.
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars cleaned.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980145) Executing
unconditional rule...
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 0
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 0
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 0
[1629895323] [/index.html?exec=/bin/bash] [4] Running [independent]
(non-disruptive) action: setvar
[1629895323] [/index.html?exec=/bin/bash] [8] Saving variable:
TX:executing_anomaly_score with value: 0
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: log
[1629895323] [/index.html?exec=/bin/bash] [9] Saving transaction to logs
[1629895323] [/index.html?exec=/bin/bash] [9] Running action: auditlog
[1629895323] [/index.html?exec=/bin/bash] [9] Saving transaction to logs
[1629895323] [/index.html?exec=/bin/bash] [4] Running (disruptive)
action: pass.
[1629895323] [/index.html?exec=/bin/bash] [8] Running action pass
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 980150) Executing
operator "Lt" with param "4" Was: "" against TX:OUTBOUND_ANOMALY_SCORE.
[1629895323] [/index.html?exec=/bin/bash] [9] Target value: "0"
(Variable: TX:OUTBOUND_ANOMALY_SCORE)
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars updated.
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 1.
[1629895323] [/index.html?exec=/bin/bash] [4] Executing chained rule.
[1629895323] [/index.html?exec=/bin/bash] [4] (Rule: 0) Executing
operator "Gt" with param "1" against TX:MONITOR_ANOMALY_SCORE.
[1629895323] [/index.html?exec=/bin/bash] [4] Rule returned 0.
[1629895323] [/index.html?exec=/bin/bash] [9] Matched vars cleaned.
[1629895323] [/index.html?exec=/bin/bash] [8] Checking if this request
is suitable to be saved as an audit log.
[1629895323] [/index.html?exec=/bin/bash] [4] There was an audit log
modifier for this transaction.
[1629895323] [/index.html?exec=/bin/bash] [7] AuditLog parts before
modification(s): 8190.
[1629895323] [/index.html?exec=/bin/bash] [8] Checking if this request
is relevant to be part of the audit logs.
[1629895323] [/index.html?exec=/bin/bash] [5] Saving this request as
part of the audit logs.
[1629895323] [/index.html?exec=/bin/bash] [8] Request was relevant to be
saved. Parts: 8190
I also started thinking that it could have to do something with Windows.
I'm doing this on Windows 10 WSL Ubuntu, maybe the error device is
handled in some weird way that nginx doesn't support. I'll try tonight
to install nginx on Arch Linux and if that changes anything.
Again, thanks for taking the time to look into this. I'm learning a lot
already!
Cheers,
Florian