-
Notifications
You must be signed in to change notification settings - Fork 728
Conversation
the regression test fails:/ I'll try to understand why asap. |
Good start @theMiddleBlue , could you also add at least urldecode :) |
thanks @spartantri you're right, I'm adding it. I'm trying to replicate what travis does with regressions, I'll update this PR after a rebase |
could you also add don't you prefer to lowercase everything? and use can we rename this to xml-attacks instead of xxe? so we can address entity expansion as well |
Here is a link to sample payload of entity expansion |
done, thanks!
I don't know if lowercase
totally agree! thank you! |
(any suggestion on why the travis regression test fails?) |
ok, I managed to make it works. It seems that it was related to the content-type I'm changing it with |
Nice contribution. Thank you. Obviously there are several small issues, but you are heading in a good direction here. I think we need to test this extensively before we include it, but it looks very interesting. Detection regexModSec recommended rules detects XML with the following regex:
NumberingPlease start the real rules of the new group at 9xx100. Separate fileWhat is the opinion of the other project members about the new and separate rule file. It might fit into 921 too, would not it? Switch on and off945000 should be handled in the crs-setup.conf. PL tags945110 and 945120 are tagged as PL1. |
thanks @dune73, I've added some fixes based on your comment. I take some time to define better 945000 and put it in crs-setup.conf. I also want to make regression test works using |
I've put this on hold because, unfortunately, I've realized only now that it won't work on v2 (I've always tested it on v3). The problem is that, with the XML Processor, the REQUEST_BODY variable doesn't exist and we can't copy it to something like |
referring to a conversation on the slack channel, unfortunately, I can confirm that the "missing REQUEST_BODY variable" with XML and JSON body processor could lead to many WAF evasion especially with XXE. basically, the problem is that the ModSecurity rule 200000 in phase:1 set the body processor to XML if the content-type match I've got a working PoC for that, this works only on v2 and not on v3 (just because a bug :D but the good news is that @airween is working on a patch): a vulnerable PHP script <?php
$data = file_get_contents('php://input');
$xml = simplexml_load_string($data);
echo $xml->name; this is just an example of an app that doesn't care about content-type. XXE payload
PoC 1: blockedenv: Apache + modsec v2 + this XML attack ruleset sending the request with content-type blocked by:
PoC 2: bypassenv: Apache + modsec v2 + this XML attack ruleset sending the request with content-type bypass all rules:
the good news is that @airween is working on a patch that makes REQUEST_BODY available even if the bodyprocessor is set to XML. I've just tested it with him, and it works! |
as discussed during the CRS meeting, I'm closing this until we reach a solution with ModSecurity v2 and libmodsecurity (v3). |
just to keep track of interesting article about XXE (hoping we'll have a rule set to cover this attack): |
A Deep Dive into XXE Injection: |
Is there any more progress made on this? :) |
Unfortunately not. Working with the ModSecurity developers is taking a lot of time. Not sure about the status of the patch by @airween, though. |
I think we need to align this subset for v2. The behavior of v3 from the point of REQUEST_BODY handling is wrong, see 2045 and 2146 issues under ModSecurity. May be the 3.1 will contains the fix, but I don't know about anything. The patch what I made is just a workaround, and it aligned the v3 to v2, so if the ModSecurity would contains that, this ruleset (945) in this format wouldn't work with v3 too. I think we need to reform this subset that the engine uses the REQUEST_BODY. See the reference: The forceRequestBodyVariable option allows you to configure the REQUEST_BODY variable to be set when there is no request body processor configured. This allows for inspection of request bodies of unknown types. But I'm not sure that this will works - don't know how can we turn on the REQUEST_BODY variable when CT is |
related to #1319 this PR adds a new rule file for XXE attacks. This file adds 2 rules in PL1, 1 rule in PL2 and 1 rule in PL3:
I'm trying to define something like this:
SYSTEM
orPUBLIC
to exploit a LFI/RFI<!ENTITY
tag usingSYSTEM
orPUBLIC
<!ENTITY
in the bodyIt would be nice If someone can run and check all regression tests. Any help/comments is really appreciated.
thanks!