Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coraza not logging logs and audit logs #42

Open
carlos-herrer opened this issue Feb 2, 2023 · 21 comments
Open

Coraza not logging logs and audit logs #42

carlos-herrer opened this issue Feb 2, 2023 · 21 comments

Comments

@carlos-herrer
Copy link

carlos-herrer commented Feb 2, 2023

Hi,
I am using coraza with caddy and trying to find the audit logs noted that it does not leave the audit log registers and when change the config SecAuditLog got a error:

If used a rute /var/log/audit/coraza_audit.log I got Permission deny
and If I used another rute in my case I try with /var/log/caddy/coraza_audit.log I got file don't found (if I create log file back permission deny)

All logs that i receive came from caddy log and not from the coraza

I try seting the config "SecDebugLog /var/log/coraza/coraza.log" with "SexDebugLogLevel 6" but not generate any file.
and if I using audit log "SecAuditLogDir /var/log/audit/audit_coraza.log", it's generate a permission error even with permission 777, only if using on /tmp/ folder not geting a error but it's not generate any file or log.

anyone knows how to fix the permission deny?

@carlos-herrer
Copy link
Author

carlos-herrer commented Feb 7, 2023

this logs is from coraza ? If that is, why all logs are generate on /var/log/syslog and not generate on the rute I specificated ?

Feb 6 19:47:04 lab caddy[585]: {"level":"error","ts":1675730824.3300385,"logger":"http.handlers.waf","msg":"[client "192.168.152.1"] Coraza: Warning. SQL Injection Attack Detected via libinjection [file "/usr/share/caddy/waf/coreruleset/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "0"] [id "942100"] [rev ""] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data: n&1 found within ARGS:name: carlos or 1=1"] [severity "critical"] [ver "OWASP_CRS/4.0.0-rc1"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/66"] [tag "PCI/6.5.2"] [hostname ""] [uri "/?name=carlos%20or%201=1"] [unique_id "hEliunlRvPlEKAvH"]\n[client "192.168.152.1"] Coraza: Warning. SQL Injection Attack Detected via libinjection [file "/usr/share/caddy/waf/coreruleset/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "0"] [id "942100"] [rev ""] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data: n&1 found within ARGS:name: carlos or 1=1"] [severity "critical"] [ver "OWASP_CRS/4.0.0-rc1"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/66"] [tag "PCI/6.5.2"] [hostname ""] [uri "/?name=carlos%20or%201=1"] [unique_id "hEliunlRvPlEKAvH"]\n[client "192.168.152.1"] Coraza: Warning. SQL Injection Attack Detected via libinjection [file "/usr/share/caddy/waf/coreruleset/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "0"] [id "942100"] [rev ""] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data: n&1 found within ARGS:name: carlos or 1=1"] [severity "critical"] [ver "OWASP_CRS/4.0.0-rc1"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/66"] [tag "PCI/6.5.2"] [hostname ""] [uri "/?name=carlos%20or%201=1"] [unique_id "hEliunlRvPlEKAvH"]\n[client "192.168.152.1"] Coraza: Warning. SQL Injection Attack Detected via libinjection [file "/usr/share/caddy/waf/coreruleset/rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf"] [line "0"] [id "942100"] [rev ""] [msg "SQL Injection Attack Detected via libinjection"] [data "Matched Data: n&1 found within ARGS:name: carlos or 1=1"] [severity "critical"] [ver "OWASP_CRS/4.0.0-rc1"] [maturity "0"] [accuracy "0"] [tag "application-multi"] [tag "language-multi"] [tag "platform-multi"] [tag "attack-sqli"] [tag "paranoia-level/1"] [tag "OWASP_CRS"] [tag "capec/1000/152/248/66"] [tag "PCI/6.5.2"] [hostname ""] [uri "/?name=carlos%20or%201=1"] [unique_id "hEliunlRvPlEKAvH"]\n"}
Feb 6 19:47:04 lab caddy[585]: {"level":"error","ts":1675730824.3382945,"logger":"http.handlers.waf","msg":"[client "192.168.152.1"] Coraza: Warning. Inbound Anomaly Score Exceeded (Total Score: 20) [file "/usr/share/caddy/waf/coreruleset/rules/REQUEST-949-BLOCKING-EVALUATION.conf"] [line "0"] [id "949110"] [rev ""] [msg "Inbound Anomaly Score Exceeded (Total Score: 20)"] [data ""] [severity "emergency"] [ver "OWASP_CRS/4.0.0-rc1"] [maturity "0"] [accuracy "0"] [tag "anomaly-evaluation"] [hostname ""] [uri "/?name=carlos%20or%201=1"] [unique_id "hEliunlRvPlEKAvH"]\n"}

@fzipi
Copy link
Member

fzipi commented Feb 26, 2023

@jptosso @jcchavezs Any inputs here?

@fzipi
Copy link
Member

fzipi commented Mar 1, 2023

@jcchavezs @jptosso ping.

@fzipi
Copy link
Member

fzipi commented Mar 5, 2023

@jcchavezs @jptosso ping 2.

@jcchavezs
Copy link
Member

we completely rewrite the connector. Do you mind testing again with latest commit? At least the debug logging should be working fine. Audit we will tackle soon.

@carlos-herrer
Copy link
Author

Hello @jcchavezs when try to update caddy it's take v1.2.2 this is the final version of coraza-caddy? it's not will be 1.2.3 ?
"SecAuditLogDir /var/log/audit_coraza.log" provision http.handlers.waf: invalid WAF config: open /var/log/audit_coraza.log: permission denied

same error.

@M4tteoP
Copy link
Member

M4tteoP commented Apr 4, 2023

The version with the rewritten connector is not yet tagged, you should be able to try it pointing directly to the commit (34daaf87f9ddaca2833461de59ebada21c902598)

@carlos-herrer
Copy link
Author

Hello @M4tteoP if used xcaddy with build 34daaf8 i got error invalid

go: github.com/caddyserver/caddy/v2@34daaf87f9ddaca2833461de59ebada21c902598: invalid version: unknown revision 34daaf8

I used xcaddy build 34daaf8 --with github.com/corazawaf/coraza-caddy

@jcchavezs
Copy link
Member

jcchavezs commented Apr 4, 2023 via email

@M4tteoP
Copy link
Member

M4tteoP commented Apr 4, 2023

The right syntax should be this one: xcaddy build --with github.com/corazawaf/coraza-caddy@34daaf87f9ddaca2833461de59ebada21c902598
In your attempt, you are trying to use the commit like it was a caddy commit, not a coraza-caddy one.

Edit: ops, JC has been faster :3

@carlos-herrer
Copy link
Author

Hello @M4tteoP @jcchavezs

You have right I can compile using xcaddy build --with github....coraza-caddy@build_hash

But now the error change and I got a error with the CRS loaded.
["/usr/share/caddy/waf/coreruleset/rules/REQUEST-901-INITIALIZATION.conf","/usr/share/caddy/waf/coreruleset/rules/]

@jcchavezs
Copy link
Member

Unfortunately this is an issue with the file system as it does not like absolute paths. I tried different approaches and ended up creating my own library for merging filesystems because existing ones did have some opinions.

This is the same issue as in jcchavezs/coraza-httpbin#4 (comment) which I will soon fix as soon as finish test the new merge library.

@jptosso
Copy link
Member

jptosso commented Apr 5, 2023

@jcchavezs I would remove your coreruleset library from coraza-caddy until it is fixed. It's not such an important feature for the connector, and it's not even documented

@jcchavezs
Copy link
Member

Yeah I will remove that. And reassess the os filesystem.

@jcchavezs
Copy link
Member

jcchavezs commented Apr 5, 2023 via email

@jcchavezs
Copy link
Member

@carlos-herrer please do try this branch #52

@carlos-herrer
Copy link
Author

Hello @jcchavezs, I got the same error Permission deny.

with "SecDebugLog /var/log/coraza/coraza.log" with "SexDebugLogLevel 6" I got invalid sintax.
and if I using audit log "SecAuditLogDir /var/log/audit/audit_coraza.log", it's generate a permission error.

@jwDevOps
Copy link

Hey there,
any updates on this? Still can't get logs working for coraza.

@bananasgroup
Copy link

Still having the same problem. I builded caddy by xcaddy build --with github.com/corazawaf/coraza-caddy/v2@latest . All log just show on screen console. Can't find in any log file.

@jcchavezs
Copy link
Member

I will look into this again.

@jcchavezs
Copy link
Member

I changed the example to show logs #173. Unfortunately I did not face any issue with logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants