-
Notifications
You must be signed in to change notification settings - Fork 728
SQLi id:942100, false positive on combination of two chars #794
Comments
Looks to be a libinjection rule. interesting, not quite sure why this is, maybe it wasnt done with other langs in mind. I know modsec's regex engine also has problems with Cyrillic chars just cause of PCRE |
Thank you very much for your report @landergate. This is an upstream problem but very glad you reported. I am going to forward this to the libinjection maintainer asap. |
Wow, very good find. There are three places where this can go wrong: CRS, ModSecurity, or libinjection. At first sight, it seems like a false positive in libinjection. But if I feed this input to libinjection itself, in encoded or decoded form, I am not getting a hit:
So I am not sure it's a libinjection problem. There seems to be something interesting going on in ModSec or CRS. We should narrow the issue first by removing some transformations. |
You suspected correctly, @lifeforms. Here is my reduced rule to trigger this FP:
So it looks like a combination of payload and two transformation leads to an internal value that sets off libinjection. |
lol wat |
Yes, looks a bit simplistic. Bad implementation in ModSec? |
@zimmerle can you shed some light on this problem? I know there are tickets in modsec's repo also can we link them here if they apply? |
Hi @csanders-git, please go ahead and make the links ;) I will also report something here. Most likely I will look into this tomorrow. @ALL Thanks for the report ;) |
Hey guys, it looks like we have a few problems here with this issue. First lets see if ModSecurity is handling these transformations right:
\xd0\xb4\xd0\xbe\xd1\x80 looks correct UTF-8 encoding of дор.
0x0434 = CYRILLIC SMALL LETTER DE (aka "De") This looks right as well. Moving on, there's the SecUnicodeMapFile which t:urlDecodeUni uses to map Unicode for normalization and we have on the recommend modsecurity.conf file which by default points to Code point 20127 US-ASCII mapping. If you simply try to change the code point to 1251 (aka Windows-1251) it still won't work as for some reason these cyrillic characters are missing from the mapping file. But I believe they should be there according to unicode.org. But if you add the missing Unicode characters and their corresponding ASCII codes (0434:64 043e:6f 0440:70) to the code point the rule works fine with the input:
So I think the the transformations are working fine, but I think we need to do some adjustments to the mapping file or come up with a different solution altogether. Interestingly enough looks like that other software that fails to recognize these characters does the same thing as ModSecurity. From Burp: |
owasp-modsecurity/ModSecurity#348 (comment) please see the very thoughtful comment @marcstern left on this other thread. |
Any possible workaround approach at this moment? |
@landergate : This does not look like a quick fix and I think there is no way around disabling the rule for the login parameter for the time being. Of course, if you know the acceptable values that trigger false positives, then you can also disable the rule depending on the value of login. |
Victor has some good analysis on this, if expanding the mapping would solve this then it would be a real constructive solution... I'm not familiar with that part of ModSec myself. Tagging this for 3.1.0 as the problem happen on multiple rules and we need to support our Russian friends! |
I am also facing false positives caused by rule 942100 (running ModSecurity v3/master and CRS 3.1) on post params in greek (utf8). After tracking down a false positive, I came to the conclusion that if an apostrophe (') and a greek question mark (semicolon, ";") appears on the same post argument, the rule triggers. Since the use of those 2 characters is quite common in greek, I would appreciate any suggestions. PS. I have already tried experimenting with different code points in unicode.mapping (started with 1253 greek but also tried 850, since it seems to include more greek unicode characters), but nothing changed. |
Hi @victorhora , in your example you made mapping of the Cyrillic characters on their analogue in the Latin alphabet. E.g.:
Although, for mentioned code page 1251 (extension of the ASCII), correct mapping is:
The question is - do we always need make mapping for non latin symbols to their latin analogue to get working solution? Can you explain? |
Some words about CP1251 mapping. Unicode table contains a special range for Cyrillic characters. This is 0400 - 04FF (https://unicode-table.com/en/blocks/cyrillic/). They are used in many languages, the writing of which is based on them. But as for the Russian language, this range is much narrower: 0410 - 044F and two characters outside this range are 0401 (letter "Ё") and 0451 (small letter "ё").
Using this mapping for payload with russian characters will not lead to a false positive in example with "Игорь". But code page 1251 also contains characters of the Ukrainian, Bulgarian and Belarusian alphabets. Such as ї, Ї, і, І and so on (see http://ascii-table.com/codepage.php?1251). They also need to be added to the mapping. |
What to do for this false positive from ModSecurity? |
@jibz08 That's an issue unrelated to this thread. Generally you want to exclude a password field from CRS checking. This is normally done by adding to your ModSec config a rule like:
|
Thanks @lifeforms ,it helped . |
This issue has been open 120 days with no activity. Remove the stale label or comment, or this will be closed in 14 days |
Decision during the CRS project chat on March 2, 2020: @dune73 will get in touch with the libinjection project to try and get things moving again. |
Any thought on why two cyrillic symbols "ор" could trigger this rule?
It happens in different conditions near other symbols, but could not happen at all with other symbols.
And what would be the best approach without omitting rules at all?
login=Игорь
It's a legit cyrillic first name, pronounced as "Igor".
login=дор
Just experimenting with "ор" combination.
login=ббббббор
login=Симафор
The text was updated successfully, but these errors were encountered: