LoginSignup
0
0

More than 1 year has passed since last update.

Apache Log4j 脆弱性「CVE-2021-44228」について調べたこと

Last updated at Posted at 2021-12-18

はじめに

  • 2021年12月よりアナウンスされている Apache Log4j の脆弱性「CVE-2021-44228」について個人的に調べたことを記載します。

Apache Log4j について

  • The Apache Software Foundation が提供している Java のロギング用ライブラリです。
  • 2021年時点では、Apache Log4j 1.x を継ぐ、Apache Log4j 2 でアップデートが行われています。
  • Apache Log4j 2 では、log4j2.xml というログフォーマットやログレベル等の定義ファイルをもとに、プログラムでログを出力します。

CVE について

  • MITRE により掲載されている、サイバーセキュリティ関連の脆弱性情報の一覧が該当します。
  • 世界各国のサイバーセキュリティ製品やサービスで脆弱性の影響の有無がアナウンスされる場合に、CVE の番号が使われています。

CVE-2021-44228 について調べたこと

  • スコア

    • NVD (アメリカ国立標準技術研究所が管理する脆弱性情報のデータベース) の 掲載情報 では、本脆弱性はスコアの上限である「10.0 (Critical)」に該当すると記載されています。
  • 脆弱性内容

    • Apache Log4j の掲載内容より、本脆弱性は JNDI Lookup の機能に起因する RCE (Remote Code Execution) 攻撃が成立する可能性があるとの内容が読み取れます。
    • 以下を満たしている場合、攻撃者が用意したサーバ(JNDI でアクセス可能な LDAP サーバ等)から Java コードが取得され、実行される可能性があることも読み取れます。
      • プログラムで、Log4j2 の機能によりユーザからの入力値をログに出力していること
      • ユーザからの入力値に、攻撃者が用意したサーバへの JNDI Lookup が含まれていること
※引用: Apache Log4j 2「Important: Security Vulnerability CVE-2021-44228」
  閲覧日: 12/19
  URL: https://logging.apache.org/log4j/2.x/

...(中略)...

Important: Security Vulnerability CVE-2021-44228
The Log4j team has been made aware of a security vulnerability, CVE-2021-44228, that has been addressed in Log4j 2.12.2 and Log4j 2.16.0.

Summary
Log4j’s JNDI support has not restricted what names could be resolved. Some protocols are unsafe or can allow remote code execution.

Details
One vector that allowed exposure to this vulnerability was Log4j’s allowance of Lookups to appear in log messages. This meant that when user input is logged, and that user input contained a JNDI Lookup pointing to a malicious server, then Log4j would resolve that JNDI Lookup, connect to that server, and potentially download serialized Java code from that remote server. This in turn could execute any code during deserialization. This is known as a RCE (Remote Code Execution) attack.
...
  • 緩和策

    • 緩和策として、以下が挙げられています。
    • Java 8 以上を利用している場合は 2.16.0、Java 7 では 2.12.2 にアップデートすること
      • ※2021/12/28 時点では、Java 8 以上用に 2.17.1 がリリースされています。
    • それ以外は、JndiLookup.class を log4j-core-*.jar から削除すること
※引用: Apache Log4j 2「Fixed in Log4j 2.15.0 (Java 8)」
  閲覧日: 12/19
  URL: https://logging.apache.org/log4j/2.x/security.html

...(中略)...

Log4j 2.x mitigation
Implement one of the following mitigation techniques:

* Java 8 (or later) users should upgrade to release 2.16.0.
* Java 7 users should upgrade to release 2.12.2.
* Otherwise, in any release other than 2.16.0, you may remove the JndiLookup class from the classpath: zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
Note that only the log4j-core JAR file is impacted by this vulnerability. Applications using only the log4j-api JAR file without the log4j-core JAR file are not impacted by this vulnerability.

Also note that Apache Log4j is the only Logging Services subproject affected by this vulnerability. Other projects like Log4net and Log4cxx are not impacted by this.

同時期にアナウンスされた他の脆弱性について

  • 上記以外にも Apache Log4j 2 関連の脆弱性がアナウンスされています。

CVE-2021-45046

  • NVD では、スコアを「9.0(Critical)」と判断しています。
  • JNDI Lookup の機能に起因し、DOS 攻撃が成立する可能性があることがアナウンスされています。
  • 「CVE-2021-44228」の脆弱性と同じ緩和策が挙げられています。
    • それ以外のシステムプロパティ「log4j2.formatMsgNoLookups」を "true" に設定する方法等は対策として不十分とのアナウンスが出ています。

CVE-2021-45105

  • NVD では、スコアは「5.9(Moderate)」と判断しています。「CVE-2021-44228」や「CVE-2021-45046」よりは低い深刻さであると判断されています。
  • ロギングの設定にて、デフォルト以外の PatternLayout で「$${ctx:【key】}」等の Context Lookup を利用する場合、DOS 攻撃が成立する可能性があることがアナウンスされています。
  • 2.17.0 へのアップデート、PatternLayout で Context Lookup の利用部分を Thread Context Map patterns(%X{【key】} 等)の利用に置き換えること等が緩和策として挙げられています。

CVE-2021-44832

  • NVD では、スコアを「6.6(Moderate)」と判断しています。「CVE-2021-45105」並の深刻さと判断されています。
  • 攻撃者がロギングの設定ファイルに対して編集権限がある場合、本ファイルで JDBC Appender のデータソースがリモートコードを実行できる JNDI URI を参照するように設定され、RCE 攻撃が成立する可能性があることがアナウンスされています。
  • 2.17.1 へのアップデート、以前のバージョンでは JDBC Appender を使用している場合に Java 以外のプロトコルを使用するよう設定がされていないことを確認することが緩和策として挙げられています。

参考資料

https://logging.apache.org/log4j/2.x/
https://logging.apache.org/log4j/2.x/security.html
https://logging.apache.org/log4j/2.x/manual/thread-context.html
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228
https://nvd.nist.gov/vuln/detail/CVE-2021-44228

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0