下沙论坛

标题: Apache Log4j2 远程代码执行漏洞 [打印本页]

作者: 煎饼    时间: 2021-12-15 10:10
标题: Apache Log4j2 远程代码执行漏洞
漏洞描述

Apache Log4j2 是一个基于 Java 的日志记录工具。该工具重写了 Log4j 框架,并且引入了大量丰富的特性。该日志框架被大量用于业务系统开发,用来记录日志信息。

在大多数情况下,开发者可能会将用户输入导致的错误信息写入日志中。攻击者利用此特性可通过该漏洞构造特殊的数据请求包,最终触发远程代码执行。由于该漏洞影响范围极广,建议广大用户及时排查相关漏洞,经过白帽汇安全研究院分析确认,目前市面有多款流行的系统都受影响。

该漏洞危害等级:严重

影响范围

Apache Log4j 2.x < 2.15.0-rc2

已知影响组件受影响开源组件
项目
仓库地址
版本

% b9 w! c/ X2 ?2 Q: pelasticsearch(org.elasticsearch)https://github.com/elastic/elasticsearch8.0.0-alpha2 等(共 100 个)
6 c) L6 Z, {; ospring-webflux(org.springframework)https://github.com/spring-projects/spring-framework5.2.6.RELEASE 等(共 40 个)
" v* ]: e" t+ n! E+ ]$ idruid(com.alibaba)https://github.com/alibaba/druid1.2.8 等(共 68 个)+ @7 q5 C( j$ ~8 B4 `# H5 z
hystrix-rx-netty-metrics-stream(com.netflix.hystrix)https://github.com/Netflix/Hystrix1.5.4 等(共 2 个): X# I) x: }5 |: H
spring-cloud-starter-alibaba-sentinel(com.alibaba.cloud)https://github.com/alibaba/spring-cloud-alibaba2021.1 等(共 14 个)
6 Y# V! C) A3 j! r2 Mspring-boot-starter-ahas-sentinel-client(com.alibaba.csp)https://github.com/alibaba/Sentinel1.3.2 等(共 17 个)7 V( m( M0 G* f
redisson(org.redisson)https://github.com/redisson/redisson2.2.24 等(共 3 个)+ V# T! h% E/ x6 |/ F
HikariCP(com.zaxxer)https://github.com/brettwooldridge/HikariCP5.0.0 等(共 27 个)
8 h/ A, R  z+ Kzipkin-collector-service(io.zipkin)https://github.com/openzipkin/zipkin1.40.2 等(共 27 个)
" R, O" [+ ~! a* Q& a5 Vmybatis-plus(com.baomidou)https://github.com/baomidou/mybatis-plus3.4.3.4 等(共 41 个)4 m* n( ?  `0 t0 d1 ?7 q" Y9 _
zuul-sample(com.netflix.zuul)https://github.com/Netflix/zuul2.3.0 等(共 10 个)5 i+ ?* G3 t  R$ e0 a' H* l! b
watson-data-api-client(com.ibm.watson.data)https://github.com/OpenAPITools/openapi-generator0.1 等(共 1 个). @9 I: y! Z( ~
spring-boot-admin-sample-consul(de.codecentric)https://github.com/codecentric/spring-boot-admin2.5.4 等(共 40 个)
3 d( u  [( p7 T, T  cjedis(redis.clients)https://github.com/redis/jedisjedis-3.6.2 等(共 36 个)7 t6 K: Z& p0 F7 G; R
grpc-benchmarks(io.grpc)https://github.com/grpc/grpc-java1.9.1 等(共 65 个)( W! s2 e. b# W0 J
ktor-client-json-tests(io.ktor)https://github.com/ktorio/ktor1.6.7 等(共 32 个)) Z4 e0 A0 ~1 b& h: J& n
gitbucket_2.13(io.github.gitbucket)https://github.com/gitbucket/gitbucket4.32.0 等(共 27 个)
+ D( [  d7 v5 k) Ifinagle-zipkin_2.12(com.twitter)https://github.com/twitter/finagle7.1.0 等(共 56 个)) e, M2 F; R/ i) m+ z$ @% h- [
resilience4j-vertx(io.github.resilience4j)https://github.com/resilience4j/resilience4j0.9.0 等(共 9 个)& \6 Z& n, A; M- z* A" J) L
elasticsearch-sql(org.nlpcn)https://github.com/NLPchina/elasticsearch-sql6.8.13.0 等(共 9 个)
9 N) \' `+ H7 M: |exposed-spring-boot-starter(org.jetbrains.exposed)https://github.com/JetBrains/Exposed0.36.2 等(共 11 个)
* _9 L' W" z/ r- D  M% ], Gblade-sql2o(com.bladejava)https://github.com/lets-blade/blade1.2.9 等(共 1 个)  T. e; w) d* y6 h
netty-socketio(com.corundumstudio.socketio)https://github.com/mrniko/netty-socketio1.7.19 等(共 8 个)  [: F  _0 }6 X  o; M% W
springfox-swagger2(io.springfox)https://github.com/springfox/springfox2.10.5 等(共 6 个)
  \3 [; ?' N8 y1 nmain_2.12(org.scala-sbt)https://github.com/sbt/sbt1.6.0-RC1 等(共 88 个)2 J1 c/ |- ^2 w* [+ Z5 D# R& _8 q. k
lettuce-core(io.lettuce)https://github.com/lettuce-io/lettuce-core6.1.5.RELEASE 等(共 42 个)% {% F5 j/ d0 ?. L& T# U
repository-azure(org.opensearch.plugin)https://github.com/opensearch-project/OpenSearch1.2.0 等(共 3 个): J! v7 m0 z( \* T+ L' D4 Y
reactor-test(io.projectreactor)https://github.com/reactor/reactor-core3.3.4.RELEASE 等(共 3 个)" n/ H+ X  N7 f7 I; j- w& S
corda-webserver-impl(net.corda)https://github.com/corda/cordacorda-3.0 等(共 32 个)8 G8 ?6 v+ O* z; A8 Q% I
conductor-redis-persistence(com.netflix.conductor)https://github.com/Netflix/conductor3.3.6 等(共 100 个)7 J- i' f! m/ K8 d( ?8 b
armeria(com.linecorp.armeria)https://github.com/line/armeria0.26.1.Final 等(共 2 个)& N% C7 l4 K8 V7 y1 Z
breeze-parent_2.13(org.scalanlp)https://github.com/scalanlp/breeze2.0.1-RC1 等(共 5 个)% b0 t" N; C+ U" B- h" E' v
micrometer-core(io.micrometer)https://github.com/micrometer-metrics/micrometer1.8.1 等(共 98 个)
8 [8 b. g4 [9 j6 O& r' falink_connector_jdbc_sqlite_flink-1.9_2.11(com.alibaba.alink)https://github.com/alibaba/Alink1.5.1 等(共 3 个)
3 B5 S3 L4 D; [& k% {, q- tinitializr-actuator(io.spring.initializr)https://github.com/spring-io/initializr0.9.0 等(共 6 个)9 e; F& p" h9 D' K! }
telegrambots-spring-boot-starter(org.telegram)https://github.com/rubenlagus/TelegramBots4.9.1 等(共 17 个)2 Z+ @( `/ q( J* t! N
spring-data-elasticsearch(org.springframework.data)https://github.com/spring-projects/spring-data-elasticsearch4.3.0 等(共 86 个)
1 x6 H( J8 D) q1 B* ]feast-common(dev.feast)https://github.com/feast-dev/feast0.9.2 等(共 26 个)
2 e3 C, r+ c5 Wjavamelody-core(net.bull.javamelody)https://github.com/javamelody/javamelody1.88.0 等(共 13 个)$ ~5 S: G' k! L4 M
analytics-zoo-bigdl_0.13.0-spark_3.0.0(com.intel.analytics.zoo)https://github.com/intel-analytics/analytics-zoo0.11.0-RC1 等(共 4 个), o* l! k' d% B( v
scio-tensorflow_2.13(com.spotify)https://github.com/spotify/scio0.9.6 等(共 97 个)( A5 o+ O7 [/ ?2 a9 M8 g/ ~
grpc-client-spring-boot-autoconfigure(net.devh)https://github.com/yidongnan/grpc-spring-boot-starter2.9.0.RELEASE 等(共 16 个)
( l# J% @, X( v0 U, i% y8 f+ Xinject-server_2.12(com.twitter)https://github.com/twitter/finatra21.9.0 等(共 56 个)& _/ W9 }' S' @9 R5 g- V
client-java-examples(io.kubernetes)https://github.com/kubernetes-client/java8.0.2 等(共 1 个)
7 r8 k) B/ ^* J/ x" rreactivesocket-tck-drivers(io.reactivesocket)https://github.com/rsocket/rsocket-java0.6.0 等(共 1 个)* J0 t0 h  h; _; O
jest-droid(io.searchbox)https://github.com/searchbox-io/Jest6.3.1 等(共 8 个)
  n- g8 ~* Y( [# w* }. [6 @8 E1 pgraphql-dgs-example-java-webflux(com.netflix.graphql.dgs)https://github.com/Netflix/dgs-framework4.9.7 等(共 36 个)+ i5 }$ S+ _0 ?  ]
quill-jdbc-monix_2.11(io.getquill)https://github.com/getquill/quill3.9.0 等(共 62 个)% j# x: q* c) i- }9 f3 y
doobie-quill_2.12(org.tpolecat)https://github.com/tpolecat/doobie1.0.0-RC1 等(共 61 个)# g" S* Q: Y( _) }6 ]
http4k(org.http4k)https://github.com/http4k/http4k4.3.4.1 等(共 3 个). S" b! V6 O+ A" Y
elasticsearch-hadoop(org.elasticsearch)https://github.com/elastic/elasticsearch-hadoop8.0.0-beta1 等(共 100 个)# Y: c9 I& N" d3 v  {
sbt-shading(io.get-coursier)https://github.com/coursier/coursier1.0.0-RC8 等(共 1 个)" ]7 G8 n! h, C) j0 `
spark-cassandra-connector-unshaded_2.10(com.datastax.spark)https://github.com/datastax/spark-cassandra-connector2.0.9 等(共 54 个): n$ \  B3 S% r3 C
webdrivermanager(io.github.bonigarcia)https://github.com/bonigarcia/webdrivermanager4.0.0 等(共 15 个)8 y9 u" X4 \) e6 `( Q7 q
common-auth-v3(com.tencent.bk.devops.ci.common)https://github.com/Tencent/bk-ci1.2.0-rc.7-RELEASE 等(共 3 个)
- @* U' x; i4 W3 ]& G% O) M0 preactor-netty(io.projectreactor.netty)https://github.com/reactor/reactor-netty1.0.9 等(共 75 个)
1 D7 |9 }6 Q0 s' l) i* S9 I" E2 u; s% yevcache-client-sample(com.netflix.evcache)https://github.com/Netflix/EVCache5.18.9 等(共 63 个)- ~9 A0 ^1 E2 x+ O' C( J) c4 F
xtdb-test(com.xtdb)https://github.com/xtdb/xtdb1.20.0 等(共 9 个)
# I( R) m' A' S3 {: D7 Ktransport-netty4(com.strapdata.elasticsearch.plugin)https://github.com/strapdata/elassandra6.2.3.31 等(共 14 个)( A0 i& k5 b7 t8 F9 J
sbt-metals(org.scalameta)https://github.com/scalameta/metals0.9.9 等(共 17 个)
* E: ^. d! M9 y6 E, relastic4s-embedded_2.12(com.sksamuel.elastic4s)https://github.com/sksamuel/elastic4s6.7.8 等(共 100 个)
* i7 A! a/ l* X0 ^& `genie-agent(com.netflix.genie)https://github.com/Netflix/genie4.0.4 等(共 100 个)5 i3 a; |- X- m
spring-kafka(org.springframework.kafka)https://github.com/spring-projects/spring-kafka2.7.9 等(共 79 个)) O7 \1 c2 d$ g  ^
db-async-common_2.13(com.dripower)https://github.com/mauricio/postgresql-async0.3.109 等(共 19 个)
0 N% J  g: z, Oselenide(com.codeborne)https://github.com/selenide/selenide5.25.0-selenium-4.0.0-rc-2 等(共 18 个)3 E5 ^2 N$ c; x3 F, h* p+ I# @
cloudfoundry-identity-server(org.cloudfoundry.identity)https://github.com/cloudfoundry/uaa4.30.0 等(共 1 个)) l& J3 O5 j+ p$ q
servo-atlas(com.netflix.servo)https://github.com/Netflix/servo0.13.2 等(共 20 个)8 p( i0 o# i; S# f% o* W) a
rxnetty-spectator-tcp(io.reactivex)https://github.com/ReactiveX/RxNetty0.5.3-rc.4 等(共 12 个). O% b# r7 t" Q: s# }, t/ O$ m) B& U
mleap-tensorflow_2.10(ml.combust.mleap)https://github.com/combust/mleap0.9.6 等(共 25 个)) ~0 t$ K+ ^. F% V
spark-testing-base_2.12(com.holdenkarau)https://github.com/holdenk/spark-testing-base2.4.4_1.1.1 等(共 100 个); _! r/ I4 N2 \  c0 b8 H0 Q# c
graphql-kotlin-spring-client(com.expediagroup)https://github.com/ExpediaGroup/graphql-kotlin5.0.0-alpha.0 等(共 20 个)5 U6 m, a5 z$ d8 \2 ?
graphql-spring-boot-test-autoconfigure(com.graphql-java-kickstart)https://github.com/graphql-java-kickstart/graphql-spring-boot8.1.1 等(共 33 个)
- }- H! i; E; K; D. ?0 X% z5 Jdiscord4j-rest(com.discord4j)https://github.com/Discord4J/Discord4J3.2.1 等(共 15 个)
2 s: ~! ~- ?4 h/ \twitter-server-logback-classic_2.13(com.twitter)https://github.com/twitter/twitter-server21.9.0 等(共 54 个)- X/ s% Q9 [6 v+ I
synthea(org.mitre.synthea)https://github.com/synthetichealth/synthea2.7.0 等(共 2 个)
3 i6 ?& p6 g  U! y$ uspring-integration-redis(org.springframework.integration)https://github.com/spring-projects/spring-integration5.5.6 等(共 30 个)6 l9 N9 _) Y! o% g% E, W$ @
cyclops-reactor-integration(com.oath.cyclops)https://github.com/aol/cyclops10.4.0 等(共 1 个)
" t, V, Z: f9 {- f1 `6 Makka-stream-alpakka-geode_2.12(com.lightbend.akka)https://github.com/akka/alpakka1.0-M1 等(共 13 个)
9 P* M- T+ h. w: V5 ~2 C% ?4 t% y3 N2 Qmantis-client(io.mantisrx)https://github.com/Netflix/mantis1.3.9 等(共 83 个)- w( F5 u6 i3 N( y# }9 F
mybatis-generator-plugin(com.itfsw)https://github.com/itfsw/mybatis-generator-plugin1.2.9 等(共 31 个)0 G, u9 v1 b$ n7 _% E* Z1 V
ktorm-support-sqlserver(org.ktorm)https://github.com/kotlin-orm/ktorm3.3.0 等(共 11 个)
6 w3 B8 X: f, a  B5 |( j- _gatk(org.broadinstitute)https://github.com/broadinstitute/gatk4.beta.2 等(共 39 个)
7 ^( _4 @, I  L; v" iazure-messaging-servicebus(com.azure)https://github.com/Azure/azure-sdk-for-java7.5.1 等(共 100 个)5 T% R% A: L" o
mica-metrics(net.dreamlu)https://github.com/lets-mica/mica2.5.7 等(共 7 个)
  w3 q; Z- }/ i: A  B- qshiro-redis(org.crazycake)https://github.com/alexxiyang/shiro-redis3.3.1 等(共 2 个)& h% \0 {. o% S  K# |
enumeratum-play_2.12(com.beachape)https://github.com/lloydmeta/enumeratum1.5.16 等(共 2 个)' h" x9 @+ {/ e' h
jdonframework(org.jdon)https://github.com/banq/jdonframework6.6.8 等(共 1 个)
2 }' q0 W$ _& i1 mweid-java-sdk(com.webank)https://github.com/WeBankBlockchain/WeIdentity1.8.1 等(共 3 个); \% V" y6 `4 i9 p5 w4 ^
log-protocol(io.shulie.pradar)https://github.com/shulieTech/Takin2.0.3 等(共 3 个)
( s+ h4 Z$ Y  h# h; Tmicro-boot(com.oath.microservices)https://github.com/aol/micro-server1.2.6 等(共 38 个)- s4 c7 c# ]$ K3 s7 i3 r
sparkling-water-package_2.11(ai.h2o)https://github.com/h2oai/sparkling-water2.4.10 等(共 36 个)) e: L7 x, c9 Z) G0 j) a' \, ]; c
scalatest_2.13(au.com.dius.pact.provider)https://github.com/pact-foundation/pact-jvm4.2.4 等(共 5 个)
. B& C  a7 ?7 K2 E, ?0 ?mssql-jdbc(com.microsoft.sqlserver)https://github.com/microsoft/mssql-jdbc8.3.0.jre11-preview 等(共 100 个)
- u" A) |! Y. T+ Qelide-spring-boot-starter(com.yahoo.elide)https://github.com/yahoo/elide6.0.3 等(共 45 个)3 ]1 ?4 |; ~" l1 \9 f5 w
kafka-connect-elastic5(com.datamountaineer)https://github.com/lensesio/stream-reactor1.2.0 等(共 5 个)0 P9 `) p! N4 W1 ~2 r
kvision-server-spring-boot-jvm(io.kvision)https://github.com/rjaros/kvision5.4.3 等(共 9 个)
  `9 B: t! R0 b( H5 x9 B; G$ nr2dbc-postgresql(org.postgresql)https://github.com/pgjdbc/r2dbc-postgresql0.9.0.RC1 等(共 8 个)
& ]1 q# f% M' hplay-slick-evolutions_2.13(com.typesafe.play)https://github.com/playframework/play-slick5.0.0-RC3 等(共 29 个)+ X  P9 t" r% i" u( ?  e
sbt-bloop-core(ch.epfl.scala)https://github.com/scalacenter/bloop1.4.8-43-c2d941d9 等(共 29 个)
- \- }0 h+ b! J( cjcseg-elasticsearch(org.lionsoul)https://github.com/lionsoul2014/jcseg2.6.2 等(共 7 个)

更多受影响组件查询,请点击以下链接查询:https://log4j2.huoxian.cn/

漏洞排查

代码排查:查看 pom.xml 是否引入 org.apache.logging.log4j、org.apache.logging.log4j2

Linux:

sudo find / -name "*log4j-*.jar"

Windows:

*log4j*.jar

攻击排查

日志排查:

攻击者在利用前通常采用dnslog方式进行扫描、探测,对于常见利用方式可通过应用系统报错日志中的

"javax.naming.CommunicationException"

"javax.naming.NamingException: problem generating object using object factory"

"Error looking up JNDI resource"关键字进行排查。

流量排查:

攻击者的数据包中可能存在:“${jndi:rmi”、“${jndi:ldap”字样,可根据此类关键字进行排查。

漏洞复现

Vulfocus 靶场环境

目前 Vulfocus 已经集成 Log4j2 环境,可通过以下链接启动环境测试:

http://vulfocus.fofa.so/#/dashboard?image_id=3b8f15eb-7bd9-49b2-a69e-541f89c4216c

也可通过 docker pull vulfocus/log4j2-rce-2021-12-09:latest 拉取本地环境运行,本地启动命令:docker run -d -P vulfocus/log4j2-rce-2021-12-09:latest

修复建议

1、禁止使用 log4j 服务器外连,升级 idk 11.0.1 8u191 7u201 6u211 或更高版本。

2、升级至 log4j-2.15.0-rc2:

     下载地址:https://github.com/apache/logging-log4j2/releases/tag/log4j-2.15.0-rc2

3、紧急缓解措施:

(1) 修改 jvm 参数 -Dlog4j2.formatMsgNoLookups=true

(2) 修改配置 log4j2.formatMsgNoLookups=True

(3) 将系统环境变量 FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS 设置 为 true

参考

[1] https://github.com/apache/logging-log4j2/releases/tag/log4j-2.15.0-rc1

[2] [LOG4J2-3201] Limit the protocols jNDI can use and restrict LDAP. - ASF JIRA (apache.org)

[3] ASF Git Repos - logging-log4j2.git/blob - log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/JndiRestrictedLookupTest.java

[4] https://mp.weixin.qq.com/s/wC7mrK1Y4DYz9_yW4fLzbw

[5] https://help.aliyun.com/noticelist/articleid/1060971232.html

[6] https://mp.weixin.qq.com/s/C4zeXHKHDqPeRuLytO7Fzw

) n* {- ^/ `4 d0 U, q/ R9 J

via https://nosec.org/home/detail/4917.html

- E+ U. }- X1 U1 L2 q





欢迎光临 下沙论坛 (http://bbs.xiasha.cn/) Powered by Discuz! X3.3