Sicherheitskonfiguration
XOOPS-Sicherheitskonfiguration
Abschnitt betitelt „XOOPS-Sicherheitskonfiguration“Umfassender Leitfaden zum Schutz Ihrer XOOPS-Installation gegen häufige Web-Sicherheitslücken.
Sicherheits-Checkliste
Abschnitt betitelt „Sicherheits-Checkliste“Implementieren Sie vor dem Launch Ihrer Site diese Sicherheitsmaßnahmen:
- Dateiberechtigungen korrekt eingestellt (644/755)
- Install-Ordner entfernt oder geschützt
- mainfile.php vor Änderung geschützt
- SSL/HTTPS auf allen Seiten aktiviert
- Admin-Ordner umbenannt oder geschützt
- Sensitive Dateien nicht web-zugänglich
- .htaccess-Beschränkungen vorhanden
- Regelmäßige Backups automatisiert
- Sicherheits-Header konfiguriert
- CSRF-Schutz aktiviert
- SQL-Injection-Schutz aktiv
- Module/Erweiterungen aktualisiert
Dateisystem-Sicherheit
Abschnitt betitelt „Dateisystem-Sicherheit“Dateiberechtigungen
Abschnitt betitelt „Dateiberechtigungen“Korrekte Dateiberechtigungen sind kritisch für die Sicherheit.
Richtlinien für Berechtigungen
Abschnitt betitelt „Richtlinien für Berechtigungen“| Pfad | Berechtigungen | Besitzer | Grund |
|---|---|---|---|
| mainfile.php | 644 | root | Enthält DB-Anmeldedaten |
| *.php files | 644 | root | Verhindern Sie nicht autorisierte Änderungen |
| Directories | 755 | root | Lesen erlauben, Schreiben verhindern |
| cache/ | 777 | www-data | Web-Server muss schreiben |
| templates_c/ | 777 | www-data | Kompilierte Templates |
| uploads/ | 777 | www-data | Benutzer-Uploads |
| var/ | 777 | www-data | Variable Daten |
| install/ | Remove | - | Nach Installation löschen |
| configs/ | 755 | root | Lesbar, nicht beschreibbar |
Berechtigungs-Set-Skript
Abschnitt betitelt „Berechtigungs-Set-Skript“#!/bin/bashXOOPS_PATH="/var/www/html/xoops"WEB_USER="www-data"
# Set ownershipecho "Setting ownership..."chown -R $WEB_USER:$WEB_USER $XOOPS_PATH
# Set restrictive default permissionsecho "Setting base permissions..."find $XOOPS_PATH -type d -exec chmod 755 {} \;find $XOOPS_PATH -type f -exec chmod 644 {} \;
# Make specific directories writableecho "Setting writable directories..."chmod 777 $XOOPS_PATH/cachechmod 777 $XOOPS_PATH/templates_cchmod 777 $XOOPS_PATH/uploadschmod 777 $XOOPS_PATH/var
# Protect sensitive filesecho "Protecting sensitive files..."chmod 644 $XOOPS_PATH/mainfile.phpchmod 444 $XOOPS_PATH/mainfile.php.dist # If it exists (read-only)
# Verify permissionsecho "Verifying permissions..."ls -la $XOOPS_PATH | grep -E "mainfile|cache|uploads|var|templates_c"
echo "Security hardening completed!"Führen Sie das Skript aus:
chmod +x /usr/local/bin/xoops-secure.sh/usr/local/bin/xoops-secure.shInstall-Ordner entfernen
Abschnitt betitelt „Install-Ordner entfernen“KRITISCH: Der Install-Ordner muss nach der Installation entfernt werden!
# Option 1: Delete completelyrm -rf /var/www/html/xoops/install/
# Option 2: Rename and keep for referencemv /var/www/html/xoops/install/ /var/www/html/xoops/install.bak/
# Verify removalls -la /var/www/html/xoops/ | grep installSchützen Sie sensitive Verzeichnisse
Abschnitt betitelt „Schützen Sie sensitive Verzeichnisse“Erstellen Sie .htaccess-Dateien zur Blockierung des Web-Zugriffs auf sensitive Ordner:
Datei: /var/www/html/xoops/var/.htaccess
<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7|phps|pht|phar)$"> Deny from all</FilesMatch>
<IfModule mod_autoindex.c> Options -Indexes</IfModule>Datei: /var/www/html/xoops/templates_c/.htaccess
<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7|phps|pht|phar)$"> Deny from all</FilesMatch>
Options -IndexesDatei: /var/www/html/xoops/cache/.htaccess
Options -Indexes<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7)$"> Deny from all</FilesMatch>Schützen Sie das Upload-Verzeichnis
Abschnitt betitelt „Schützen Sie das Upload-Verzeichnis“Verhindern Sie die Ausführung von Skripten in Uploads:
Datei: /var/www/html/xoops/uploads/.htaccess
# Prevent script execution<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7|phps|pht|phar|pl|py|jsp|asp|aspx|cgi|sh|bat|exe)$"> Deny from all</FilesMatch>
# Prevent directory listingOptions -Indexes
# Additional protection<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /xoops/uploads/
# Block suspicious files RewriteCond %{REQUEST_URI} \.(php|phtml|php3|php4|php5|php6|php7)$ [NC] RewriteRule ^.*$ - [F,L]</IfModule>SSL/HTTPS-Konfiguration
Abschnitt betitelt „SSL/HTTPS-Konfiguration“Verschlüsseln Sie den gesamten Datenverkehr zwischen Benutzer und Server.
SSL-Zertifikat erhalten
Abschnitt betitelt „SSL-Zertifikat erhalten“Option 1: Kostenloses Zertifikat von Let’s Encrypt
# Install Certbotapt-get install certbot python3-certbot-apache
# Obtain certificate (auto-configures Apache)certbot certonly --apache -d your-domain.com -d www.your-domain.com
# Verify certificate installedls /etc/letsencrypt/live/your-domain.com/Option 2: Kommerzielles SSL-Zertifikat
Kontaktieren Sie SSL-Anbieter oder Registrar:
- SSL-Zertifikat kaufen
- Domain-Besitz überprüfen
- Zertifikatsdateien auf Server installieren
- Web-Server konfigurieren
Apache SSL-Konfiguration
Abschnitt betitelt „Apache SSL-Konfiguration“Erstellen Sie einen HTTPS-Virtual-Host:
Datei: /etc/apache2/sites-available/xoops-ssl.conf
<VirtualHost *:443> ServerName your-domain.com ServerAlias www.your-domain.com DocumentRoot /var/www/html/xoops
# SSL Configuration SSLEngine on SSLProtocol TLSv1.2 TLSv1.3 SSLCipherSuite HIGH:!aNULL:!MD5 SSLCertificateFile /etc/letsencrypt/live/your-domain.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/your-domain.com/chain.pem
# Security Headers Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" Header always set X-Content-Type-Options "nosniff" Header always set X-Frame-Options "SAMEORIGIN" Header always set X-XSS-Protection "1; mode=block" Header always set Referrer-Policy "no-referrer-when-downgrade" Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'"
<Directory /var/www/html/xoops> Options -Indexes +FollowSymLinks AllowOverride All Require all granted </Directory>
# Restrict install folder <Directory /var/www/html/xoops/install> Deny from all </Directory>
# Logging ErrorLog ${APACHE_LOG_DIR}/xoops_ssl_error.log CustomLog ${APACHE_LOG_DIR}/xoops_ssl_access.log combined</VirtualHost>
# Redirect HTTP to HTTPS<VirtualHost *:80> ServerName your-domain.com ServerAlias www.your-domain.com Redirect 301 / https://your-domain.com/</VirtualHost>Aktivieren Sie die Konfiguration:
# Enable SSL modulea2enmod ssl
# Enable sitea2ensite xoops-ssl
# Disable non-SSL site if existsa2dissite 000-default
# Test configurationapache2ctl configtest# Should output: Syntax OK
# Restart Apachesystemctl restart apache2Nginx SSL-Konfiguration
Abschnitt betitelt „Nginx SSL-Konfiguration“Datei: /etc/nginx/sites-available/xoops
# HTTP to HTTPS redirectserver { listen 80; listen [::]:80; server_name your-domain.com www.your-domain.com;
location / { return 301 https://$server_name$request_uri; }}
# HTTPS serverserver { listen 443 ssl http2; listen [::]:443 ssl http2;
server_name your-domain.com www.your-domain.com; root /var/www/html/xoops; index index.php index.html;
# SSL Certificate Configuration ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
# Modern SSL Configuration ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m;
# HSTS Header add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# Security Headers add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "no-referrer-when-downgrade" always; add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'" always;
# Restrict install folder location ~ ^/(install|upgrade)/ { deny all; }
# Deny access to sensitive files location ~ /\. { deny all; }
# PHP-FPM backend location ~ \.php$ { fastcgi_pass unix:/run/php-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }
# Static files caching location ~* \.(js|css|png|jpg|gif|ico|svg)$ { expires 30d; add_header Cache-Control "public, immutable"; }
# URL rewriting location / { try_files $uri $uri/ /index.php?$query_string; }
# Logging access_log /var/log/nginx/xoops_access.log; error_log /var/log/nginx/xoops_error.log;}Aktivieren Sie die Konfiguration:
ln -s /etc/nginx/sites-available/xoops /etc/nginx/sites-enabled/nginx -tsystemctl restart nginxHTTPS-Installation überprüfen
Abschnitt betitelt „HTTPS-Installation überprüfen“# Test SSL configurationopenssl s_client -connect your-domain.com:443 -tls1_2
# Check certificate validityopenssl x509 -in /etc/letsencrypt/live/your-domain.com/cert.pem -noout -text
# SSL/TLS test online# https://www.ssllabs.com/ssltest/# https://www.testssl.sh/Let’s Encrypt-Zertifikat automatisch erneuern
Abschnitt betitelt „Let’s Encrypt-Zertifikat automatisch erneuern“# Enable auto-renewalsystemctl enable certbot.timersystemctl start certbot.timer
# Test renewal processcertbot renew --dry-run
# Manual renewal if neededcertbot renew --force-renewalWeb-Anwendungssicherheit
Abschnitt betitelt „Web-Anwendungssicherheit“Schutz vor SQL-Injection
Abschnitt betitelt „Schutz vor SQL-Injection“XOOPS verwendet standardmäßig parametrisierte Abfragen (sicher), aber immer:
// UNSAFE - Never do this!$query = "SELECT * FROM users WHERE name = '" . $_GET['name'] . "'";
// SAFE - Use prepared statements$database = XoopsDatabaseFactory::getDatabaseConnection();$sql = "SELECT * FROM " . $database->prefix('users') . " WHERE name = ?";$result = $database->query($sql, array($_GET['name']));Schutz vor Cross-Site Scripting (XSS)
Abschnitt betitelt „Schutz vor Cross-Site Scripting (XSS)“Bereinigen Sie immer Benutzereingaben:
// UNSAFEecho $_GET['user_input'];
// SAFE - Use XOOPS sanitization functionsecho htmlspecialchars($_GET['user_input'], ENT_QUOTES, 'UTF-8');
// Or use XOOPS functions$text_sanitizer = new xoops_text_sanitizer();echo $text_sanitizer->stripSlashesGPC($_GET['user_input']);Schutz vor Cross-Site Request Forgery (CSRF)
Abschnitt betitelt „Schutz vor Cross-Site Request Forgery (CSRF)“XOOPS enthält CSRF-Token-Schutz. Immer Token einbinden:
<!-- In forms --><form method="post"> {xoops_token form=update} <input type="text" name="field"> <input type="submit"></form>Deaktivieren Sie PHP-Ausführung im Upload-Ordner
Abschnitt betitelt „Deaktivieren Sie PHP-Ausführung im Upload-Ordner“Verhindern Sie, dass Angreifer PHP hochladen und ausführen:
# Create .htaccess in uploads foldercat > /var/www/html/xoops/uploads/.htaccess << 'EOF'<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7)$"> Deny from all</FilesMatch>php_flag engine offEOF
# Alternative: Disable execution globally in uploadschmod 444 /var/www/html/xoops/uploads/ # Read-onlySicherheits-Header
Abschnitt betitelt „Sicherheits-Header“Konfigurieren Sie wichtige HTTP-Sicherheits-Header:
# Strict-Transport-Security (HSTS)# Forces HTTPS for 1 yearHeader always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
# X-Content-Type-Options# Prevents MIME type sniffingHeader always set X-Content-Type-Options "nosniff"
# X-Frame-Options# Prevents clickjacking attacksHeader always set X-Frame-Options "SAMEORIGIN"
# X-XSS-Protection# Browser XSS protectionHeader always set X-XSS-Protection "1; mode=block"
# Referrer-Policy# Controls referrer informationHeader always set Referrer-Policy "strict-origin-when-cross-origin"
# Content-Security-Policy# Controls resource loadingHeader always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'"Admin-Panel-Sicherheit
Abschnitt betitelt „Admin-Panel-Sicherheit“Benennen Sie Admin-Ordner um
Abschnitt betitelt „Benennen Sie Admin-Ordner um“Schützen Sie Admin-Ordner durch Umbenennung:
# Rename admin foldermv /var/www/html/xoops/admin /var/www/html/xoops/myadmin123
# Update admin access URL# Old: http://your-domain.com/xoops/admin/# New: http://your-domain.com/xoops/myadmin123/Konfigurieren Sie XOOPS zur Verwendung des umbenannten Ordners:
Bearbeiten Sie mainfile.php:
// Change this linedefine('XOOPS_ADMIN_PATH', '/var/www/html/xoops/myadmin123');IP-Whitelist für Admin
Abschnitt betitelt „IP-Whitelist für Admin“Beschränken Sie Admin-Zugriff auf bestimmte IPs:
Datei: /var/www/html/xoops/myadmin123/.htaccess
# Allow only specific IPs<RequireAll> Require ip 192.168.1.100 # Your office IP Require ip 203.0.113.50 # Your home IP Deny from all</RequireAll>Oder mit Apache 2.2:
Order Deny,AllowDeny from allAllow from 192.168.1.100 203.0.113.50Starke Admin-Anmeldedaten
Abschnitt betitelt „Starke Admin-Anmeldedaten“Erzwingen Sie starke Passwörter für Administratoren:
- Verwenden Sie mindestens 16 Zeichen
- Mischen Sie Großbuchstaben, Kleinbuchstaben, Zahlen, Symbole
- Ändern Sie das Passwort regelmäßig (alle 90 Tage)
- Verwenden Sie einen Passwort-Manager
- Aktivieren Sie die Zwei-Faktor-Authentifizierung, falls verfügbar
Überwachen Sie Admin-Aktivität
Abschnitt betitelt „Überwachen Sie Admin-Aktivität“Aktivieren Sie Admin-Login-Protokollierung:
Admin-Panel > System > Preferences > User Settings
Log Admin Logins: YesLog Failed Login Attempts: YesAlert Email on Admin Login: YesÜberprüfen Sie regelmäßig die Protokolle:
# Check database for login attemptsmysql -u xoops_user -p xoops_db << EOFSELECT uid, uname, DATE_FROM_UNIXTIME(user_lastlogin) as last_loginFROM xoops_users WHERE uid = 1;EOFRegelmäßige Wartung
Abschnitt betitelt „Regelmäßige Wartung“Aktualisieren Sie XOOPS und Module
Abschnitt betitelt „Aktualisieren Sie XOOPS und Module“Halten Sie XOOPS und alle Module aktualisiert:
# Check for updates in admin panel# Admin > Modules > Check for Updates
# Or via command linecd /var/www/html/xoops# Download and install latest version# Follow upgrade guideAutomatisierte Sicherheitsüberprüfung
Abschnitt betitelt „Automatisierte Sicherheitsüberprüfung“#!/bin/bash# Security audit script
# Check file permissionsecho "Checking file permissions..."find /var/www/html/xoops -type f ! -perm 644 ! -name "*.htaccess" | head -10
# Check for suspicious filesecho "Checking for suspicious files..."find /var/www/html/xoops -type f -name "*.php" -newer /var/www/html/xoops/install/ 2>/dev/null
# Check database for suspicious activityecho "Checking for failed login attempts..."mysql -u xoops_user -p xoops_db << EOFSELECT count(*) as attempts FROM xoops_audittrail WHERE action LIKE '%login%' AND status = 0;EOFRegelmäßige Backups
Abschnitt betitelt „Regelmäßige Backups“Automatisieren Sie tägliche Backups:
#!/bin/bash# Daily backup script
BACKUP_DIR="/backups/xoops"RETENTION=30 # Keep 30 days
# Backup databasemysqldump -u xoops_user -p xoops_db | gzip > $BACKUP_DIR/db_$(date +%Y%m%d).sql.gz
# Backup filestar -czf $BACKUP_DIR/files_$(date +%Y%m%d).tar.gz /var/www/html/xoops --exclude=cache --exclude=templates_c
# Remove old backupsfind $BACKUP_DIR -type f -mtime +$RETENTION -delete
echo "Backup completed at $(date)"Planen Sie mit cron:
# Edit crontabcrontab -e
# Add line (runs daily at 2 AM)0 2 * * * /usr/local/bin/xoops-backup.sh >> /var/log/xoops_backup.log 2>&1Vorlage für Sicherheits-Checkliste
Abschnitt betitelt „Vorlage für Sicherheits-Checkliste“Verwenden Sie diese Vorlage für regelmäßige Sicherheitsüberprüfungen:
Weekly Security Checklist========================
Date: ___________Checked by: ___________
File System:[ ] Permissions correct (644/755)[ ] Install folder removed[ ] No suspicious files[ ] mainfile.php protected
Web Security:[ ] HTTPS/SSL working[ ] Security headers present[ ] Admin panel restricted[ ] File upload restrictions active[ ] Login attempts logged
Application:[ ] XOOPS version current[ ] All modules updated[ ] No error messages in logs[ ] Database optimized[ ] Cache cleared
Backups:[ ] Database backed up[ ] Files backed up[ ] Backup tested[ ] Offsite copy verified
Issues Found:1. ___________2. ___________3. ___________
Actions Taken:1. ___________2. ___________Sicherheitsressourcen
Abschnitt betitelt „Sicherheitsressourcen“- Server Requirements
- Basic Configuration
- Performance Optimization
- OWASP Top 10: https://owasp.org/www-project-top-ten/
Tags: #security #ssl #https #hardening #best-practices
Related Articles:
- ../Installation/Installation
- ../../06-Publisher-Module/User-Guide/Basic-Configuration
- System-Settings
- ../Installation/Upgrading-XOOPS