Skip to content

Commit f832b52

Browse files
Miguel Angelmamedin
authored andcommitted
To fix this log4j security issue: * ES v1.7.x: The JMSAppender.class is deleted * ES v5.x: No action required * ES v6.x: No action required
1 parent 92d5249 commit f832b52

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

tasks/cve-2021-4104-patch.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: "Install zip package"
3+
become: "yes"
4+
package:
5+
name: "zip"
6+
state: "present"
7+
8+
- name: "Check if JMSAppender.class has been removed"
9+
become: "yes"
10+
shell:
11+
cmd: "unzip -l log4j-*.jar | grep JMSAppender.class"
12+
chdir: "/usr/share/elasticsearch/lib"
13+
register: "__jmsappender_class"
14+
failed_when: "__jmsappender_class.rc not in [ 0, 1 ]"
15+
16+
- name: "Remove JMSAppender.class"
17+
become: "yes"
18+
shell:
19+
cmd: "zip -q -d log4j-*.jar org/apache/log4j/net/JMSAppender.class"
20+
chdir: "/usr/share/elasticsearch/lib"
21+
when:
22+
- "__jmsappender_class.rc == 0"
23+
notify: "Restart Elasticsearch"

tasks/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@
129129
tags:
130130
- "cve-2021-44228-patch"
131131

132+
# Patch ES version 1.x for cve-2021-4104-vulnerability
133+
- include: cve-2021-4104-patch.yml
134+
when:
135+
- elasticsearch_version is version_compare('2.0', '<')
136+
tags:
137+
- "cve-2021-4104-patch"
138+
132139
# Register Elasticsearch service to start on boot
133140
- name: Ensure Elasticsearch is started on boot
134141
service: name=elasticsearch enabled={{ elasticsearch_service_startonboot }} state={{ elasticsearch_service_state }}

0 commit comments

Comments
 (0)