Skip to content

Commit 5b38441

Browse files
authored
Patch log4j JAR to remove JndiLookup class (#81631)
1 parent cdc5ae4 commit 5b38441

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

distribution/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
276276
}
277277
}
278278
}
279+
all {
280+
resolutionStrategy.dependencySubstitution {
281+
substitute module("org.apache.logging.log4j:log4j-core") using project(":libs:elasticsearch-log4j") because "patched to remove JndiLookup clas"}
282+
}
279283
}
280284

281285
dependencies {

libs/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Side Public License, v 1.
77
*/
88

9-
subprojects {
9+
configure(subprojects - project('elasticsearch-log4j')) {
1010
/*
1111
* All subprojects are java projects using Elasticsearch's standard build
1212
* tools.

libs/log4j/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id 'base'
3+
id 'elasticsearch.repositories'
4+
}
5+
6+
configurations {
7+
log4j {
8+
transitive = false
9+
}
10+
}
11+
12+
dependencies {
13+
log4j "org.apache.logging.log4j:log4j-core:${versions.log4j}"
14+
}
15+
16+
// Strip out JndiLookup class to avoid any possibility of exploitation of CVE-2021-44228
17+
// See: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228
18+
// See: https://issues.apache.org/jira/browse/LOG4J2-3201
19+
def patchLog4j = tasks.register('patchLog4j', Zip) {
20+
archiveExtension = 'jar'
21+
from({ zipTree(configurations.log4j.singleFile) }) {
22+
exclude '**/JndiLookup.class'
23+
}
24+
}
25+
26+
artifacts {
27+
'default'(patchLog4j)
28+
}

0 commit comments

Comments
 (0)