Skip to content

Commit 5a580fc

Browse files
Check JVM option -Dlog4j2.formatMsgNoLookups=true is set
1 parent ccc4726 commit 5a580fc

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/Controller/ElasticsearchClusterController.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,13 @@ public function audit(Request $request, string $elasticsearchUsername, string $e
261261

262262
$plugins = [];
263263
$nodesPlugins = [];
264+
$formatMsgNoLookups = [];
264265

265266
$cpuPercent = false;
266267
$diskPercent = false;
267268
$heapSize = false;
268269
$heapSizeJvm = false;
270+
$inputArgumentsJvm = false;
269271
$fileDescriptors = false;
270272

271273
if (true === isset($parameters['cluster_settings']['cluster.routing.allocation.disk.threshold_enabled']) && 'true' == $parameters['cluster_settings']['cluster.routing.allocation.disk.threshold_enabled']) {
@@ -332,6 +334,15 @@ public function audit(Request $request, string $elasticsearchUsername, string $e
332334
}
333335
}
334336

337+
if (true === isset($node['jvm']['input_arguments'])) {
338+
$inputArgumentsJvm = true;
339+
if (true === in_array('-Dlog4j2.formatMsgNoLookups=true', $node['jvm']['input_arguments'])) {
340+
$formatMsgNoLookups[$node['name']] = true;
341+
} else {
342+
$formatMsgNoLookups[$node['name']] = false;
343+
}
344+
}
345+
335346
if (true === isset($node['file_desc.max'])) {
336347
$fileDescriptors = true;
337348
if (-1 < $node['file_desc.max'] && 65535 > $node['file_desc.max']) {
@@ -397,6 +408,7 @@ public function audit(Request $request, string $elasticsearchUsername, string $e
397408
'total_shards_per_node',
398409
'replication_100_percent',
399410
'deprecations',
411+
'format_msg_no_lookups',
400412
];
401413

402414
$checkpoints = [];
@@ -715,6 +727,22 @@ public function audit(Request $request, string $elasticsearchUsername, string $e
715727
}
716728
}
717729
break;
730+
case 'format_msg_no_lookups':
731+
if (true === $inputArgumentsJvm) {
732+
$fail = [];
733+
foreach ($formatMsgNoLookups as $node => $parameter) {
734+
if (false === $parameter) {
735+
$fail[] = $node;
736+
}
737+
}
738+
739+
if (0 < count($fail)) {
740+
$results['audit_fail'][$checkpoint] = $fail;
741+
} else {
742+
$results['audit_pass'][$checkpoint] = [];
743+
}
744+
}
745+
break;
718746
}
719747
}
720748

templates/Modules/cluster/cluster_audit.html.twig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,23 @@
529529
{% endblock %}
530530
{% endembed %}
531531
{% endif %}
532+
533+
{% if 'format_msg_no_lookups' == checkpoint %}
534+
{% embed 'Embed/audit_checkpoint_embed.html.twig' %}
535+
{% block comment %}
536+
{% if 'audit_fail' == result %}
537+
{{ ('audit_comments.' ~ checkpoint ~ '.fail')|trans|raw }}
538+
{% for node in parameters %}
539+
{{ node }}{% if false == loop.last %},{% endif %}
540+
{% endfor %}
541+
{% endif %}
542+
{% endblock %}
543+
544+
{% block external_link %}
545+
<a class="btn btn-secondary btn-sm" rel="noreferrer" target="_blank" href="https://discuss.elastic.co/t/apache-log4j2-remote-code-execution-rce-vulnerability-cve-2021-44228-esa-2021-31/291476">{{ 'help'|trans }}</a>
546+
{% endblock %}
547+
{% endembed %}
548+
{% endif %}
532549
</tr>
533550
{% endfor %}
534551
{% endfor %}

translations/messages.en.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ audit_checkpoints:
8989
max_shards_per_node: "The cluster shards per node limit is below 1000"
9090
total_shards_per_node: "The cluster shards allocation per node limit is below 1000"
9191
deprecations: "There is no deprecations"
92+
format_msg_no_lookups: "The JVM option -Dlog4j2.formatMsgNoLookups=true is set"
9293
audit_comments:
9394
fail_for_nodes: "The checkpoint fails for the following nodes:"
9495
fail_for_repositories: "The checkpoint fails for the following repositories:"
@@ -133,6 +134,8 @@ audit_comments:
133134
note: "The setting <code>{setting}</code> is set to <code>{value}</code>."
134135
total_shards_per_node:
135136
note: "The setting <code>{setting}</code> is set to <code>{value}</code>."
137+
format_msg_no_lookups:
138+
fail: "The JVM option <code>-Dlog4j2.formatMsgNoLookups=true</code> is not set for the following nodes:"
136139
authentication_secret: "Authentication secret"
137140
available: "Available"
138141
awaiting_info: "Awaiting info"

0 commit comments

Comments
 (0)