Projekt

Allgemein

Profil

R & B kivitendo Konfiguration Apache 2.4 ubuntu 14.4

Von Jan Büren vor mehr als 8 Jahren hinzugefügt

Bedingungen:

- kivitendo ist nur über https erreichbar.
- kivitendo wird nur mit fcgi betrieben
- https ist mit Stand 2014 zusätzlich gesichert konfiguriert
- Basic Authentice wird global noch als Sicherheitsschritt vor die Installation gesetzt
- Wörterbuch-Attacken (ssh und https) werden mit fail2ban behindert

Hier die entsprechende Apache2 (virtual host mit SSL) Konfiguration:

                SSLProtocol All -SSLv2 -SSLv3
                SSLHonorCipherOrder on
                SSLCompression off
                SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS" 

                AddHandler fcgid-script .fpl
                AliasMatch ^/kivitendo-erp/[^/]+\.pl /usr/local/src/kivitendo-erp/dispatcher.fpl
                Alias       /kivitendo-erp/          /usr/local/src/kivitendo-erp/
                FcgidMaxRequestLen 10485760
               <Directory /usr/local/src/kivitendo-erp>
                  AllowOverride All
                  Options ExecCGI Includes FollowSymlinks
                  Require all granted
                </Directory>

                <DirectoryMatch /usr/local/src/kivitendo-erp/users>
                  Order Deny,Allow
                  Deny from All
                </DirectoryMatch>

                <Location "/kivitendo-erp">
                        AuthUserFile /etc/htaccess
                        AuthName "Please authenticate" 
                        AuthType Basic
                        Require valid-user
                </Location>

Port 80, erst gar nicht anbieten (ports.conf):


# Listen 80

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

Hier die fail2ban (jail.conf) Konfiguration:


[apache]

enabled  = true
port     = http,https
filter   = apache-auth
logpath  = /var/log/apache*/*error.log
maxretry = 3

[ssh]

enabled  = true
port     = 4222
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 3

Das reicht leider noch nicht. Wenn man (sehr bequem) ein selbst-signiertes Zertifikat von debian / ubuntu verwendet, muss hier noch der Signatur-Algorithmus angepasst werden.
Ungefähr in Zeile 100 hab ich wie folgt in /usr/sbin/make-ssl-cert ergänzt:

 openssl req -config $TMPFILE -x509 -days 3650 -sha256 -newkey rsa:2048 -nodes

Damit ist man dann mit allen Paranoias für September 2015 auf der sicheren Seite.
Zusätzlich nutzen wir noch unattended-upgrades damit Sicherheitsupdates automatisch passieren und vertrauen hier der Ubuntu-Community.

Die Einstellungen kann man dann noch Gegentesten, bspw. mittels solcher Dienstleister [https://www.ssllabs.com/ssltest/]
Das Ergebnis sieht (für den heutigen Test) dann so aus:
SSL-Test


Antworten (3)

RE: R & B kivitendo Konfiguration Apache 2.4 ubuntu 14.4 - Von Jan Büren vor mehr als 8 Jahren hinzugefügt

Wer feste IP-Adresse hat, sollte diese zusätzlich noch mittels hosts.allow und hosts.deny blocken, bzw. erlauben.
Ich hatte zumindestens erstmal keine Lust mehr auf solche Anklopf-Versuche auf ssh-Ebene:

Sep 23 16:51:23 brasil sshd[5274]: warning: /etc/hosts.allow, line 15: can't verify hostname: getaddrinfo(252.117.76.201.getecnet.com.br, AF_INET) failed
Sep 23 16:51:23 brasil sshd[5274]: refused connect from 201.76.117.252 (201.76.117.252)

Klar, die IP-Adresse kann man auch fälschen, aber es wird dann schon langsam lästig für einen automatisierten Angreifer.

hosts.deny:

sshd: ALL

hosts.allow:

sshd: 2.3.4.  # alle ips aus dem 2.3.4er Netz erlauben

RE: R & B kivitendo Konfiguration Apache 2.4 ubuntu 14.4 - Von Jan Büren vor mehr als 8 Jahren hinzugefügt

.... und die default index.html auch ins nirvana schicken:

                DocumentRoot /var/www/nirvana

RE: R & B kivitendo Konfiguration Apache 2.4 ubuntu 14.4 - Von Jan Büren vor 10 Monaten hinzugefügt

Der Eintrag ist jetzt mittlerweile 8 Jahre alt, an der Aktualität des Themas hat sich allerdings nichts geändert, eher im Gegenteil.

Deshalb ein Update von unserer aktuellen Konfiguration unter ubuntu 22.04

Hinzugekommen ist eine Sperre mittels fail2ban über die generelle Basic Auth Authentifizierung.

Damit ist schon mal das Meiste an automatisierten Angriffen entkräften ohne das man die Anwender mit einer 2-Faktor Authorisierung bedrängen muss.

Installation unter ubuntu/debian

sudo apt install fail2ban
sudo vim /etc/fail2ban/jail.d/kivitendo.conf
[apache-auth]
enabled = true
port = http,https
logpath = %(apache_error_log)s
maxretry = 3
bantime = 86400
findtime = 43200

Wer möchte kann die fehlerhaften Anfragen auch noch an abuseipdb verpetzen, dies benötigt allerdings einen entsprechenden kostenpflichtigen Account dort:

# Ban IP and report to AbuseIPDB for WebApp BruteForce
action = %(action_)s
%(action_abuseipdb)s[abuseipdb_apikey="mein eigener schlüssel", abuseipdb_category="18,21"]

Die entsprechend aktuelle SSL-Konfig im Apache2 dazu:

vim /etc/apache2/sites-enabled/default-ssl.conf
<IfModule mod_ssl.c>
    # intermediate configuration
    SSLProtocol             all -SSLv3 -TLSv1 -TLSv1.1
    SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305
    SSLHonorCipherOrder     off
    SSLSessionTickets       off

    SSLUseStapling On
    SSLStaplingCache "shmcb:logs/ssl_stapling(32768)" 

    <VirtualHost _default_:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/html
        Protocols h2 http/1.1
        Header always set Strict-Transport-Security "max-age=63072000" 
        AddHandler fcgid-script .fpl
                FcgidMaxRequestLen 10485760
                IPCCommTimeout 32000
                FcgidIOTimeout 32000
              <DirectoryMatch "(\.git|config)/">
                    Require all denied
            </DirectoryMatch>
        <Location "/" >
             AuthType Basic
             AuthName "Bitte authentifizieren" 
             AuthUserFile /etc/htaccess
                 Require valid-user
             AllowOverride all                       
        </Location>

                        AliasMatch /[^/]+\.pl /var/www/kivitendo-erp/dispatcher.fpl
                        Alias      /          /var/www/kivitendo-erp/

                        <Directory /var/www/kivitendo-erp>
                                  AllowOverride All
                                  Options ExecCGI Includes FollowSymlinks
                                  Require all granted
                        </Directory>

                        <DirectoryMatch /var/www/kivitendo-erp/users>
                                Order Deny,Allow
                                Deny from All
                        </DirectoryMatch>

(.. usw. usf.)
    (1-3/3)