【问题标题】:Hive 2.0 log4j vulnerability patching issueHive 2.0 log4j 漏洞修补问题
【发布时间】:2022-01-04 10:38:34
【问题描述】:

我有一个使用 Hive 2.0.0 和 Hadoop 2.6.0 的项目,我正在研究解决最近的 log4j 漏洞。

一些选项是:

  • 将 Hive 升级到可解决该漏洞的最新版本 - 这将是一个复杂的更改,其中包含大量破坏性代码更改。
  • 修补 Hive 2.0.0 以使用解决漏洞的最新 log4j jar (2.17.1)。
  • 删除 JndiLookup.class 和其他配置设置以立即修复 - 我能够成功地做到这一点。

Hive 2.0.0 使用 log4j 版本 2.4.1,我目前正在尝试通过用 2.17.1 jar 替换 2.4.1 jar 来修补 Hive 库 目前:

./lib/ | grep log4j
log4j-1.2-api-2.4.1.jar
log4j-api-2.4.1.jar
log4j-core-2.4.1.jar
log4j-slf4j-impl-2.4.1.jar
log4j-web-2.4.1.jar

发布补丁:

./lib/ | grep log4j
log4j-1.2-api-2.17.1.jar
log4j-api-2.17.1.jar
log4j-core-2.17.1.jar
log4j-slf4j-impl-2.17.1.jar
log4j-web-2.17.1.jar

但是,Hive 服务 (cli/hiveserver2) 不会启动发布 jar 更改并在启动期间中断并出现以下错误:

ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/lib/hive-jdbc-2.0.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.logging.log4j.Logger.debug(Ljava/lang/String;Ljava/lang/Object;)V
    at org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory.<init>(YamlConfigurationFactory.java:48)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    ....
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:188)
    at org.apache.logging.log4j.core.config.ConfigurationFactory.addFactory(ConfigurationFactory.java:183)
    at org.apache.logging.log4j.core.config.ConfigurationFactory.getInstance(ConfigurationFactory.java:157)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:519)
    ....
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:221)
    at org.apache.logging.log4j.core.config.Configurator.initialize(Configurator.java:140)
    ....
    at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jDefault(LogUtils.java:121)
    at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:73)
    at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:54)
    at org.apache.hive.service.server.HiveServer2.main(HiveServer2.java:631)

对可能出现的问题有任何建议吗?或者甚至通过用最新版本替换 jar 来进行这样的修复甚至是可行的?

谢谢!!

【问题讨论】:

    标签: hadoop hive log4j slf4j


    【解决方案1】:

    停止,你不能只更换一个 jar 并希望新版本能正常工作。这可能适用于次要版本更改。 (2.4.X) 但大多数肯定不会在主要版本更改 (2.X) 上起作用

    执行此操作(如下),然后替换之前的 jar。

    关注guidance from log4j

    否则,在 2.16.0 以外的任何版本中,您可以删除 类路径中的 JndiLookup 类:zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class

    基本上就是解压jar,删除class文件,再压缩回去就可以使用了。如果你这样做了,你就很好。您需要等待 apache 的 Hive 新版本才能获得 log4j 的升级版本。

    【讨论】:

    • 嗨,有人成功修补了 hive 中的 log4j 吗?
    猜你喜欢
    • 2022-01-17
    • 1970-01-01
    • 2022-01-17
    • 2022-01-22
    • 1970-01-01
    • 2022-01-16
    • 2022-01-18
    • 2015-05-03
    • 2022-01-18
    相关资源
    最近更新 更多