WordPress: Wordfence プラグインのアラートの対応 - "Publicly accessible config, backup, or log file found" ほか

WordPress: Wordfence プラグインのアラートの対応 - "Publicly accessible config, backup, or log file found" ほか

April 10, 2022

(友人にヘルプを求められ、そのとき対応した内容をメモ)

状況整理 #

経緯 #

ブログのワードプレスで以下の通りいくつかアラートが出たものの、良く分からないので助けて欲しいとのこと。

「Wordfence」というプラグインのアラートらしい。

  1. Publicly accessible config, backup, or log file found: user.ini
  2. X pathes was skipped for the malware scan due to scan settings

WordPress: Wordfence - Alert

  1. The WordFence Web Application Firewall cannot run. (We were unable to write to ~/wp-content/wflogs)

WordPress: Wordfence - Alert

環境 #

  • Amazon Lightsail 上にインストールされた WordPress
  • (Let’s Encrypt で SSL 化済み)

対応 #

プラグイン公式ページ(?)の指示に従えば OK.

「Publicly accessible config, backup, or log file found」の対応 #

AWS のコンソールからインスタンスに SSH で接続。

以下のファイルを次のように編集する。

/opt/bitnami/apps/letsencrypt/conf/httpd-app.conf

編集前 #

<Directory "/opt/bitnami/apps/letsencrypt/.well-known">
    Options +MultiViews
    AllowOverride None
    <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>

</Directory>

編集後 #

<Directory "/opt/bitnami/apps/letsencrypt/.well-known">
    Options +MultiViews
    AllowOverride None
    <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>
</Directory>

<Files ".user.ini">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
    </IfModule>
</Files>

その後インスタンスを再起動する。

「X pathes was skipped for the malware scan due to scan settings」の対応 #

(スキャン対象に含める場合)

  1. アラートと合わせて表示されている「GO TO OPTION」を選択
  2. オプションから「Scan files outside your WordPress installation」を選択して保存

「The WordFence Web Application Firewall cannot run. (We were unable to write to ~/wp-content/wflogs)」の対応 #

AWS のコンソールからインスタンスに SSH で接続して以下の作業。

cd /opt/bitnami/wordpress/wp-content
ls -l

> -rw-rw-r--  1 bitnami daemon   28 Apr 01 07:30 index.php
> drwxrwxr-x  4 bitnami daemon 4096 Apr 01 07:30 languages
> drwxr-xr-x  2 daemon  daemon 4096 Apr 01 07:30 mu-plugins
> drwxrwxr-x 12 bitnami daemon 4096 Apr 01 07:30 plugins
> drwxrwxr-x  5 bitnami daemon 4096 Apr 01 07:30 themes
> drwxrwxr-x  2 bitnami daemon 4096 Apr 01 07:30 upgrade
> drwxrwxr-x  6 bitnami daemon 4096 Apr 01 07:30 uploads
> drwxr-xr-x  2 daemon  daemon 4096 Apr 01 07:30 wflogs

sudo chmod 775 wflogs/
ls -l

> (省略)
> drwxrwxr-x  2 daemon  daemon 4096 Apr 01 07:30 wflogs # パーミッションが変更されていること

cd wflogs/
sudo rm rules.php

その後 Wordfence が rules.php を自動的に再生成する(遅くとも 30 分以内)。再び SSH 接続して rules.php が新たに作成されていることを確認する。

その後 #

再度スキャンを行うとアラートが解消されているはず。