Compare commits

..

2 Commits

Author SHA1 Message Date
moritz 4b81322e4f harden htaccess 2026-04-28 01:21:29 +02:00
moritz 563c691172 selfmanaged wordpress 2026-04-28 01:17:17 +02:00
6 changed files with 16 additions and 36 deletions
+7 -14
View File
@@ -1,8 +1,8 @@
export PHP_UPLOADS_CONF_VERSION=v4 export PHP_UPLOADS_CONF_VERSION=v4
export ENTRYPOINT_CONF_VERSION=v8 export ENTRYPOINT_CONF_VERSION=v7
export ENTRYPOINT_MAILRELAY_CONF_VERSION=v2 export ENTRYPOINT_MAILRELAY_CONF_VERSION=v2
export MSMTP_CONF_VERSION=v4 export MSMTP_CONF_VERSION=v4
export HTACCESS_CONF_VERSION=v5 export HTACCESS_CONF_VERSION=v3
export USERS_CONF_VERSION=v1 export USERS_CONF_VERSION=v1
wp() { wp() {
@@ -42,11 +42,11 @@ core_install(){
} }
enable_auto_updates(){ enable_auto_updates(){
wp "plugin deactivate disable-update-notifications --allow-root" wp plugin deactivate disable-update-notifications --allow-root
wp "plugin uninstall disable-update-notifications --allow-root" wp plugin uninstall disable-update-notifications --allow-root
wp "option delete disable_notification_setting --allow-root" wp option delete disable_notification_setting --allow-root
wp "plugin auto-updates enable --all --allow-root" wp plugin auto-updates enable --all --allow-root
wp "theme auto-updates enable --all --allow-root" wp theme auto-updates enable --all --allow-root
} }
disable_auto_updates(){ disable_auto_updates(){
@@ -107,10 +107,3 @@ fix_mysql() {
show_plugins() { show_plugins() {
wp "plugin list --fields=name,status,wporg_status,version,update_version,auto_update,tested_up_to,wporg_last_updated" wp "plugin list --fields=name,status,wporg_status,version,update_version,auto_update,tested_up_to,wporg_last_updated"
} }
rotate_db_pass() {
DB_PASS=$(cat /run/secrets/db_password)
DB_ROOT_PASS=$(cat /run/secrets/db_root_password)
echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASS}'; ALTER USER 'root'@'%' IDENTIFIED BY '${DB_ROOT_PASS}'; ALTER USER 'wordpress'@'%' IDENTIFIED BY '${DB_PASS}'; FLUSH PRIVILEGES;" | mariadb -u root --skip-password 2>/dev/null \
|| echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '${DB_ROOT_PASS}'; ALTER USER 'root'@'%' IDENTIFIED BY '${DB_ROOT_PASS}'; ALTER USER 'wordpress'@'%' IDENTIFIED BY '${DB_PASS}'; FLUSH PRIVILEGES;" | mariadb -u root -p"${DB_ROOT_PASS}"
}
+2 -2
View File
@@ -3,7 +3,7 @@ version: "3.8"
services: services:
app: app:
image: "wordpress:6.9.5" image: "wordpress:6.9.4"
volumes: volumes:
- "wordpress_content:/var/www/html/wp-content/" - "wordpress_content:/var/www/html/wp-content/"
networks: networks:
@@ -62,7 +62,7 @@ services:
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectregex.replacement=https://${DOMAIN}/$${2}" - "traefik.http.middlewares.${STACK_NAME}-redirect.redirectregex.replacement=https://${DOMAIN}/$${2}"
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectregex.permanent=true" - "traefik.http.middlewares.${STACK_NAME}-redirect.redirectregex.permanent=true"
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT}" - "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT}"
- "coop-cloud.${STACK_NAME}.version=2.19.5+6.9.5" - "coop-cloud.${STACK_NAME}.version=2.19.1+6.9.4"
db: db:
image: "mariadb:12.2" image: "mariadb:12.2"
-13
View File
@@ -42,19 +42,6 @@ define('FORCE_SSL_ADMIN', true );
define('COOKIE_DOMAIN', \$_SERVER['HTTP_HOST']);" define('COOKIE_DOMAIN', \$_SERVER['HTTP_HOST']);"
{{ end }} {{ end }}
UPLOADS_HTACCESS=/var/www/html/wp-content/uploads/.htaccess
if [ ! -f "$UPLOADS_HTACCESS" ]; then
mkdir -p /var/www/html/wp-content/uploads
cat > "$UPLOADS_HTACCESS" <<'EOF'
# Prevent PHP execution in uploads directory
<FilesMatch "\.(?i:php|phtml|phar)$">
Require all denied
</FilesMatch>
EOF
chown www-data:www-data "$UPLOADS_HTACCESS"
fi
if [ -n "$@" ]; then if [ -n "$@" ]; then
"$@" "$@"
fi fi
+6 -4
View File
@@ -3,10 +3,12 @@
Require all denied Require all denied
</FilesMatch> </FilesMatch>
# Block XML-RPC # Prevent PHP execution in uploads directory
<Files xmlrpc.php> <Directory /var/www/html/wp-content/uploads>
Require all denied <FilesMatch "\.(?i:php|phtml|phar)$">
</Files> Require all denied
</FilesMatch>
</Directory>
{{ if eq (env "MULTISITE") "" -}} {{ if eq (env "MULTISITE") "" -}}
# BEGIN WordPress # BEGIN WordPress
-1
View File
@@ -1 +0,0 @@
patch to block XML-RPC via htaccess
-1
View File
@@ -1 +0,0 @@
temporarily block rest api against wp2shell CVE