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

chore: improves coraza.conf-recommended comments #1334

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

M4tteoP
Copy link
Member

@M4tteoP M4tteoP commented Mar 23, 2025

Improves coraza.conf-recommended coherency with the current Coraza state, and reduces old copy-pasted messages. See in-line comments for details

@M4tteoP M4tteoP force-pushed the recommended_keep_it_real branch from fb293c1 to 58bb175 Compare March 23, 2025 14:55
Comment on lines -38 to +48
# file uploads then the value given on the first line has to be as large
# as the largest file you are willing to accept. The second value refers
# to the size of data, with files excluded. You want to keep that value as
# low as practical.
#
# file uploads, this value must has to be as large as the largest file
# you are willing to accept.
SecRequestBodyLimit 13107200

# Maximum request body size that Coraza will store in memory. If the body
# size exceeds this value, it will be saved to a temporary file on disk.
SecRequestBodyInMemoryLimit 131072

# SecRequestBodyNoFilesLimit is currently not supported by Coraza
# Maximum request body size we will accept for buffering, with files excluded.
# You want to keep that value as low as practical.
# Note: SecRequestBodyNoFilesLimit is currently NOT supported by Coraza
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • first line, second value is not clear at all. I think it was referring to SecRequestBodyNoFilesLimit but then we added SecRequestBodyInMemoryLimit in between. I split this comment into one comment per directive.
  • SecRequestBodyInMemoryLimit was uncommented

Comment on lines +55 to +56
# Warning: Setting this directive to ProcessPartial introduces a potential bypass
# risk, as attackers could prepend junk data equal to or greater than the inspected body size.
Copy link
Member Author

@M4tteoP M4tteoP Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it is worth mentioning this attack here, this is something to consider when setting this directive. See https://github.com/assetnote/nowafpls

Copy link

codecov bot commented Mar 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.99%. Comparing base (572d720) to head (766d07d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1334   +/-   ##
=======================================
  Coverage   81.99%   81.99%           
=======================================
  Files         170      170           
  Lines        9803     9803           
=======================================
  Hits         8038     8038           
  Misses       1518     1518           
  Partials      247      247           
Flag Coverage Δ
coraza.rule.case_sensitive_args_keys 81.95% <ø> (ø)
coraza.rule.multiphase_valuation 81.99% <ø> (ø)
coraza.rule.no_regex_multiline 81.93% <ø> (ø)
default 81.99% <ø> (ø)
examples+ 16.50% <ø> (ø)
examples+coraza.rule.case_sensitive_args_keys 81.95% <ø> (ø)
examples+coraza.rule.multiphase_valuation 81.83% <ø> (ø)
examples+coraza.rule.no_regex_multiline 81.85% <ø> (ø)
examples+memoize_builders 81.95% <ø> (ø)
examples+no_fs_access 81.28% <ø> (ø)
ftw 81.99% <ø> (ø)
memoize_builders 82.08% <ø> (ø)
no_fs_access 81.44% <ø> (ø)
tinygo 81.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines -118 to +125
# By default, only keep the files that were determined to be unusual
# in some way (by an external inspection script). For this to work you
# will also need at least one file inspection rule.
# If On, the WAF will store the uploaded files in the SecUploadDir
# directory.
# Note: SecUploadKeepFiles is currently NOT supported by Coraza
#
#SecUploadKeepFiles RelevantOnly
#SecUploadKeepFiles Off
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching reality here. See #1205


# Uploaded files are by default created with permissions that do not allow
# any other user to access them. You may need to relax that if you want to
# interface Coraza to an external program (e.g., an anti-virus).
# Note: SecUploadFileMode is currently NOT supported by Coraza
Copy link
Member Author

@M4tteoP M4tteoP Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are calling os.CreateTemp(storagePath, "crzmp*") , which is coming with hardcoded 0600. So we are reading this value, not effectively using it.

Comment on lines -141 to -142
# Most logging has not been implemented because it will be replaced with
# advanced rule profiling options
Copy link
Member Author

@M4tteoP M4tteoP Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a pretty old comment. We should maybe revisit all the logs printed in the various levels, but we have some logs for each of them, and I don't think there is some traction for advanced rule profiling options. I would remove these lines and not confuse the user reading them

@@ -153,7 +156,7 @@ SecDataDir /tmp/
SecAuditEngine RelevantOnly
SecAuditLogRelevantStatus "^(?:(5|4)(0|1)[0-9])$"

# Log everything we know about a transaction.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ABIJDEFHZ is not even everything

@M4tteoP M4tteoP marked this pull request as ready for review March 23, 2025 15:09
@M4tteoP M4tteoP requested a review from a team as a code owner March 23, 2025 15:09
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

Successfully merging this pull request may close these issues.

2 participants