
Ruoyi v4.8.3のバックエンドにSQLインジェクションの脆弱性があります。
filterKeyword バイパス SQLインジェクション認証必須 / 許可されたテストのみ
このリポジトリはセキュリティ研究および許可されたテストのみを目的としています。明示的な許可なくシステムに対して使用しないでください。
本リポジトリはセキュリティ研究と明確に許可されたテストのみを目的としています。未承認システムに対しては使用しないでください。
RuoYi v4.8.3 のコード生成モジュールにある /tool/gen/createTable エンドポイントは、バックエンドユーザーがテーブル作成SQLを送信することを許可します。このエンドポイントは SqlUtil.filterKeyword() を呼び出してキーワードブラックリストによるフィルタリングを行いますが、実装では入力からすべての空白文字を削除した後、末尾にスペースを含むキーワード(例:select 、insert 、drop )と照合するため、関連ルールがヒットしません。
CREATE TABLE ... AS SELECT ...(CTAS)文を使用すると、Druid の MySqlCreateTableStatement 型チェックを通過しながら SELECT を実行できます。有効なバックエンドセッションを持つ攻撃者は、これを用いてブールベースのブラインドSQLインジェクションを構築し、データベースから機密情報を読み取り、データテーブルを作成できます。
JSESSIONID を保持していること。検証スクリプトは以下のロジックで sys_user テーブルの admin ユーザーのパスワードハッシュとソルトを抽出します。
login_name、password、salt フィールドをコピーします。WHERE 句に SUBSTRING() 条件を追加します。/tool/gen/list 経由で確認できます。requests、urllib3依存パッケージのインストール:
python -m pip install requests urllib3
exp.py を開き、ファイル上部の設定領域にある以下の2行を書き換えます。
TARGET = "http://127.0.0.1:8080"
COOKIE = "JSESSIONID=your_session_id"
各項目の説明:
TARGET:テスト対象の RuoYi URL に置き換えます。(例:http://127.0.0.1:8080)COOKIE:バックエンドにログイン後に取得した有効な JSESSIONID セッションに置き換えます。書き換え後、直接実行します。
python exp.py
スクリプトは対象データベース内に中間テーブルと多数のブール判定テストテーブルを作成します。隔離環境または明示的に許可された環境でのみ使用し、テスト完了後はデータベース管理者に生成されたテーブルの削除を依頼してください。
exp.png は許可されたローカル環境での成功検証スクリーンショットです。

filterKeyword() の正規化および照合ロジックを修正してください。ただし、これを唯一の防御策としないでください。The /tool/gen/createTable endpoint in the code-generation module of RuoYi v4.8.3 accepts table-creation SQL from authenticated backend users. The endpoint calls SqlUtil.filterKeyword() to block dangerous SQL keywords. However, the implementation removes all whitespace from the input before checking blacklist entries that contain trailing spaces, such as select , insert , and drop . Those entries therefore cannot match the normalized input.
A CREATE TABLE ... AS SELECT ... (CTAS) statement can pass the Druid MySqlCreateTableStatement type check while still executing a SELECT. An attacker with a valid backend session may use this behavior for boolean-based blind SQL injection, sensitive-data extraction, and table creation.
JSESSIONID.The script recovers the admin password hash and salt from sys_user using the following oracle:
login_name, password, and salt.SUBSTRING() condition./tool/gen/list.requests, urllib3Install dependencies:
python -m pip install requests urllib3
Open exp.py and replace the following two lines in the configuration section near the top of the file:
TARGET = "http://127.0.0.1:8080"
COOKIE = "JSESSIONID=your_session_id"
Where:
TARGET is the RuoYi base URL to test, for example http://127.0.0.1:8080.COOKIE is a valid authenticated backend JSESSIONID session.After replacing the URL and session, run:
python exp.py
The script creates an intermediate table and many boolean-test tables in the target database. Use it only in an isolated or explicitly authorized environment, and have the database administrator remove the generated tables after testing.
exp.png shows a successful verification in an authorized local environment:

filterKeyword(), but do not treat it as the sole security control.exp.py - 検証スクリプト / verification scriptexp.png - 検証成功スクリーンショット / successful verification screenshotREADME.md - 日英バイリンガル脆弱性ドキュメント / bilingual vulnerability documentation