PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Apache2 und mod_security



cpreisinger
12.10.06, 22:59
Hallo zusammen,

auf meinem Suse 10.1 System mit Apache2 habe ich das mod_security installiert.
Nun habe ich das Problem dass er sämtliche .htaccess Dateien übergeht die ich vorher angelegt habe! Was muss ich in die modsecurity.conf eintragen, damit dies wieder geht !?

Auf einem alten Suse 9.0 Server habe ich auch auf den Apache2 das mod_security installiert. Dort habe ich auf einmal keinen Zugriff mehr auf das Visas (Virtual Server Admin Interface) auf welches über https://servername.net:22222 zugegriffen wird.
Das Log unter /var/log/apache2/error.log bringt keine Auskunft, sehe dort auch keine Meldungen bezüglich mod_security wenn ich versuche auf das Visas zuzugreifen... Alle vorhandenen VHOSTS gehen aber noch...

Google und modsecurity.org manual bringen mich net weiter ... :(
Woher kommt dieses Problem und wie bekomme ich das in den Griff ?

Vielen Dank schonmal und Grüße,
cpreisinger

marce
13.10.06, 06:10
interessant wäre, was denn nun eingetragen ist, was Du geändert hast - halt einfach mal die Config des Webservers...

Ansonsten können wir leider nur dumm im Nebel herumstochern...

cpreisinger
13.10.06, 10:56
Hallo marce,

hier die gewünschten Dateien:

Suse 10.1 HTTPD.conf:


### Global Environment ################################################## ####
Include /etc/apache2/uid.conf
Include /etc/apache2/server-tuning.conf
ErrorLog /var/log/apache2/error_log
Include /etc/apache2/sysconfig.d/loadmodule.conf
Include /etc/apache2/listen.conf
Include /etc/apache2/mod_log_config.conf
Include /etc/apache2/sysconfig.d/global.conf
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf
Include /etc/apache2/mod_usertrack.conf
Include /etc/apache2/mod_autoindex-defaults.conf
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf
Include /etc/apache2/errors.conf
Include /etc/apache2/ssl-global.conf
# forbid access to the entire filesystem by default
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>
# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
# List of resources to look for when the client requests a directory
DirectoryIndex index.html index.html.var

### 'Main' server configuration #############################################
Include /etc/apache2/default-server.conf
Include /etc/apache2/sysconfig.d/include.conf
# Security Module
#
LoadModule security_module /usr/lib64/apache2-prefork/mod_security.so
Include /etc/apache2/modsecurity.conf

### Virtual server configuration ############################################
Include /etc/apache2/vhosts.d/*.conf


Die Suse 9.0 httpd.conf


### Global Environment ################################################## ####
Include /etc/apache2/uid.conf
Include /etc/apache2/server-tuning.conf
ErrorLog /var/log/apache2/error_log
Include /etc/apache2/sysconfig.d/loadmodule.conf
Include /etc/apache2/listen.conf
Include /etc/apache2/mod_log_config.conf
Include /etc/apache2/sysconfig.d/global.conf
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf
Include /etc/apache2/mod_autoindex-defaults.conf
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf
Include /etc/apache2/errors.conf
Include /etc/apache2/ssl-global.conf
# forbid access to the entire filesystem by default
#<Directory />
#Options None
#AllowOverride None
#Order deny,allow
#Deny from all
#</Directory>
<Directory />
Options -Indexes +FollowSymLinks +Includes
AllowOverride All
</Directory>

# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>

# List of resources to look for when the client requests a directory
DirectoryIndex index.html index.html.var

### 'Main' server configuration #############################################

Include /etc/apache2/default-server.conf

<IfModule mod_suphp.c>
suPHP_Engine on
php_admin_flag engine off
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
AddHandler x-httpd-php .php
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.php4
</IfModule>


Include /etc/apache2/sysconfig.d/include.conf
# Security Module (this is mod_security)
#
LoadModule security_module /usr/lib/apache2-prefork/mod_security.so
Include /etc/apache2/modsecurity.conf
#

### Virtual server configuration ############################################
Include /etc/apache2/vhosts.d/*.conf


<VirtualHost _default_:443>
DocumentRoot /usr/local/visas/public_html/
ServerName x.y.net
ServerAlias www.x.y.net
php_admin_value open_basedir /usr/local/visas/public_html/ssl/
php_admin_value engine off
IndexOptions
DirectoryIndex index.htm index.html index.shtml start.htm start.html start.shtml index.php index.php3
SSLEngine on
SSLCertificateFile /etc/apache2/ssl.crt/server.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/server.key
Redirectpermanent /adminlevel https://x.y.net:22222/adminlevel
Redirectpermanent /domainadminlevel https://x.y.net:22222/domainadminlevel
Redirectpermanent /serveradminlevel https://x.y.net:22222/serveradminlevel
Redirectpermanent /mail https://x.y.net:22222/webmail
Redirectpermanent /webmail https://x.y.net:22222/webmail
Redirectpermanent /support https://x.y.net:22222/support
Redirectpermanent /mysql https://x.y.net:22222/mysql
</VirtualHost>


Der VHOST Eintrag ist der vom VISAS System.
Die anderen vhosts gehen alle...
Wenn ich hier auf https://www.servername.de gehe, dann seh ich die Visas Startseite, klicke ich dann auf einen der Links, die mich auf eine andere Seite verweisen (Port 22222), dann sehe ich immer nur "Seite nicht gefunden"...

Und hier die modsecurity.conf, welche bei beiden Systemen gleich ist:


SecFilterEngine On
SecFilterDefaultAction "deny,log,status:403"
SecFilterScanPOST On
SecFilterCheckURLEncoding On
SecFilterCheckUnicodeEncoding Off
SecFilterForceByteRange 1 255
SecServerSignature " "
SecUploadDir /tmp
SecUploadKeepFiles Off
SecAuditEngine RelevantOnly
SecAuditLog /var/log/apache2/security/audit_log
SecFilterDebugLevel 0
SecFilterDebugLog /var/log/apache2/security/modsec_debug_log
SecFilterSelective REQUEST_METHOD "!^(GET|HEAD)$" chain
SecFilterSelective HTTP_Content-Type "!(^application/x-www-form-urlencoded$|^multipart/form-data;)"
SecFilterSelective REQUEST_METHOD "^(GET|HEAD)$" chain
SecFilterSelective HTTP_Content-Length "!^$"
SecFilterSelective REQUEST_METHOD "^POST$" chain
SecFilterSelective HTTP_Content-Length "^$"
SecFilterSelective HTTP_Transfer-Encoding "!^$"
SecFilter /bin/sh
SecFilterSelective "QUERY_STRING" "bin/(ba|a|z|c|k)?sh"
SecFilterSelective "QUERY_STRING" "bin/(kill|ls|passwd|perl|chmod|wget|lynx|links|net(sta t|cat)|who|whoami|id|cd|ld)"
SecFilterSelective ARGS "wget\x20"
SecFilterSelective ARGS "<[[:space:]]*script"
SecFilterSelective ARG_highlight "%27"


Ich bin am Verzweifeln... :( Normaler Betrieb des Webservers geht, nur Administration des Servers nimmer ...

Geändert hab ich an den Config nix, ausser dass ich bei den httpd.confs eben die 2 Zeilen für die Modsecurity eingebaut habe ...

marce
13.10.06, 11:24
was steht denn in
SecFilterDebugLog /var/log/apache2/security/modsec_debug_log?

cpreisinger
13.10.06, 11:33
Die Files sind immo leer. Grund: Debug von modsecurity.conf war auf 0 gestellt. *Ohrfeig*
Gleich aktiviert. Poste später was rauskommt aus Logs...

cpreisinger
14.10.06, 18:15
Hier der Auzug seit gestern vom Suse 9.0 Server:


cat modsec_debug_log
[13/Oct/2006:17:11:08 +0200] [www.vhost3.org/sid#81a7e88][rid#842c2e8][/vhost3/administrator/components/com_remository/admin.remository.php][1] Access denied with code 403. Pattern match "wget\\x20" at QUERY_STRING [severity "EMERGENCY"]
[13/Oct/2006:21:28:07 +0200] [www.vhost7.de/sid#81b0ef8][rid#843e330][/][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[13/Oct/2006:21:28:10 +0200] [www.vhost7.de/sid#81b0ef8][rid#84262d0][/vhost7/downloads/ua/0617_UHON_Musterbrief.rtf][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[13/Oct/2006:21:28:10 +0200] [www.vhost7.de/sid#81b0ef8][rid#8434358][/vhost7/downloads/ua][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[13/Oct/2006:21:28:10 +0200] [www.vhost7.de/sid#81b0ef8][rid#8434308][/vhost7/downloads][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[13/Oct/2006:21:28:10 +0200] [www.vhost7.de/sid#81b0ef8][rid#84262d0][/vhost7][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[13/Oct/2006:21:28:13 +0200] [www.vhost7.de/sid#81b0ef8][rid#84262d0][/][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:01:18:35 +0200] [www.vhost3.org/sid#81a7e88][rid#842c2e8][/][1] Access denied with code 403. Pattern match "!^$" at HEADER("Content-Length") [severity "EMERGENCY"]
[14/Oct/2006:02:07:01 +0200] [www.vhost3.org/sid#81a7e88][rid#843e3c8][/vhost3/pdf][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:02:07:02 +0200] [www.vhost3.org/sid#81a7e88][rid#842c2e8][/_vti_inf.html][1] Access denied with code 403. Pattern match "!^$" at HEADER("Content-Length") [severity "EMERGENCY"]
[14/Oct/2006:02:07:03 +0200] [www.vhost3.org/sid#81a7e88][rid#8432300][/vhost3/pdf/La Jornada_16Oct05.doc][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:02:07:04 +0200] [www.vhost3.org/sid#81a7e88][rid#84302f8][/vhost3/pdf][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:02:07:22 +0200] [www.vhost3.org/sid#81a7e88][rid#842a2e0][/vhost3][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:02:07:23 +0200] [www.vhost3.org/sid#81a7e88][rid#8441490][/vhost3][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:02:07:23 +0200] [www.vhost3.org/sid#81a7e88][rid#84282d8][/][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:11:52:23 +0200] [www.vhost7.de/sid#81b0ef8][rid#84262d0][/vhost7][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:11:52:23 +0200] [www.vhost7.de/sid#81b0ef8][rid#84282d8][/vhost7][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]
[14/Oct/2006:11:52:24 +0200] [www.vhost7.de/sid#81b0ef8][rid#84282d8][/][1] Access denied with code 403. Pattern match "!(^application/x-www-form-urlencoded$|^multipart/form-data;)" at HEADER("Content-Type") [severity "EMERGENCY"]


Trotz mehrfacher Aufrufe der VISAS Seite seh ich hier nix im Logfile ...
Mittlerweilt weiss ich, dass VISAS auch Server Admin 24 genannt wird und von Strato is und es dafür keinen Support gibt ... :(

Hier hab ich noch ein http.visas gefunden unter /etc/apache2:


PidFile /var/run/visas.pid

User vpopmail
Group visas

Include /etc/apache2/server-tuning.conf
ErrorLog /var/log/apache2/error_log
Include /etc/apache2/sysconfig.d/loadmodule.conf
Listen 22222
Include /etc/apache2/mod_log_config.conf
Include /etc/apache2/sysconfig.d/global.conf
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf
Include /etc/apache2/mod_autoindex-defaults.conf
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf
Include /etc/apache2/errors.conf
# global (server-wide) SSL configuration, that is not specific to
# any virtual host
<IfDefine SSL>
<IfDefine !NOSSL>
<IfModule mod_ssl.c>
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin
SSLSessionCache shmcb:/var/lib/apache2/ssl_scache_visas SSLSessionCacheTimeout 600
SSLMutex sem
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
</IfDefine>
</IfDefine>
# forbid access to the entire filesystem by default
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>

# use .htaccess files for overriding,
AccessFileName .htaccess
# and never show them
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
DirectoryIndex index.html index.html.var
Include /etc/apache2/default-server.conf
Include /etc/apache2/sysconfig.d/include.conf

<VirtualHost _default_>
DocumentRoot /usr/local/visas/public_html/
php_admin_value safe_mode Off
php_admin_value session.save_path /usr/local/visas/sessions/
php_admin_value register_globals On
ServerName server.domain.de
IndexOptions
DirectoryIndex index.htm index.html index.shtml start.htm start.html start.shtml index.php index.php3
ScriptAlias /cgi-bin/ /usr/local/visas/public_html/cgi-bin/

SSLEngine on
SSLCertificateFile /etc/httpd/ssl.crt/server.crt
SSLCertificateKeyFile /etc/httpd/ssl.key/server.key

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+SSLv2:+EXP:+eNUL L
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/usr/local/apache/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>

Muss ich hier nur den Port umbasteln auf 443 und schon läuft des Teil wieder oder wie seh ich das ???:eek:

cpreisinger
14.10.06, 23:51
Ok, aktueller Zwischenstand:

VISAS hab ich wieder hingebogen bekommen. :cool: Zwar nimmer auf Port 22222 aber dafür läufts jetzt. Mod_security mag anscheinend keine Redirects.

Trotzdem habe ich immer noch das Problem mit der .htaccess Datei auf dem Suse 10.1 Server :(. Hat noch jemand einen Tipp für mich?

marce
15.10.06, 00:30
Poste mal eine der problematischen .htaccess-Files.

Ansonsten - gehen die 100%, wenn mod_sec nicht eingebunden ist?

Mal Stück für Stück die Regeln rausnehmen und schauen, wann es wieder geht...

cpreisinger
20.10.06, 11:02
Hi Marce,

tut mir Leid dass es etwas länger gedauert hat...
Wenn ich den mod_security abschalte, dann tun die .htaccess Dateien jetzt auch nimmer ...:eek:


AuthType Basic
AuthName "Restricted - Auth Users only"
AuthUserFile /srv/www/htdocs/mailconfig/.htusers
Require valid-user

Angelegt habe ich die Dateien nach dem How-To des Forums. Getan haben sie mal!:confused:

LG,
cpreisinger

marce
20.10.06, 11:11
Sind die Dateien kopiert worden oder neu erstellen? Speziell die .htusers?

Ansonsten sehe ich gerade oben in der 10er Konfig noch ein AllowOverride none - ist das noch so drin und wenn ja, wird irgendwo ein AllowOverride AuthConfig gesetzt?

cpreisinger
20.10.06, 15:05
Die Dateien wurden neu erstellt und NICHT kopiert.

Die Config ist noch original und unangetastet ... Ein Override AuthCOnfig wurde nirgends gesetzt meines wissens ...
Wenn dies der Fehler sein soll, warum haben sie dann vorher getan?:(

gruß