0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【nginx】静的解析ツール「gixy-next」について

0
Last updated at Posted at 2026-05-16

はじめに

世の中で広く使われているwebサーバのnginxですが、設定の記載方法によっては思わぬセキュリティホール(※Alias Path Traversal等)が発生するケースがあります。
今回はnginx向けの静的解析ツールである「gixy-next」を紹介させて頂きます。

「gixy-next」は、gixyの後継の「gixy-ng」が開発都合によりフォークしたものとなります

実行環境

  • OS:Ubuntu 24.04.04
  • python:3.12.3

gixy-nextインストール

※gixy-nextのoverviewページにインストールの記載があるため、uvのインストール手順については割愛させていただきます。

# uv pip install gixy-next

動作確認用のサンプル設定ファイル作成

gixy-nextの動作確認を実施するため、エイリアスパストラバーサルが発生するサンプルのnginx設定ファイルを事前に用意しておきます。

# cat /etc/nginx/sites-enabled/sample_vuln_path_traversal.conf
server {
    listen 10080;
    server_name gixy-next.example.com;

    # 脆弱な設定 (Vulnerable configuration)
    # locationの末尾に「/」がなく、aliasの末尾に「/」があるため、
    # パス・トラバーサルの脆弱性(alias_traversal)が発生します。
    # 注意!ツール動作確認用の設定のため、本番環境では使用しないでください。
    location /static {
        alias /var/www/app/static/;
    }
}

nginx設定のダンプファイル取得

Includeされた設定ファイルを含みチェックをかけるため、nginx -Tコマンドを使い設定内容全体をダンプします。

# nginx -T > /tmp/nginx-dump.conf
# gixy /tmp/nginx-dump.conf
または下記でも可
# cat /tmp/nginx-dump.conf | gixy -

gixy-nextの実行、出力結果の確認

セキュリティにて問題箇所がある場合、重要度(Low,Medium,High等)と該当箇所のレポートが以下のように出力されます。

# gixy /tmp/nginx-dump.conf

==================== Results ===================

>> Problem: [alias_traversal] Path traversal via misconfigured alias.
Description: Using alias in a prefixed location that doesn't end with a directory separator could lead to path traversal vulnerability.
Additional info: https://gixy.io/plugins/alias_traversal/
Pseudo config:

server {
        server_name gixy-next.example.com;

        location /static {
                alias /var/www/app/static/;
        }
}

==================== Summary ===================
Total issues:
    Unspecified: 0
    Low: 0
    Medium: 0
    High: 1

レポートに問題個所が出力されている事を確認できました。

問題個所(サンプルのAlias Path Traversal等)の詳細や対処方法について内容を確認したい場合は、レポート内の[Additional info]のURLに記載があります。

特定チェック項目の除外

特定のチェック項目をレポート結果から除外したい場合、出力時のProblem:直後の[]内のplugin名をskipオプションで指定する事で除外が可能となっています。

・if文のpluginチェックをレポートから除外したい場合

# gixy --skips if_is_evil /tmp/nginx-dump.conf

※複数除外したい場合:--skips if_is_evil,pluginnameのような形で指定可

Nginx Rift(CVE-2026-42945)のチェック

Issueで、Nginx Rift(CVE-2026-42945)を情報レベルでレポート出力するよう改修を行った旨の更新があったため、サンプル設定ファイルを用意して確認してみます。

# cat /etc/nginx/sites-enabled/sample_vuln_CVE-2026-42945.conf
server {
    listen 10080;
    server_name gixy-next.example.com;
    root /var/www/html;

    # CVE-2026-42945 Nginx Rift
    # 注意!ツール動作確認用の設定のため、本番環境では使用しないでください。
    location /static {
        rewrite ^/static/(.*)$ /stat/$1?mode=1 last;
        set $userid $1;
    }
}

・gixy-nextを更新し、再度ダンプファイル取得
# uv pip install --upgrade gixy-next
# nginx -T > /tmp/nginx-dump.conf

gixy-nextを実行します。

# gixy /tmp/nginx-dump.conf
[variable]      INFO    Can't find variable '1' in script '$1' inside block 'location /static {'.
[variable]      INFO    Can't find variable '1' in script '$1' inside block 'location /static {'.

==================== Results ===================

>> Problem: [unnamed_groups] Unnamed capture group reference in rewrite with query string (CVE-2026-42945).
Description: This check flags a specific pattern associated with CVE-2026-42945: a rewrite replacement that contains both a query string ('?') and numeric capture group references ($1, $2, …). Not all uses of unnamed capture groups are flagged — only this combination. The underlying bug is in nginx itself; if you are running a patched version (1.30.1+/1.31.0+, or NGINX Plus R32 P6+/R36 P4+), no action is required. On unpatched versions, switching to named capture groups avoids the vulnerable pattern and improves readability.
Additional info: https://gixy.io/plugins/unnamed_groups/
Reason: Rewrite replacement contains '?' and references numeric capture group(s) $1. See CVE-2026-42945.
Pseudo config:

server {
        server_name gixy-next.example.com;

        location /static {
                rewrite ^/static/(.*)$ /stat/$1?mode=1 last;
        }
}

==================== Summary ===================
Total issues:
    Informational: 1
    Low: 0
    Medium: 0
    High: 0

nginxの最新バージョンへの更新を促すメッセージとともに、「Informational」項目にて[unnamed_groups]としてレポート内へ出力されている事が確認できました。

5/23(土)時点で、バージョン1.30.0および1.31.0で新たに「nginx-poolslip(CVE-2026-9256)」の脆弱性が見つかったため、バージョンアップについてはご注意願います。

おわりに

nginx設定ファイルの静的解析ツールであるgixy-nextを紹介させて頂きましたがいかがでしたでしょうか。

本ツールにより、サービスイン前の設定チェック等を行う事で既知の問題によるセキュリティホールを防ぐ事が出来ますので是非ご活用していただければと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?