Falco nginx Plugin / Falco nginxプラグイン

March 3, 2026 · View on GitHub

English | 日本語

English

A Falco plugin that reads nginx access logs and detects security threats in real-time.

Features

  • Real-time nginx log monitoring: Continuously monitors nginx access logs
  • Security threat detection: Detects SQL injection, XSS, directory traversal, command injection, and more
  • Scanner detection: Identifies common security scanning tools
  • Brute force detection: Monitors authentication failures and password attacks
    • Failed login attempts on multiple endpoints (/login, /admin, /api/auth, etc.)
    • HTTP Basic Authentication failures
    • Password reset abuse detection
    • WordPress and CMS login monitoring
  • High performance: Efficient log parsing with minimal overhead
  • Easy deployment: Simple binary installation with automated setup

Quick Start

The easiest way to get started:

curl -sSL https://raw.githubusercontent.com/takaosgb3/falco-plugin-nginx/main/install.sh | sudo bash

This will automatically:

  • ✅ Check system requirements
  • ✅ Install and configure nginx (if needed)
  • ✅ Install Falco
  • ✅ Download and install the nginx plugin
  • ✅ Configure everything for immediate use

Manual Installation

  1. Download the latest release:
wget https://github.com/takaosgb3/falco-plugin-nginx/releases/latest/download/libfalco-nginx-plugin-linux-amd64.so
wget https://github.com/takaosgb3/falco-plugin-nginx/releases/latest/download/nginx_rules.yaml
  1. Install the plugin:
sudo mkdir -p /usr/share/falco/plugins
sudo cp libfalco-nginx-plugin-linux-amd64.so /usr/share/falco/plugins/libfalco-nginx-plugin.so
sudo chmod 644 /usr/share/falco/plugins/libfalco-nginx-plugin.so
  1. Install the rules:
sudo mkdir -p /etc/falco/rules.d
sudo cp nginx_rules.yaml /etc/falco/rules.d/
  1. Configure Falco - Add to /etc/falco/falco.yaml:
load_plugins: [nginx]

plugins:
  - name: nginx
    library_path: /usr/share/falco/plugins/libfalco-nginx-plugin.so
    init_config:
      log_paths:
        - /var/log/nginx/access.log

Testing

After installation, test the plugin:

# Step 1: Find which Falco service is running (quick check)
for svc in falco falco-modern-bpf falco-bpf; do
  echo -n "$svc: "
  systemctl is-active $svc 2>/dev/null || echo "not found"
done
# Look for "active" - that's your service!

# Step 2: Monitor alerts using YOUR active service
# If falco: active         → sudo journalctl -u falco -f
# If falco-modern-bpf: active → sudo journalctl -u falco-modern-bpf -f
# If falco-bpf: active     → sudo journalctl -u falco-bpf -f

# Step 3: In another terminal, simulate attacks
curl "http://localhost/search.php?q=%27%20OR%20%271%27%3D%271"  # SQL injection
curl "http://localhost/search.php?q=%3Cscript%3Ealert(1)%3C/script%3E"  # XSS

# Verify plugin is loaded
sudo falco --list-plugins | grep nginx

💡 Tip: Not sure which service? Run sudo systemctl status falco - if it shows "not found" or "inactive", try sudo systemctl status falco-modern-bpf (common on EC2/cloud).

E2E Security Tests

This repository includes comprehensive E2E tests for security detection validation.

Running E2E Tests:

# Trigger via GitHub Actions
gh workflow run e2e-test.yml

Test Coverage (850 attack patterns across 24 categories):

CategoryPatternsDescription
SQL Injection138Time-based, Boolean-based, Error-based, Advanced SQLi
Command Injection98Shell, OS command injection, obfuscation bypass
XSS96Reflected, DOM-based, Advanced, Filter bypass, Mutation
Path Traversal81Directory traversal, LFI, RFI, Unicode bypass
SSRF41Cloud metadata, internal network, hex/IPv6/octal IP
SSTI34Jinja2, Pug, EJS, Handlebars, Mako, Nunjucks
Other34Additional security patterns
CRLF Injection31Header injection, response splitting, Unicode CRLF
API Security30BOLA, authentication bypass, mass assignment
GraphQL25Introspection, data extraction, query abuse
XPath Injection25Boolean-based, blind, function abuse
Host Header Injection21Multi-host, CRLF, port manipulation
HPP20HTTP Parameter Pollution, array, type juggling
Open Redirect20Data URI, fragment, meta refresh, Unicode
NoSQL Injection20MongoDB, Redis, CouchDB injection patterns
LDAP Injection20LDAP query manipulation, filter injection
WAF Bypass18Chunked, multipart, double encoding
XXE18XML External Entity, DOCTYPE/ENTITY injection
JWT15KID injection, X5U, JWE, replay, JWKS
Prototype Pollution15__proto__, constructor.prototype pollution
HTTP Smuggling15CL.TE, TE.CL, request splitting
Pickle/Deserialization15Python deserialization, pickle exploitation
Information Disclosure10Server info, debug endpoints, error pages
Auth Bypass via Path10Path normalization, case manipulation

Latest Results: See Actions for test runs and Allure Report for detailed results.

Extractable Fields

This plugin provides 17 fields for use in Falco rules:

FieldTypeDescription
nginx.remote_addrstringClient IP address
nginx.remote_userstringAuthenticated username
nginx.time_localstringLocal time of the request
nginx.methodstringHTTP request method (GET, POST, etc.)
nginx.pathstringRequest URI path
nginx.query_stringstringQuery string parameters
nginx.request_uristringComplete request URI (path + query)
nginx.protocolstringHTTP protocol version
nginx.statusuint64HTTP response status code
nginx.bytes_sentuint64Response size in bytes
nginx.refererstringHTTP referer header
nginx.user_agentstringHTTP user agent
nginx.log_pathstringPath to the log file
nginx.rawstringRaw log line
nginx.headers[key]stringHTTP request headers (key-based access)
nginx.test_idstringE2E test identifier (X-Test-ID header)
nginx.categorystringAttack category (X-Category header)
nginx.pattern_idstringPattern ID (X-Pattern-ID header)

Example rule using these fields:

- rule: SQL Injection Attempt
  desc: Detects SQL injection patterns in nginx access logs
  condition: nginx.request_uri contains "' OR " or nginx.request_uri contains "1=1"
  output: "SQL Injection detected (client=%nginx.remote_addr path=%nginx.path)"
  priority: WARNING
  source: nginx

Documentation

Requirements

  • Falco: 0.36.0 or higher
  • OS: Linux x86_64
  • nginx: 1.14.0+ with combined log format

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


日本語

nginxのアクセスログを読み取り、セキュリティ脅威をリアルタイムで検出するFalcoプラグイン。

機能

  • リアルタイムnginxログ監視: nginxアクセスログを継続的に監視
  • セキュリティ脅威検出: SQLインジェクション、XSS、ディレクトリトラバーサル、コマンドインジェクション等を検出
  • スキャナー検出: 一般的なセキュリティスキャンツールを識別
  • ブルートフォース検出: 認証攻撃を監視
  • 高性能: 最小限のオーバーヘッドで効率的なログ解析
  • 簡単な展開: 自動セットアップによる簡単なバイナリインストール

クイックスタート

ワンライナーインストール(推奨)

最も簡単な開始方法:

curl -sSL https://raw.githubusercontent.com/takaosgb3/falco-plugin-nginx/main/install.sh | sudo bash

これにより自動的に以下が実行されます:

  • ✅ システム要件の確認
  • ✅ nginx のインストールと設定(必要な場合)
  • ✅ Falco のインストール
  • ✅ nginx プラグインのダウンロードとインストール
  • ✅ すぐに使用できるようにすべてを設定

手動インストール

  1. 最新リリースをダウンロード
wget https://github.com/takaosgb3/falco-plugin-nginx/releases/latest/download/libfalco-nginx-plugin-linux-amd64.so
wget https://github.com/takaosgb3/falco-plugin-nginx/releases/latest/download/nginx_rules.yaml
  1. プラグインをインストール
sudo mkdir -p /usr/share/falco/plugins
sudo cp libfalco-nginx-plugin-linux-amd64.so /usr/share/falco/plugins/libfalco-nginx-plugin.so
sudo chmod 644 /usr/share/falco/plugins/libfalco-nginx-plugin.so
  1. ルールをインストール
sudo mkdir -p /etc/falco/rules.d
sudo cp nginx_rules.yaml /etc/falco/rules.d/
  1. Falcoを設定 - /etc/falco/falco.yamlに追加:
load_plugins: [nginx]

plugins:
  - name: nginx
    library_path: /usr/share/falco/plugins/libfalco-nginx-plugin.so
    init_config:
      log_paths:
        - /var/log/nginx/access.log

テスト

インストール後、プラグインをテスト:

# アラートを監視(サービスは既に起動しています)
sudo journalctl -u falco -f
# またはEC2/eBPFシステムの場合:
sudo journalctl -u falco-modern-bpf -f

# 別のターミナルで攻撃をシミュレート
curl "http://localhost/search.php?q=%27%20OR%20%271%27%3D%271"

E2Eセキュリティテスト

このリポジトリには、セキュリティ検出を検証するための包括的なE2Eテストが含まれています。

E2Eテストの実行:

# GitHub Actions経由でトリガー
gh workflow run e2e-test.yml

テストカバレッジ(850攻撃パターン、24カテゴリ):

カテゴリパターン数説明
SQLインジェクション138時間ベース、ブールベース、エラーベース、高度なSQLi
コマンドインジェクション98シェル、OSコマンドインジェクション、難読化バイパス
XSS96反射型、DOMベース、高度なXSS、フィルターバイパス、ミューテーション
パストラバーサル81ディレクトリトラバーサル、LFI、RFI、Unicodeバイパス
SSRF41クラウドメタデータ、内部ネットワーク、hex/IPv6/octal IP
SSTI34Jinja2、Pug、EJS、Handlebars、Mako、Nunjucks
その他34追加セキュリティパターン
CRLFインジェクション31ヘッダーインジェクション、レスポンス分割、Unicode CRLF
APIセキュリティ30BOLA、認証バイパス、マスアサインメント
GraphQLインジェクション25イントロスペクション、データ抽出、クエリ悪用
XPathインジェクション25ブールベース、ブラインド、関数悪用
Host Headerインジェクション21マルチホスト、CRLF、ポート操作
HPP20HTTPパラメータ汚染、配列、型ジャグリング
オープンリダイレクト20Data URI、フラグメント、metaリフレッシュ、Unicode
NoSQLインジェクション20MongoDB、Redis、CouchDBインジェクション
LDAPインジェクション20LDAPクエリ操作、フィルターインジェクション
WAFバイパス18チャンク、マルチパート、二重エンコーディング
XXE18XML外部エンティティ、DOCTYPE/ENTITYインジェクション
JWT15KIDインジェクション、X5U、JWE、リプレイ、JWKS
プロトタイプ汚染15__proto__、constructor.prototype汚染
HTTPスマグリング15CL.TE、TE.CL、リクエスト分割
Pickle/デシリアライゼーション15Pythonデシリアライゼーション、Pickle悪用
情報漏洩10サーバー情報、デバッグエンドポイント、エラーページ
パスベース認証バイパス10パス正規化、大文字小文字操作

最新結果: テスト実行はActions、詳細結果はAllure Reportを参照。

抽出可能フィールド

このプラグインはFalcoルールで使用できる17フィールドを提供します:

フィールド説明
nginx.remote_addrstringクライアントIPアドレス
nginx.remote_userstring認証済みユーザー名
nginx.time_localstringリクエストのローカル時刻
nginx.methodstringHTTPリクエストメソッド(GET、POSTなど)
nginx.pathstringリクエストURIパス
nginx.query_stringstringクエリ文字列パラメータ
nginx.request_uristring完全なリクエストURI(パス+クエリ)
nginx.protocolstringHTTPプロトコルバージョン
nginx.statusuint64HTTPレスポンスステータスコード
nginx.bytes_sentuint64レスポンスサイズ(バイト)
nginx.refererstringHTTPリファラーヘッダー
nginx.user_agentstringHTTPユーザーエージェント
nginx.log_pathstringログファイルのパス
nginx.rawstring生のログ行
nginx.headers[key]stringHTTPリクエストヘッダー(キーベースアクセス)
nginx.test_idstringE2Eテスト識別子(X-Test-IDヘッダー)
nginx.categorystring攻撃カテゴリ(X-Categoryヘッダー)
nginx.pattern_idstringパターンID(X-Pattern-IDヘッダー)

これらのフィールドを使用したルール例

- rule: SQL Injection Attempt
  desc: nginxアクセスログでSQLインジェクションパターンを検出
  condition: nginx.request_uri contains "' OR " or nginx.request_uri contains "1=1"
  output: "SQLインジェクション検出 (client=%nginx.remote_addr path=%nginx.path)"
  priority: WARNING
  source: nginx

ドキュメント

要件

  • Falco: 0.36.0以上
  • OS: Linux x86_64
  • nginx: 1.14.0以上(combined形式のログ)

ライセンス

このプロジェクトはApache License 2.0でライセンスされています - 詳細はLICENSEファイルを参照してください。