Skip to content

fix(942200): False Positive#4236

Closed
Xhoenix wants to merge 5 commits into
coreruleset:mainfrom
Xhoenix:fix-fp-942200
Closed

fix(942200): False Positive#4236
Xhoenix wants to merge 5 commits into
coreruleset:mainfrom
Xhoenix:fix-fp-942200

Conversation

@Xhoenix

@Xhoenix Xhoenix commented Aug 11, 2025

Copy link
Copy Markdown
Member

@Xhoenix
Xhoenix requested a review from a team August 11, 2025 11:02
@github-actions

github-actions Bot commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

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

Comment thread regex-assembly/942200.ra Outdated

##! Helpers
##!> define punctuation-hexnumbers ,.*?[)\da-f\"'`]
##!> define punctuation-hexnumbers ,\S*?[)\da-f\"'`]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think that's correct. I'm pretty sure spaces after the comma are possible.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought so. What do you think is a better solution for this? I suggest moving this to PL2 until a fix is found.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to properly analyse what punctuation-hexnumbers is supposed to match. It looks like something like select a, b '... but I don't understand the role of the hexadecimal and parenthesis. The a-f doesn't even make much sense, since hexadecimals must be preceded by either X' or 0x in MySQL. I have the feeling that we might be able to split up the character class into a more restrictive sequence, which would fix the issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If you check the regex, all of the below statements are exact matches.

SELECT * FROM users WHERE name = 'admin', --


SELECT * FROM users WHERE username = 'admin', '1'='1'


INSERT INTO logs (ip, comment) VALUES ('192.168.0.1', 'test')


SELECT * FROM data WHERE hash = 'abc', 0x1a


SELECT * FROM orders WHERE product = 'item', (5)

The fourth statement above provides a hexadecimal syntax usage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. So the main issue appears to be that the regex doesn't match quotes. We could expand the regex with three additional expressions that match every type of quote, e.g.,

...'[^']*'...|..."[^"]*"...|...`[^`]*`...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Making quotes optional would lead to the same FP as above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, I mean matching quote pairs. To do that, you need one expression per quote type. Currently, punctuation-hexnumbers is paired with ticks but that doesn't work as it's supposed to, I believe. punctuation-hexnumbers may not have match a quote, but a letter, so ticks will not match a closing quote but an opening one. If we matched quote pairs, we could reduce FPs. Although it's common enough in french to have a name with more than one quote, e.g., rue d'Arlon sur l'avon, so that would still remain an FP.

Honestly, I think the regex is just too generic. It's combined with detection for SQL keywords, which doesn't make much sense. The quote detection stuff is clearly more prone to FPs and should live in a separate rule. Could you modify the PR to split the rule into two distinct rules? That will also make it easier to test different detections.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That makes sense, separating based on quote pairs will surely reduce FP, since the phrase like rue d'Arlon uses single quotes.

@Xhoenix Xhoenix Sep 1, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed the issue. Actually the regex was wrong, and we were matching {{ticks}} after {{ticks}} which is not correct.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't agree with your latest change, but I'll need some time to look into it properly.

@Xhoenix
Xhoenix requested a review from theseion August 28, 2025 06:55
@Xhoenix
Xhoenix requested a review from a team September 1, 2025 11:35
@Xhoenix
Xhoenix requested review from a team and removed request for a team September 17, 2025 09:24
@github-actions github-actions Bot added the Stale label Oct 19, 2025
@github-actions github-actions Bot closed this Nov 3, 2025
@Xhoenix Xhoenix reopened this Nov 3, 2025
@github-actions github-actions Bot removed the Stale label Nov 4, 2025
@github-actions github-actions Bot added the Stale label Dec 4, 2025
@github-actions github-actions Bot closed this Dec 19, 2025
@Xhoenix Xhoenix reopened this Dec 19, 2025
@github-actions github-actions Bot removed the Stale label Dec 20, 2025
@github-actions github-actions Bot added the Stale label Jan 19, 2026
@EsadCetiner EsadCetiner removed the Stale label Jan 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts the SQL injection detection regex for rule 942200 to eliminate a specific false positive on valid postal addresses, and adds regression coverage to guard against regressions.

Changes:

  • Updated the assembled regex for rule 942200 (regex-assembly/942200.ra) to change the trailing alternatives so that a comma+quote pattern must be followed by either a closing parenthesis, end-of-input, or a balanced closing quote/backtick, reducing false positives like 999, rue d'Arlon.
  • Regenerated/synchronized the concrete ModSecurity rule in rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf from the updated regex assembly so the deployed rule reflects the new behavior.
  • Extended regression tests for rule 942200: tweaked the header-based positive test and added a new negative test to assert that the address=999, rue d'Arlon case no longer triggers rule 942200.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
tests/regression/tests/REQUEST-942-APPLICATION-ATTACK-SQLI/942200.yaml Adjusts existing positive header test and adds a new negative test reproducing Issue #3838 to ensure rule 942200 no longer fires on a valid postal address string.
rules/REQUEST-942-APPLICATION-ATTACK-SQLI.conf Updates the compiled regex for rule 942200 to incorporate the refined comma+quote/backtick pattern, aiming to avoid the documented false positive while keeping the rest of the detection intact.
regex-assembly/942200.ra Modifies the regex assembly for 942200 so that the generated pattern requires either a closing parenthesis, end-of-line, or a trailing quote/backtick after non-quote characters, bringing the rule’s behavior in line with the intended fix.

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

theseion added a commit to theseion/coreruleset that referenced this pull request Feb 22, 2026
- Fixes FPs against French addresses, such as `999, rue d'Arlon`
- Additional tests and enhanced regex

Fixes coreruleset#4236
@theseion

Copy link
Copy Markdown
Contributor

Closed in favor of #4476

@theseion theseion closed this Feb 22, 2026
theseion added a commit to theseion/coreruleset that referenced this pull request Feb 22, 2026
- Fixes FPs against French addresses, such as `999, rue d'Arlon`
- Additional tests and enhanced regex

Fixes coreruleset#3838
Replaces coreruleset#4236
@Xhoenix
Xhoenix deleted the fix-fp-942200 branch February 22, 2026 19:20
github-merge-queue Bot pushed a commit that referenced this pull request Feb 28, 2026
…4476)

* fix(942200): FP against comma and single quote in French addresses

- Fixes FPs against French addresses, such as `999, rue d'Arlon`
- Additional tests and enhanced regex

Fixes #3838
Replaces #4236

* Update regex-assembly/942200.ra

---------

Co-authored-by: Felipe Zipitría <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive with rule 942200 and valid postal address

5 participants