Skip to content

feat: resolve common false positives with ad and tracker cookies#4378

Merged
EsadCetiner merged 10 commits into
coreruleset:mainfrom
EsadCetiner:fix-common-cookie-fp
Jan 22, 2026
Merged

feat: resolve common false positives with ad and tracker cookies#4378
EsadCetiner merged 10 commits into
coreruleset:mainfrom
EsadCetiner:fix-common-cookie-fp

Conversation

@EsadCetiner
Copy link
Copy Markdown
Member

@EsadCetiner EsadCetiner commented Dec 9, 2025

Proposed changes

This PR resolves false positives with the new Google tracking cookies and a few other common tracking/ad cookies. I've moved the existing cookie exceptions to it's own file REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf to improve the overall maintainability of these exceptions. The 999 in the filename is to ensure that the file is loaded after all the request rules have been created.

closes #4370

supersedes: #4293

PR Checklist

  • I have read the CONTRIBUTING doc
  • I have added positive tests proving my fix/feature works as intended.
  • I have added negative tests that prove my fix/feature considers common cases that might end in false positives
  • In case you changed a regular expression, you are not adding a ReDOS for pcre. You can check this using regexploit
  • My test use the comment field to write the expected behavior
  • I have added documentation for the rule or change (when appropriate)

Further comments

For the reviewer

  • Positive and negative tests were added
  • Tests cover the intended fix/feature properly
  • No usage of dangerous constructs like ctl:requestBodyAccess=Off were used in the rule
  • In case a regular expression was changed, there is no ReDOS
  • Documentation is clear for the rule/change

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 9, 2025

📊 Quantitative test results for language: eng, year: 2023, size: 10K, paranoia level: 1:
🚀 Quantitative testing did not detect new false positives

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Jan 18, 2026

@EsadCetiner CRS provides the file RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example for people to modify by copying it as RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf. This will overwrite any files that people might have, so it is a bad choice.

@EsadCetiner
Copy link
Copy Markdown
Member Author

@fzipi I'm confused, how will REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf conflict with RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example? They are different files.

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Jan 19, 2026

Ugh, I'm sorry. Read it twice, and couldn't separate the two names apart 🤦 .

Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf
@fzipi
Copy link
Copy Markdown
Member

fzipi commented Jan 20, 2026

Do we plan to have tests?

Co-authored-by: Felipe Zipitría <3012076+fzipi@users.noreply.github.com>
@EsadCetiner
Copy link
Copy Markdown
Member Author

@fzipi I don't have any tests for the Matomo cookie since I don't use it, I'll add tests for the others.

@EsadCetiner
Copy link
Copy Markdown
Member Author

@fzipi Added tests

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Jan 21, 2026

We should add a new linting rule that prevents adding exceptions to request cookies in SecRules. I'll create a followup in the crs-linter repo.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new dedicated file for common cookie exceptions to address false positives with tracking and advertising cookies, particularly Google's newer tracking cookies and other widely-used ad/tracking services. The change improves maintainability by consolidating cookie exceptions that were previously inline in rule files.

Changes:

  • Created new file REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf containing exceptions for common tracking/ad cookies (Google Analytics, Google Ads, Microsoft Clarity, Prebid.js, AWS Load Balancer, and Matomo)
  • Removed inline !REQUEST_COOKIES:/_pk_ref/ exceptions from SQLi and XSS rule files, moving them to the new centralized file
  • Added comprehensive test suite with 10 test cases covering all new cookie exceptions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf New file containing centralized cookie exceptions for common tracking/advertising cookies with the 999 prefix ensuring it loads after request rules
rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf Removed inline !REQUEST_COOKIES:/_pk_ref/ exceptions from multiple SQLi detection rules (942380, 942390, 942400, 942410, 942420, 942421, 942440, 942450, 942470, 942480)
rules/REQUEST-941-APPLICATION-ATTACK-XSS.conf Removed inline !REQUEST_COOKIES:/_pk_ref/ exceptions from XSS detection rules (941320, 941330, 941340)
tests/regression/tests/REQUEST-999-COMMON-EXCEPTIONS-AFTER/999999.yml Added test suite verifying that legitimate tracking/ad cookies do not trigger WAF rules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread tests/regression/tests/REQUEST-999-COMMON-EXCEPTIONS-AFTER/999999.yml Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
Comment thread rules/REQUEST-999-COMMON-EXCEPTIONS-AFTER.conf Outdated
EsadCetiner and others added 3 commits January 22, 2026 10:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Member

@fzipi fzipi left a comment

Choose a reason for hiding this comment

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

I think this is in good shape now.

@EsadCetiner EsadCetiner added this pull request to the merge queue Jan 22, 2026
Merged via the queue into coreruleset:main with commit e4d3374 Jan 22, 2026
9 of 10 checks passed
@EsadCetiner EsadCetiner deleted the fix-common-cookie-fp branch January 22, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:fix release:new-feature This PR introduces a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Excessive false positives in rules 941100, 942290, 942550 for advertising/tracking cookies

3 participants