store | blogs | forums | twitter | facebook | wiki | mailing lists | downloads | support portal
Atomic Secure Linux
It is currently Sun May 19, 2013 6:25 am

» Feed - Atomicorp

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic Share/Bookmark  [ 14 posts ] 
Author Message
 Post subject: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 7:03 am 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
Hello,

I don't know, whats wrong with my modsecurity installation, but if I try to upload a file to my owncloud installation with the android client, the upload will fail.

If I exclude 00_asl_z_antievasion.conf, it works.

The problem is, that there are no logfile entries wich show what happened. No entry in audit.log...
So I only know, that it must have to do something with 00_asl_z_antievasion.conf.


I'm using
Debian Squeeze
Apache 2.2.16-6+squeeze7
ModSecurity 2.6.3-1
ModSecurity Rules: 201208031104


Do you have any Ideas?

Christian

PS: sorry for my bad English


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 9:21 am 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
I don't know why there is still nothing to see in the log files.
But know I tested it again,the responsible mod security rule is 333791.
If I add "SecRuleRemoveById 333791" to the configuration of the Vhost, it works.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 12:49 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3242
Location: Chantilly, VA
We'd be happy to help. So first, make sure you are running the latest modsecurity, according to what you posted you're running a very old version that has both bugs, and some very big security vulnerabilities.

With that said, rule 333791 does not block anything, it just detects unknown encoding types and configures the WAF to inspect them more closely using other rules. Disabling this rule will open a very huge whole in your system, and you should not disable this rule. This rule does not block anything, and disabling it will make the WAF blind to many attacks.

Are any rules being logged as having been triggered on your system? And do you have modsecurity configured as described on the wiki:

https://www.atomicorp.com/wiki/index.ph ... rity_Rules

And do you have any other rules installed on your system?

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 3:08 pm 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
I have updated modsecurity to 2.6.6-3. Thats the newest debian packet. The normal stable packet is much older and doesn't work well with asl modsecurity rules.

I have updated the asl modsecurity rules to the newest version and I have still the same problem.
Modsecurity itself is configured correctly.

No rules being logged as having been triggered, that is what I don't understand.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 3:09 pm 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
mikeshinn wrote:
And do you have any other rules installed on your system?

No, only asl rules


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 3:31 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3242
Location: Chantilly, VA
2.6.7 is the latest stable, please make sure you are using 2.6.7 which includes some fixes.

OK, so if I understand you correctly, no rules are being triggered in your case, is that correct? Does the test case generate a log message on your system?

https://www.atomicorp.com/wiki/index.ph ... are_loaded

Do you have any rules disabled, or any custom modifications to your rules?

So we just setup owncloud 4.0.6 on a test system, and using the iphone and linux clients uploaded and synced a bunch of docs and photos and didnt have any issues. What exactly are you doing with owncloud?

We'll get the android client setup in a moment to see if it works, but so far owncloud seems to be working fine with the rules out of the box.

In the mean time, can you run a single test on your system with your android client with modsecurity in debug mode (please dont do anything else on the server when you do this, it will generate a lot of data we dont need), and then send us the modsec-debug.log file. Please also send your modsec configuration.

Add these lines to your modsec config to setup debug mode.

SecDebugLog logs/modsec-debug.log
SecDebugLogLevel 9

And then disable these once you are done, debug mode will slow down apache considerably.

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 5:53 pm 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
I built mod security from sources and now I have 2.6.7 but still the same Problem.

The testcase generates the following log entries:

audit.log:
Code:
killerhorse.eu 80.109.93.175 - - [06/Aug/2012:23:49:01 +0200] "GET /foo.php?foo=http://www.example.com HTTP/1.1" 403 239 "-" "-" UCA7zS4EcpwAAB1eOE8AAAAO "-" /20120806/20120806-2349/20120806-234901-UCA7zS4EcpwAAB1eOE8AAAAO 0 1797 md5:ad27092f1e6771d10461116c24ba45a6



./20120806/20120806-2349/20120806-234901-UCA7zS4EcpwAAB1eOE8AAAAO:
Code:
--b6dbb352-A--
[06/Aug/2012:23:49:01 +0200] UCA7zS4EcpwAAB1eOE8AAAAO 80.109.93.175 64018 46.4.114.156 443
--b6dbb352-B--
GET /foo.php?foo=http://www.example.com HTTP/1.1
Host: killerhorse.eu
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0.6) Gecko/20100101 Firefox/10.0.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: cpg15x_data=YTo1OntzOjI6IklEIjtzOjMyOiI5MzQzNGRlZjE3NjY3MDA3YjcyZTlmMWVhYjY4OGQwZCI7czoyOiJhbSI7aToxO3M6NDoibGFuZyI7czo2OiJnZXJtYW4iO3M6MzoibGl2Ijth$
Cache-Control: max-age=0

--b6dbb352-F--
HTTP/1.1 403 Forbidden
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 239
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

--b6dbb352-H--
Message: Access denied with code 403 (phase 2). Match of "rx ://%{SERVER_NAME}/" against "MATCHED_VARS:foo" required. [file "/etc/modsecurity2/rules/10_asl_$
Action: Intercepted (phase 2)
Apache-Handler: application/x-httpd-php
Stopwatch: 1344289741005173 18293 (- - -)
Stopwatch2: 1344289741005173 18293; combined=9498, p1=87, p2=9405, p3=0, p4=0, p5=6, sr=0, sw=0, l=0, gc=0
Producer: ModSecurity for Apache/2.6.7 (http://www.modsecurity.org/).
Server: Apache/2.2.16 (Debian)

--b6dbb352-Z--


I will send you a downloadlink for the debug.log in some Minutes.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 6:28 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3242
Location: Chantilly, VA
So what are you doing with owncloud? We've done file syncs, calendar and contacts from iphones, ipads, linux and windows without any issues. So what are you doing with owncloud?

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 6:55 pm 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
I tested some settings and files to upload and it seems so, that it works to upload very small files.
But it works only if the uploaded file is smaller than SecRequestBodyInMemoryLimit.
If the file is larger, it will be stored in /tmp on the disk but after that nothing seems to happen The upload fails.


My modsecurity config:
Code:
 SecRuleEngine On
 SecRequestBodyAccess On
 SecResponseBodyAccess On
 SecResponseBodyMimeType (null) text/html text/plain text/xml
 SecResponseBodyLimit 2621440
 SecServerSignature Apache
 SecComponentSignature 200911012341
 SecUploadDir /var/asl/data/suspicious
 SecUploadKeepFiles Off
 SecAuditEngine RelevantOnly
 SecAuditLogRelevantStatus "^(?:5|4(?!04))"
 SecAuditLogType Concurrent
 SecAuditLog /etc/modsecurity2/logs/audit.log
 SecAuditLogParts ABIFHZ
 SecArgumentSeparator "&"
 SecCookieFormat 0
 SecRequestBodyInMemoryLimit 131072
 SecDataDir /var/asl/data/msa
 SecTmpDir /tmp
SecAuditLogType  Concurrent
 SecAuditLogStorageDir /etc/modsecurity2/logs/
 SecResponseBodyLimitAction ProcessPartial



here is the debug log file:
https://killerhorse.eu/debug/debug.log

I will send user and password with PM.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 7:07 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3242
Location: Chantilly, VA
Quote:
I tested some settings and files to upload and it seems so, that it works to upload very small files.


I just uploaded a 500MB file myself, with no issues. How big of a file are you trying to upload?

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 7:48 pm 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
Only 1 Mbyte


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 8:36 pm 
Offline
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
User avatar

Joined: Thu Feb 07, 2008 7:49 pm
Posts: 3242
Location: Chantilly, VA
Definitely not able to reproduce that:

/var/www/html/owncloud/data/testuser/files/media

root@server1 media]# ls -alh *
-rw-r--r-- 1 apache apache 1.4M Aug 6 20:11 libjpeg-turbo-1.1.1.src.rpm
-rw-r--r-- 1 apache apache 2.6M Aug 6 20:13 roundcubemail-0.7.2.tar.gz

Uploads over 1MB work just fine on the test box here. Keep in mind that we use apache 2.2.21 on our WAF appliances. With that said, if you arent seeing any rules trigger then this does not sound like its the rules causing this. If one of our rules is triggered, that gets logged, nothing in the logs, none of our rules are doing this. This is especially true if the issue abates when you disable rules, or rulesets that just configure the WAF itself. For example, 333791, which only changes the configuration of the WAF and does not do anything else. Or if you disable the antievasion rules which do the same thing.

Looking at your debug log, this is starting to look like a problem with either how modsecurity is setup or built on your system, which could include an issue with a library, or a possible bug in the version of Apache you are using (or one its libraries). But something is wrong with the environment it seems.

From the debug file, can you confirm thats the entire debug for this event? If so, something is very wrong with your system. It quit during your write, hard, it just stopped cold. Heres what happens on your system:

[07/Aug/2012:00:26:52 +0200] [youbox/sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][4] Input filter: Request too large to store in memory, switching to disk.
[07/Aug/2012:00:26:52 +0200] [yourbox/sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][4] Input filter: Created temporary file to store request body: /tmp/2
0120807-002652-UCBEqi4EcpwAACtBGakAAAAB-request_body-EgHDFh
[07/Aug/2012:00:26:52 +0200] [yourbox/sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][4] Input filter: Wrote 131072 bytes from memory to disk.
[07/Aug/2012:00:26:52 +0200] [yourbox/sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][9] Input filter: Bucket type TRANSIENT contains 2048 bytes.
[More of the same ....]

But then after pushing some of the file, apache just quits:
[07/Aug/2012:00:26:59 +0200] [yourbox/sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][9] Input filter: Bucket type TRANSIENT contains 1508 bytes.
[07/Aug/2012:00:26:59 +0200] [yourbox//sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][9] Input filter: Bucket type EOS contains 0 bytes.

And thats in your log. Which means apache quit, no rules were triggered, apache just stopped processing the thread.

Heres a healthy apache:

[06/Aug/2012:20:26:02 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][4] Input filter: Request too large to store in memory, switching to disk.
[06/Aug/2012:20:26:02 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][4] Input filter: Created temporary file to store request body: /tmp/20120806-202602-UCBgmn8AAAEAAHdvvlcAAAAD-request_body-yFaMpe
[06/Aug/2012:20:26:02 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][4] Input filter: Wrote 131072 bytes from memory to disk.
[06/Aug/2012:20:26:02 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][9] Input filter: Bucket type TRANSIENT contains 8192 bytes.
[More of the same.....]
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][9] Input filter: Bucket type TRANSIENT contains 2166 bytes.
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][9] Multipart: Added file part 2b7faf58e2d0 to the list: name "files[]" file name "snort-2.9.0.5-1.src.rpm" (offset 366, length 5826266)
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][9] Input filter: Bucket type EOS contains 0 bytes.
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][5] Adding request argument (BODY): name "MAX_FILE_SIZE", value "536870912"
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][5] Adding request argument (BODY): name "dir", value "/media"
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][4] Request body no files length: 236
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][4] Input filter: Completed receiving request body (length 5826678).
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][4] Starting phase REQUEST_BODY.
[06/Aug/2012:20:26:03 --0400] [ourhost/sid#2b7fa0dc2768][rid#2b7fabc896a0][/owncloud/][9] This phase consists of 3442 rule(s).

And it continues from there, with rules being processed and the body is inspected. In your case, apache never gets to this, the thread just dies.

If your debug truly did stop here:

[07/Aug/2012:00:26:59 +0200] [yourhost/sid#7fdbb1639ad8][rid#7fdbb42a2580][/owncloud/remote.php/webdav/5.jpg][9] Input filter: Bucket type EOS contains 0 bytes.

Then there may be something more fundamental wrong with your modsecurity setup or build, possibly somethings amiss with apache on your system, or maybe the client just quit (although we would see an error to that effect normally, and I dont see that here), or maybe your modsecurity setup is munged. Check to make sure your rules are valid, and your config is correct. Somethings wrong with your modsecurity setup, modsecurity itself isn't either working with a valid setup or something's wron with tHe build/environment.

Can you confirm that the debug file you posted is the entire debug file?

_________________
Michael Shinn
Atomicorp - Security For Everyone

Co-Author of Troubleshooting Linux Firewalls.


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Mon Aug 06, 2012 9:23 pm 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
Yes it is the entire logfile!
Also the apache logfiles are looking like there is something missing.

Here the access.log:

80.109.93.175 - killerhorse [07/Aug/2012:03:12:21 +0200] "HEAD /owncloud/remote.php/webdav/5.jpg HTTP/1.1" 200 - "-" "Jakarta Commons-HttpClient/3.0"
80.109.93.175 - killerhorse [07/Aug/2012:03:12:21 +0200] "HEAD /owncloud/remote.php/webdav/5%20(2).jpg HTTP/1.1" 404 - "-" "Jakarta Commons-HttpClient/3.0"


I tried the same again with disabled asl Rule ID 333791
by adding this to the vhost:

<LocationMatch /owncloud/remote.php/*>
<IfModule mod_security2.c>
SecRuleRemoveById 333791
</IfModule>
</LocationMatch>


And here the related access.log:
80.109.93.175 - killerhorse [07/Aug/2012:03:16:09 +0200] "HEAD /owncloud/remote.php/webdav/5.jpg HTTP/1.1" 200 - "-" "Jakarta Commons-HttpClient/3.0"
80.109.93.175 - killerhorse [07/Aug/2012:03:16:10 +0200] "HEAD /owncloud/remote.php/webdav/5%20(2).jpg HTTP/1.1" 404 - "-" "Jakarta Commons-HttpClient/3.0"
80.109.93.175 - killerhorse [07/Aug/2012:03:16:10 +0200] "PUT /owncloud/remote.php/webdav/5%20(2).jpg HTTP/1.1" 201 - "-" "Jakarta Commons-HttpClient/3.0"


I don't think that it has something to do with the mod security build, because I tested 3 different builds. An old one from the Debian packages, a newer one and the newest stable built from source. I really don't know whats going wrong, but I think tomorrow I will also test an other Apache version (I will also build it from source).

But why I don't have any problem with other php scripts with the same asl rules, the same modsecurity and the same apache...!?


Top
 Profile  
 
 Post subject: Re: Problem with 00_asl_z_antievasion.conf
Unread postPosted: Tue Aug 07, 2012 5:58 am 
Offline
Forum User
Forum User

Joined: Mon Jun 06, 2011 5:53 am
Posts: 10
Location: Vienna
Hello,

I'm very very sorry. The reason of this Problem was a realy stupid mistake on my part.
There was a Problem in the updatescript for the modsecurity rules (my own script, not yours).
The bigger part of the modsecurity rules were really old.

Thank you for hard try to help me.

Christian


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic Share/Bookmark  [ 14 posts ] 

» Feed - Atomicorp

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group