Skip to content

Commit 403e8db

Browse files
authored
[6.8] Patch log4j JAR to remove JndiLookup class (#81632)
1 parent 416629f commit 403e8db

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

libs/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
* under the License.
1818
*/
1919

20-
subprojects {
21-
/*
22-
* All subprojects are java projects using Elasticsearch's standard build
23-
* tools.
24-
*/
25-
apply plugin: 'elasticsearch.build'
20+
configure(subprojects - project('log4j')) {
21+
/*
22+
* All subprojects are java projects using Elasticsearch's standard build
23+
* tools.
24+
*/
25+
apply plugin: 'elasticsearch.build'
2626

2727
/*
2828
* Subprojects may depend on the "core" lib but may not depend on any

libs/log4j/build.gradle

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

server/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ if (!isEclipse) {
7272
}
7373
}
7474

75+
configurations.all {
76+
resolutionStrategy.dependencySubstitution {
77+
substitute module("org.apache.logging.log4j:log4j-core") because "patched to remove JndiLookup class" with project(":libs:log4j")
78+
}
79+
}
80+
7581
dependencies {
7682

7783
compile "org.elasticsearch:elasticsearch-core:${version}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
592a48674c926b01a9a747c7831bcd82a9e6d6e4
1+
fe18be6aecfbf008a8f479397d233dcf089e9643

0 commit comments

Comments
 (0)