보안 구성
XOOPS 보안 구성
섹션 제목: “XOOPS 보안 구성”일반적인 웹 취약성으로부터 XOOPS 설치를 보호하기 위한 종합 가이드입니다.
보안 체크리스트
섹션 제목: “보안 체크리스트”사이트를 시작하기 전에 다음 보안 조치를 구현하세요.
- 파일 권한이 올바르게 설정됨(644/755)
- 설치 폴더가 제거되거나 보호됨
- 수정으로부터 보호되는 mainfile.php
- 모든 페이지에서 SSL/HTTPS가 활성화되었습니다.
- 관리 폴더 이름이 바뀌거나 보호됨
- 웹에서 액세스할 수 없는 민감한 파일
- [ ].htaccess 제한이 적용됨
- 정기 백업 자동화
- 보안 헤더가 구성됨
- CSRF 보호 활성화됨
- SQL 주입 보호가 활성화되었습니다.
- 모듈/확장 업데이트됨
파일 시스템 보안
섹션 제목: “파일 시스템 보안”파일 권한
섹션 제목: “파일 권한”보안을 위해서는 적절한 파일 권한이 중요합니다.
권한 지침
섹션 제목: “권한 지침”| 경로 | 권한 | 소유자 | 이유 |
|---|---|---|---|
| 메인파일.php | 644 | 루트 | DB 자격 증명 포함 |
| *.php 파일 | 644 | 루트 | 무단수정 방지 |
| 디렉토리 | 755 | 루트 | 읽기 허용, 쓰기 금지 |
| 캐시/ | 777 | www-데이터 | 웹 서버는 |
| template_c/ | 777 | www-데이터 | 컴파일된 템플릿 |
| 업로드/ | 777 | www-데이터 | 사용자 업로드 |
| var/ | 777 | www-데이터 | 가변 데이터 |
| 설치/ | 제거 | - | 설치 후 삭제 |
| 구성/ | 755 | 루트 | 읽기 가능, 쓰기 불가능 |
권한 스크립트 설정
섹션 제목: “권한 스크립트 설정”#!/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!"스크립트를 실행합니다:
chmod +x /usr/local/bin/xoops-secure.sh/usr/local/bin/xoops-secure.sh설치 폴더 제거
섹션 제목: “설치 폴더 제거”중요: 설치 후 설치 폴더를 제거해야 합니다!
# 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 install민감한 디렉터리 보호
섹션 제목: “민감한 디렉터리 보호”민감한 폴더에 대한 웹 액세스를 차단하려면.htaccess 파일을 만드세요.
파일: /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>파일: /var/www/html/xoops/templates_c/.htaccess
<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7|phps|pht|phar)$"> Deny from all</FilesMatch>
Options -Indexes파일: /var/www/html/xoops/cache/.htaccess
Options -Indexes<FilesMatch "\.(php|phtml|php3|php4|php5|php6|php7)$"> Deny from all</FilesMatch>업로드 디렉토리 보호
섹션 제목: “업로드 디렉토리 보호”업로드 시 스크립트 실행을 방지합니다.
파일: /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 구성
섹션 제목: “SSL/HTTPS 구성”사용자와 서버 사이의 모든 트래픽을 암호화합니다.
SSL 인증서 받기
섹션 제목: “SSL 인증서 받기”옵션 1: 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/옵션 2: 상업용 SSL 인증서
SSL 제공업체 또는 등록기관에 문의하세요.
- SSL 인증서 구매
- 도메인 소유권 확인
- 서버에 인증서 파일 설치
- 웹 서버 구성
Apache SSL 구성
섹션 제목: “Apache SSL 구성”HTTPS 가상 호스트를 생성합니다:
파일: /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>구성을 활성화합니다.
# 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 구성
섹션 제목: “Nginx SSL 구성”파일: /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;}구성을 활성화합니다.
ln -s /etc/nginx/sites-available/xoops /etc/nginx/sites-enabled/nginx -tsystemctl restart nginxHTTPS 설치 확인
섹션 제목: “HTTPS 설치 확인”# 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 인증서
섹션 제목: “자동 갱신 Let’s Encrypt 인증서”# Enable auto-renewalsystemctl enable certbot.timersystemctl start certbot.timer
# Test renewal processcertbot renew --dry-run
# Manual renewal if neededcertbot renew --force-renewal웹 애플리케이션 보안
섹션 제목: “웹 애플리케이션 보안”SQL 주입으로부터 보호
섹션 제목: “SQL 주입으로부터 보호”XOOPS는 매개변수화된 쿼리(기본적으로 안전함)를 사용하지만 항상 다음을 수행합니다.
// 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']));XSS(교차 사이트 스크립팅) 방지
섹션 제목: “XSS(교차 사이트 스크립팅) 방지”항상 사용자 입력을 삭제합니다.
// 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']);사이트 간 요청 위조(CSRF) 방지
섹션 제목: “사이트 간 요청 위조(CSRF) 방지”XOOPS에는 CSRF 토큰 보호가 포함되어 있습니다. 항상 토큰을 포함하십시오:
<!-- In forms --><form method="post"> {xoops_token form=update} <input type="text" name="field"> <input type="submit"></form>업로드 폴더에서 PHP 실행 비활성화
섹션 제목: “업로드 폴더에서 PHP 실행 비활성화”공격자가 PHP를 업로드하고 실행하지 못하도록 방지합니다.
# 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-only보안 헤더
섹션 제목: “보안 헤더”중요한 HTTP 보안 헤더를 구성합니다.
# 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'"관리자 패널 보안
섹션 제목: “관리자 패널 보안”관리 폴더 이름 바꾸기
섹션 제목: “관리 폴더 이름 바꾸기”이름을 변경하여 관리 폴더를 보호하세요.
# 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/이름이 바뀐 폴더를 사용하도록 XOOPS를 구성합니다.
mainfile.php를 편집합니다:
// Change this linedefine('XOOPS_ADMIN_PATH', '/var/www/html/xoops/myadmin123');관리자를 위한 IP 화이트리스트
섹션 제목: “관리자를 위한 IP 화이트리스트”특정 IP에 대한 관리자 액세스를 제한합니다.
파일: /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>또는 Apache 2.2의 경우:
Order Deny,AllowDeny from allAllow from 192.168.1.100 203.0.113.50강력한 관리자 자격 증명
섹션 제목: “강력한 관리자 자격 증명”관리자에게 강력한 비밀번호를 적용하십시오.
- 최소 16자 이상을 사용하세요
- 대문자, 소문자, 숫자, 기호를 혼합하세요
- 정기적으로(90일마다) 비밀번호를 변경하세요.
- 비밀번호 관리자를 사용하세요
- 가능한 경우 이중 인증을 활성화합니다.
관리자 활동 모니터링
섹션 제목: “관리자 활동 모니터링”관리자 로그인 로깅 활성화:
관리자 패널 > 시스템 > 기본 설정 > 사용자 설정
Log Admin Logins: YesLog Failed Login Attempts: YesAlert Email on Admin Login: Yes로그를 정기적으로 검토하세요.
# 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;EOF정기점검
섹션 제목: “정기점검”XOOPS 및 모듈 업데이트
섹션 제목: “XOOPS 및 모듈 업데이트”XOOPS 및 모든 모듈을 최신 상태로 유지하십시오.
# 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 guide자동 보안 검색
섹션 제목: “자동 보안 검색”#!/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;EOF정기 백업
섹션 제목: “정기 백업”일일 백업 자동화:
#!/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)"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>&1보안 체크리스트 템플릿
섹션 제목: “보안 체크리스트 템플릿”정기적인 보안 감사에 이 템플릿을 사용하십시오.
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. ___________보안 리소스
섹션 제목: “보안 리소스”- 서버 요구사항
- 기본 구성
- 성능 최적화
- OWASP 상위 10: https://owasp.org/www-project-top-ten/
태그: #보안 #ssl #https #강화 #모범 사례
관련 기사: -../설치/설치 -../../06-Publisher-Module/User-Guide/Basic-Configuration
- 시스템 설정 -../설치/업그레이드-XOOPS