# Log4Shell

**Log4Shell**是CVE-2021-44228的业界通用名称，这是Apache Log4j中的一个严重远程代码执行漏洞。Apache Log4j是一款被广泛使用的开源Java日志库，受影响版本为2.0-beta9至2.14.1，该漏洞于2021年12月10日公开披露<sup>[1](https://media.defense.gov/2021/Dec/22/2002914139/-1/-1/0/JOINT_CSA_MITIGATING_LOG4SHELL_OTHER_LOG4J_VULNERABILITIES_20211222_.PDF)</sup>。该漏洞允许攻击者提交特制的字符串，库在记录该字符串时对其进行求值，从而在存在漏洞的服务器上运行任意代码；披露后数小时内，该漏洞便在互联网上遭到大规模利用<sup>[1](https://media.defense.gov/2021/Dec/22/2002914139/-1/-1/0/JOINT_CSA_MITIGATING_LOG4SHELL_OTHER_LOG4J_VULNERABILITIES_20211222_.PDF)</sup><sup> • </sup><sup>[2](https://arxiv.org/abs/2205.02544)</sup>。

| 关键事实 | 详情 |
|---|---|
| 标识符与类型 | CVE-2021-44228，Apache Log4j 2中的未认证远程代码执行<sup>[1](https://media.defense.gov/2021/Dec/22/2002914139/-1/-1/0/JOINT_CSA_MITIGATING_LOG4SHELL_OTHER_LOG4J_VULNERABILITIES_20211222_.PDF)</sup><sup> • </sup><sup>[3](https://www.youtube.com/watch?v=HZ-itJEaFy0)</sup> |
| 受影响版本 | Log4j 2.0-beta9至2.14.1，2.3.1、2.12.2和2.12.3中提供了向后移植的修复<sup>[1](https://media.defense.gov/2021/Dec/22/2002914139/-1/-1/0/JOINT_CSA_MITIGATING_LOG4SHELL_OTHER_LOG4J_VULNERABILITIES_20211222_.PDF)</sup><sup> • </sup><sup>[4](https://github.com/advisories/GHSA-jfh8-c2jp-5v3q)</sup> |
| 根本原因 | JNDI功能（如消息查找替换）未对攻击者控制的LDAP、DNS及其他JNDI端点加以防护<sup>[5](https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-356a)</sup> |
| 相关CVE | CVE-2021-45046和CVE-2021-45105在同一份联合公告中得到处理；CVE-2021-44832甚至影响2.17.0版本<sup>[5](https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-356a)</sup><sup> • </sup><sup>[6](https://www.itpro.com/security/zero-day-exploit/361819/what-is-log4shell-log4j-vulnerability)</sup> |
| 政府响应 | 美国网络安全和基础设施安全局（CISA）于2021年12月17日发布第22-02号紧急指令；各国网络安全机构联合发布公告AA21-356A<sup>[7](https://sscsecurity.dev/book1/chapter-05/ch-5.2/)</sup><sup> • </sup><sup>[5](https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-356a)</sup> |
| 长期状态 | 网络安全审查委员会将其描述为“长期存在的”风险；披露后数年仍持续遭到利用<sup>[8](https://www.axios.com/2022/12/09/log4j-year-anniversary-cybersecurity)</sup><sup> • </sup><sup>[9](https://arxiv.org/abs/2601.04281)</sup> |

## 漏洞原理

Log4j是一个日志库：应用程序调用它来记录关于请求、错误及其他事件的消息，而其中大量内容来自不受信任的用户。Log4j 2支持查找替换，即日志消息中形如`${...}`的文本会被替换为某个命名来源的值。受支持的来源之一是JNDI，即Java命名和目录接口，它可以通过LDAP、DNS和RMI等网络协议获取对象<sup>[5](https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-356a)</sup><sup> • </sup><sup>[10](https://www.ibm.com/think/topics/log4shell)</sup>。

因此，攻击者可以将诸如`${jndi:ldap://...}`的字符串放入任何被记录的输入中，例如user-agent请求头。当存在漏洞的Log4j版本处理该消息时，会执行JNDI查找，联系攻击者控制的服务器。最具破坏性的变体利用LDAP或RMI使目标加载并执行攻击者提供的Java代码，从而在无需认证的情况下实现远程代码执行；而基于DNS的变体（如`${jndi:dns://...}`）则触发特制的DNS请求，可用于未经授权的信息泄露<sup>[10](https://www.ibm.com/think/topics/log4shell)</sup><sup> • </sup><sup>[11](https://research.checkpoint.com/2021/the-laconic-log4shell-faq/)</sup>。受影响的组件具体为`org.apache.logging.log4j:log4j-core`包<sup>[4](https://github.com/advisories/GHSA-jfh8-c2jp-5v3q)</sup>。

由于Log4j被打包在数千种产品内部，而且往往作为开发者并不知晓的间接依赖存在，识别受影响的系统本身就是一项艰巨任务<sup>[6](https://www.itpro.com/security/zero-day-exploit/361819/what-is-log4shell-log4j-vulnerability)</sup><sup> • </sup><sup>[12](https://www.axios.com/2021/12/15/log4j-open-source-cybersecurity-flaw)</sup>。

## 披露与响应时间线

- **2021年11月30日**：Apache开始着手修复该问题，即后来的CVE-2021-44228<sup>[7](https://sscsecurity.dev/book1/chapter-05/ch-5.2/)</sup>。
- **2021年12月9日**：相关细节出现在Twitter和中国博客上，随后全面公开披露；安全研究人员报告了该日志库代码中的缺陷<sup>[7](https://sscsecurity.dev/book1/chapter-05/ch-5.2/)</sup><sup> • </sup><sup>[13](https://www.cisecurity.org/log4j-zero-day-vulnerability-response)</sup>。
- **2021年12月10日**：该漏洞被公开披露，大规模利用随即开始<sup>[1](https://media.defense.gov/2021/Dec/22/2002914139/-1/-1/0/JOINT_CSA_MITIGATING_LOG4SHELL_OTHER_LOG4J_VULNERABILITIES_20211222_.PDF)</sup><sup> • </sup><sup>[2](https://arxiv.org/abs/2205.02544)</sup>。
- **2021年12月17日**：CISA发布第22-02号紧急指令，命令联邦民用机构按加速时间表识别并修复Log4Shell<sup>[7](https://sscsecurity.dev/book1/chapter-05/ch-5.2/)</sup>。
- **2021年12月22日**：CISA、联邦调查局（FBI）、国家安全局（NSA）以及澳大利亚、加拿大、新西兰和英国的网络安全机构联合发布公告AA21-356A，指出高级威胁行为者正在积极扫描网络以利用Log4Shell及相关CVE<sup>[5](https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-356a)</sup>。
- **2021年12月28日**：修复Log4j2库中已知漏洞的补丁发布<sup>[14](https://www.theseus.fi/bitstream/10024/860539/2/Thesis_Matias_Mesi%C3%A4.pdf)</sup>。

CISA副局长埃里克·戈尔茨坦（Eric Goldstein）称该漏洞“极其令人担忧”，原因在于Log4j使用范围极广、利用难度极低，且能让攻击者从目标系统上窃取信息<sup>[12](https://www.axios.com/2021/12/15/log4j-open-source-cybersecurity-flaw)</sup>。CISA局长珍·伊斯特利（Jen Easterly）称这是她见过的最严重的漏洞之一<sup>[15](https://www.axios.com/2021/12/29/china-log4j-flaw)</sup>。攻击者行动迅速：[CrowdStrike](https://www.edgepedia.org/zh/crowdstrike)报告称一个中国团伙通过VMware软件利用该漏洞攻击了一家大型学术机构<sup>[15](https://www.axios.com/2021/12/29/china-log4j-flaw)</sup>，CISA的公告也提到针对VMware Horizon和Unified Access Gateway的利用<sup>[14](https://www.theseus.fi/bitstream/10024/860539/2/Thesis_Matias_Mesi%C3%A4.pdf)</sup>。

## 缓解措施

首要修复方法是升级Log4j。由于第一个补丁2.15.0被证明不够充分，指导意见最终统一到2.17.0或更高版本，同时为较旧的发布线提供了向后移植的修复，版本为2.3.1、2.12.2和2.12.3<sup>[4](https://github.com/advisories/GHSA-jfh8-c2jp-5v3q)</sup>。在无法升级的情况下，对于2.0-beta9及以后的版本，推荐的临时措施是从类路径中移除`JndiLookup`类，例如使用`zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class`<sup>[11](https://research.checkpoint.com/2021/the-laconic-log4shell-faq/)</sup>。

一些早期缓解措施未能奏效。将系统属性`log4j2.formatMsgNoLookups`或环境变量`LOG4J_FORMAT_MSG_NO_LOOKUPS`设为true，后来被证明对该漏洞无效，已不再推荐<sup>[16](https://www.sophos.com/en-us/blog/log4shell-response-and-mitigation-recommendations)</sup>。荷兰国家网络安全中心（NCSC）的检测指南强调，仅打补丁是不够的，因为日志消息中的JNDI字符串总是首先被求值，在任何其他处理之前就会发出DNS、LDAP或RMI请求<sup>[17](https://github.com/NCSC-NL/log4shell/blob/main/detection_mitigation/README.md)</sup>。

Log4j 1.x需要单独处理：Apache于2015年宣布该分支生命周期结束，不再修复针对它的漏洞，并建议用户升级到Log4j 2<sup>[18](https://logging.apache.org/log4j/2.x/security.html)</sup>。

## 持续性与长期影响

网络安全审查委员会为美国国土安全部审查了2021年12月的Log4j事件，一年后将该问题描述为“长期存在的”问题，意即它在整个软件生态系统中仍是持续存在的风险，而非一次性事件<sup>[8](https://www.axios.com/2022/12/09/log4j-year-anniversary-cybersecurity)</sup><sup> • </sup><sup>[19](https://www.cisa.gov/resources-tools/groups/cyber-safety-review-board-csrb)</sup>。许多组织缺乏其网络中产品和依赖项的清单，因此难以确定自己是否受到影响<sup>[8](https://www.axios.com/2022/12/09/log4j-year-anniversary-cybersecurity)</sup>。

补丁发布很久之后，该漏洞仍留在攻击者的清单上。CISA、FBI、NSA以及澳大利亚、加拿大、新西兰和英国的网络安全机构共同编写的2023年最常被利用漏洞联合公告，将CVE-2021-44228列为恶意行为者在2023年经常利用的漏洞之一，将其归类为通过表达式语言注入实现的远程代码执行<sup>[20](https://www.cyber.gov.au/sites/default/files/2024-11/2023-top-routinely-exploited-vulnerabilities.pdf)</sup>。对CISA已知被利用漏洞目录的分析将Log4Shell与库级漏洞归为一类，这类漏洞因现有工具难以稳定识别和修复而持续多年<sup>[21](https://www.runzero.com/uploads/documents/reports/KEVology-An-analysis-of-exploits-scores-and-timelines-on-the-CISA-KEV.pdf)</sup>。

测量研究证实了长尾效应。一项网络望远镜研究发现，Log4Shell利用在披露后持续数年，活动集中在少数反复出现的扫描器和回调基础设施上，且载荷混淆有所增加<sup>[9](https://arxiv.org/abs/2601.04281)</sup>。对真实世界暴露情况的调查揭示了原因：Veracode 2023年12月的一份报告发现，近3900个组织仍在超过38000个应用中使用存在漏洞的Log4j版本，其中2.8%运行直接受原始Log4Shell漏洞影响的版本，3.8%运行2.17.0——该版本包含另一个严重漏洞CVE-2021-44832，另有32%的应用依赖Log4j 1.x<sup>[6](https://www.itpro.com/security/zero-day-exploit/361819/what-is-log4shell-log4j-vulnerability)</sup>。Veracode的一项研究发现，79%的开发者在首次引入第三方组件后从不更新，这使得存在漏洞的版本得以持续存在多年<sup>[6](https://www.itpro.com/security/zero-day-exploit/361819/what-is-log4shell-log4j-vulnerability)</sup>。

## References

1. [Mitigating Log4Shell and Other Log4j-Related Vulnerabilities, Joint Cybersecurity Advisory AA21-356A (PDF), CISA and partner agencies](https://media.defense.gov/2021/Dec/22/2002914139/-1/-1/0/JOINT_CSA_MITIGATING_LOG4SHELL_OTHER_LOG4J_VULNERABILITIES_20211222_.PDF)
2. [The Race to the Vulnerable: Measuring the Log4j Shell Incident, arXiv](https://arxiv.org/abs/2205.02544)
3. [Log4j vulnerability explained | Mitigation | CVE-2021-44228, YouTube](https://www.youtube.com/watch?v=HZ-itJEaFy0)
4. [Remote code injection in Log4j, CVE-2021-44228, GitHub Advisory Database](https://github.com/advisories/GHSA-jfh8-c2jp-5v3q)
5. [Mitigating Log4Shell and Other Log4j-Related Vulnerabilities, AA21-356A, CISA](https://www.cisa.gov/news-events/cybersecurity-advisories/aa21-356a)
6. [What is the Log4Shell vulnerability?, ITPro](https://www.itpro.com/security/zero-day-exploit/361819/what-is-log4shell-log4j-vulnerability)
7. [Case Study: Log4Shell (CVE-2021-44228), Open Source Software Supply Chain Security](https://sscsecurity.dev/book1/chapter-05/ch-5.2/)
8. [One year later, the widespread Log4j threat lingers on, Axios](https://www.axios.com/2022/12/09/log4j-year-anniversary-cybersecurity)
9. [A Longitudinal Measurement Study of Log4Shell Exploitation from a Reactive Network Telescope, arXiv](https://arxiv.org/abs/2601.04281)
10. [What is Log4Shell?, IBM](https://www.ibm.com/think/topics/log4shell)
11. [The Laconic Log4Shell FAQ, Check Point Research](https://research.checkpoint.com/2021/the-laconic-log4shell-faq/)
12. [Massive open-source flaw has put millions of systems at risk, Axios](https://www.axios.com/2021/12/15/log4j-open-source-cybersecurity-flaw)
13. [Log4j Zero-Day Vulnerability Response, Center for Internet Security](https://www.cisecurity.org/log4j-zero-day-vulnerability-response)
14. [Timeline of the Log4Shell vulnerability 2021, thesis citing Palo Alto Networks, Theseus](https://www.theseus.fi/bitstream/10024/860539/2/Thesis_Matias_Mesi%C3%A4.pdf)
15. [Attackers in China using open-source Log4j flaw, Axios](https://www.axios.com/2021/12/29/china-log4j-flaw)
16. [Log4Shell Response and Mitigation Recommendations, Sophos](https://www.sophos.com/en-us/blog/log4shell-response-and-mitigation-recommendations)
17. [Log4Shell Detection & Mitigation, NCSC-NL GitHub](https://github.com/NCSC-NL/log4shell/blob/main/detection_mitigation/README.md)
18. [Apache Logging Services Security page](https://logging.apache.org/log4j/2.x/security.html)
19. [Cyber Safety Review Board (CSRB), CISA](https://www.cisa.gov/resources-tools/groups/cyber-safety-review-board-csrb)
20. [2023 Top Routinely Exploited Vulnerabilities, AA24-317A, CISA and partner agencies](https://www.cyber.gov.au/sites/default/files/2024-11/2023-top-routinely-exploited-vulnerabilities.pdf)
21. [KEVology: An analysis of exploits, scores, and timelines on the CISA KEV, runZero](https://www.runzero.com/uploads/documents/reports/KEVology-An-analysis-of-exploits-scores-and-timelines-on-the-CISA-KEV.pdf)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Network defense and threats

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/log4shell

English original: https://www.edgepedia.org/log4shell
