
このツールを使用すると、ユーザーが指定したJavaおよびLog4Jのバージョンについて、単純なJava WebアプリケーションがCVE-2021-44228に対して脆弱であるかどうかを検証できます。
また、[オプションで]事前定義されたいくつかの緩和策のいずれかを適用することもできます。
log4shell_validator.pyによって起動されるシミュレーションラボは、docker-composeを使用してlog4jの脆弱性を悪用し、脆弱なマシン上でRCEを獲得することをシミュレートします。
まず、いくつかのdockerイメージをビルドする必要があります。./build_images.shスクリプトがその処理を担当します。
攻撃シミュレーションは次のように行われます:
/2021-44228-via-messageへのGET呼び出しを受信すると、常にUser-Agentヘッダーフィールドをログに記録します。このアプリケーションのコードは./poc_templateの下で入手できます。./exploit.shスクリプトを実行して、脆弱なアプリにペイロードを送信します。cd marshalsec/ ;mvn clean package -DskipTests ;cd -./build-images.shを実行しますpython log4shell_validator.py --java-version 8 --log4j-version 2.12.1を実行します~/workspace/CVE-2021-44228-playground$ python log4shell_validator.py --help
usage: log4shell_validator.py [-h] [--java-version JAVA_VERSION] --log4j-version LOG4J_VERSION [--no-cleanup] [--disable-trust-url] [--remove-jndi-lookup-class] [--disable-message-lookup] [--debug]
[--exploit-via-thread-context]
log4j-vulnerability-tester
optional arguments:
-h, --help show this help message and exit
--java-version JAVA_VERSION
version of java to be used
--log4j-version LOG4J_VERSION
version of log4j to be used
--no-cleanup Don't delete used containers.
--disable-trust-url Disable the LDAP trustURLCodebase setting on the victim app
--remove-jndi-lookup-class
Remove the JNDI Lookup class from the log4j jar file
--disable-message-lookup
Disable the JNDI message lookup in the victim app's JVM
--debug Display all container's logs
--exploit-via-thread-context
By sending the payload to an HTTP handler which makes use of Custom logging with ThreadContext, attempt to bypass the no-message-lookup mitigation
このバリデータは、Java7/8のいくつかの組み合わせと異なるバージョンのLog4J2でテストされています。その他の例については、github actionsタブの拡張テストパイプラインを参照してください。
現時点では、以下の緩和策が実装されています:
-Dlog4j2.formatMsgNoLookups=Trueさらに、メッセージルックアップの無効化をバイパスできる悪用ベクターをテストするための新しいフラグが追加されました:--exploit-via-thread-context
このソフトウェアは、研究および効果的な緩和技術の開発のみを目的として作成されており、明示的に許可された場合を除き、システムへの攻撃に使用することを意図したものではありません。プロジェクトのメンテナーは、ソフトウェアの誤用について責任を負いません。責任を持って使用してください。