Educational analysis of CVE-2021-44228 (Log4Shell): root cause, JNDI injection attack flow, patch diffs, detection rules, IoCs, and remediation guidance.
log4j-core) that interprets ${jndi:...} lookup syntax within log messages and connects to external JNDI endpoints such as LDAP.| Item | Details |
|---|---|
| CVE ID | CVE-2021-44228 (alias: Log4Shell, GHSA-jfh8-c2jp-5v3q) |
| Disclosure date | 2021-12-10 (NVD publication date) |
| Affected product/versions | Apache Log4j2 log4j-core 2.0-beta9 ~ 2.15.0 (excluding security releases 2.12.2, 2.12.3, 2.3.1) |
| Patched versions | Initial fix: 2.15.0 (Java 8), 2.12.2 (Java 7), 2.3.1 (Java 6) Recommended: 2.17.1 (Java 8+), 2.12.4 (Java 7), 2.3.2 (Java 6) — includes fixes for follow-up CVEs |
| CVSS v3.1 | 10.0 (Critical) — CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H |
| CVSS v4.0 | Vector CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H (per GitLab Advisory DB. NVD's official v4 score has not been confirmed) |
| CWE | CWE-20 (Improper Input Validation), CWE-400 (Uncontrolled Resource Consumption), CWE-502 (Deserialization of Untrusted Data) — per the CVE record |
| Known exploitation | Exploitation confirmed. Listed in CISA KEV (added 2021-12-10, remediation deadline 2021-12-24), confirmed use in ransomware campaigns |
Note: This vulnerability is limited to
log4j-core; if onlylog4j-apiis used, or in the case of Log4j 1.x, log4net, or log4cxx, they are not affected by this CVE. (Log4j 1.x has separate vulnerabilities such as CVE-2021-4104)
| CVE | Details | Fixed version |
|---|---|---|
| CVE-2021-45046 | Incompleteness of the 2.15.0 fix (bypassable under certain non-default configurations), CVSS 9.0 | 2.16.0 / 2.12.2 |
| CVE-2021-45105 | DoS due to infinite recursion of self-referential lookups, CVSS 7.5 | 2.17.0 / 2.12.3 |
| CVE-2021-44832 | RCE via JDBC Appender by an attacker with permission to modify configuration files | 2.17.1 / 2.12.4 / 2.3.2 |
Log4j2 supports Lookup syntax of the form ${prefix:name} in configuration and log messages. In vulnerable versions, this substitution is applied by default even to the body of log messages (including user input), and one of the lookup types, jndi:, looks up arbitrary remote endpoints via JNDI (Java Naming and Directory Interface).
Untrusted input passes through three consecutive stages of "unintended trust."
formatMsgNoLookups is false)JndiManager calls InitialContext.lookup() without protocol or host restrictions, connecting to an external LDAP/RMI server specified by the attacker.The following is a summary flow for understanding the behavior and is not the complete actual source code.
Logger.info("User-Agent: " + userAgent)
└─ PatternLayout → MessagePatternConverter.format()
└─ 메시지 내 "${" 발견 시 StrSubstitutor.replace() 호출 ← 사용자 입력이 표현식으로 평가
└─ Interpolator → JndiLookup.lookup("jndi:...")
└─ JndiManager.lookup(name)
└─ InitialContext.lookup(name) ← 제한 없는 원격 조회
└─ 원격 LDAP 응답 객체 로딩/역직렬화 → 코드 실행
2.15.0 — Commit d82b47c (LOG4J2-3201): Restrict JNDI access targets
log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
public class JndiManager extends AbstractManager {
+ public static final String ALLOWED_HOSTS = "allowedLdapHosts";
+ public static final String ALLOWED_CLASSES = "allowedLdapClasses";
+ public static final String ALLOWED_PROTOCOLS = "allowedJndiProtocols";
...
public JndiManager createManager(final String name, final Properties data) {
+ // 허용 호스트/클래스/프로토콜 목록 구성 (기본: java, ldap, ldaps / localhost 계열)
+ addAll(classes, allowedClasses, permanentAllowedClasses, ALLOWED_CLASSES, data);
+ addAll(protocols, allowedProtocols, permanentAllowedProtocols, ALLOWED_PROTOCOLS, data);
try {
- return new JndiManager(name, new InitialContext(data));
+ return new JndiManager(name, new InitialDirContext(data), allowedHosts, allowedClasses,
+ allowedProtocols);
| Category | Before (≤2.14.1) | After (2.15.0) |
|---|---|---|
| Allowed protocols | No restriction | By default, only java, ldap, ldaps allowed |
| Allowed LDAP hosts | No restriction | By default, only localhost allowed (extendable via log4j2.allowedLdapHosts) |
| Deserialization classes | No restriction | By default, only Java primitive classes allowed (log4j2.allowedLdapClasses) |
| Message Lookup | Enabled by default | Changed to disabled by default |
Limitations of 2.15.0 → 2.16.0 / 2.17.x
java.net.URI and JNDI's internal URI parser (e.g., handling of #) (GHSL-2021-1054). This led to CVE-2021-45046.log4j2.enableJndi* properties).→ Conclusion: 2.15.0 is an incomplete fix, so it should not be used as a baseline version for operations.
| Condition | Details |
|---|---|
| Authentication | Not required (PR:N) |
| User interaction | Not required (UI:N) |
| Network position | Remote. Only requires attacker input to reach a logging path (internal systems can also suffer secondary damage through the log pipeline) |
| Target condition | Uses vulnerable version of log4j-core + attacker-controlled string is recorded in logs |
| Additional condition | Completing RCE requires outbound LDAP/RMI/DNS communication from the target server (even if only DNS is allowed, detection and information exfiltration are possible) |
sequenceDiagram
autonumber
participant A as 공격자
participant V as 취약 애플리케이션<br/>(Log4j2 ≤ 2.14.1)
participant L as 공격자 제어<br/>LDAP 서버
participant H as 공격자 제어<br/>HTTP 서버
A->>V: 로그에 기록될 필드(헤더·입력값 등)에<br/>JNDI Lookup 구문 삽입
V->>V: 요청 처리 중 해당 값을 로그로 기록
V->>V: Log4j가 메시지 내 Lookup 구문 평가
V->>L: JNDI(LDAP) 조회 요청 (아웃바운드)
L-->>V: 원격 클래스 참조 또는 직렬화 객체 응답
V->>H: (원격 클래스 로딩 가능 환경) 클래스 파일 요청
H-->>V: 악성 클래스 전달
V->>V: 애플리케이션 권한으로 코드 실행
V-->>A: 리버스 셸·웹셸·마이너 설치 등 후속 행위