Skip to content
Fencer Vulns
high 8.8

CVE-2023-31038 json

Apache Log4cxx: SQL injection when using ODBC appender

published 2023-05-08 3 y ago modified 2026-06-17 4 mo ago also EUVD-2023-35375

cvss
8.8
version 3.1, CNA
cisa kev
Not listed
not in CISA's catalog
epss
1.6%
EPSS 1.6% chance of exploitation in 30 days, percentile 75%
public exploits
0
none known

Summary

SQL injection in Log4cxx when using the ODBC appender to send log messages to a database.  No fields sent to the database were properly escaped for SQL injection.  This has been the case since at least version 0.9.0(released 2003-08-06)

Note that Log4cxx is a C++ framework, so only C++ applications are affected.

Before version 1.1.0, the ODBC appender was automatically part of Log4cxx if the library was found when compiling the library.  As of version 1.1.0, this must be both explicitly enabled in order to be compiled in.

Three preconditions must be met for this vulnerability to be possible:

1. Log4cxx compiled with ODBC support(before version 1.1.0, this was auto-detected at compile time)

2. ODBCAppender enabled for logging messages to, generally done via a config file

3. User input is logged at some point. If your application does not have user input, it is unlikely to be affected.

Users are recommended to upgrade to version 1.1.0 which properly binds the parameters to the SQL statement, or migrate to the new DBAppender class which supports an ODBC connection in addition to other databases. Note that this fix does require a configuration file update, as the old configuration files will not configure properly.  An example is shown below, and more information may be found in the Log4cxx documentation on the ODBCAppender.

Example of old configuration snippet:

<appender name="SqlODBCAppender" class="ODBCAppender">

<param name="sql" value="INSERT INTO logs (message) VALUES ('%m')" />

... other params here ...

</appender>

The migrated configuration snippet with new ColumnMapping parameters:

<appender name="SqlODBCAppender" class="ODBCAppender">

<param name="sql" value="INSERT INTO logs (message) VALUES (?)" />

<param name="ColumnMapping" value="message"/>     ... other params here ...

</appender>

Patch / fix

  • Apache Software Foundation Apache Log4cxx 1.1.0
  • apache log4cxx 1.1.0
  • log4cxx Debian 14, Debian 13 1.1.0-1

debian advisories DEBIAN-CVE-2023-31038

  • log4cxx openSUSE Tumbleweed 1.1.0-1.1

opensuse advisories openSUSE-SU-2024:13545-1

Vendor advisories

What the vendors themselves say about their products: affected, fixed or not affected, and what to do.

red hat product security vex CVE-2023-31038 updated cvss 8.8

log4cxx: SQL injection in Log4cxx when using the ODBC appender to send log messages to a database

  • Red Hat Enterprise Linux 7 log4cxx
    not affected: vulnerable code not present

Red Hat CSAF VEX © Red Hat, Inc., from https://security.access.redhat.com/data/csaf/v2/vex/; changed: reduced to product statuses and remediations. CC BY 4.0 · csaf

CISA SSVC

Exploitation
none
Automatable
no
Technical impact
total
Assessed
2 y ago

Exploit prediction

1.60% chance of exploitation in the next 30 days, higher than 75% of all scored CVEs (FIRST EPSS, 2026-11-08).

Exploits and checks

  • lists.apache.org https://lists.apache.org/thread/vgjlpdf353vv91gryspwxrzj6p0fbjd9 referenced PoC, tagged "exploit" by a source, unverified

CVSS scores

assigned by version score vector
CISA ADP 3.1 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
NVD 3.1 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
CNA 3.1 8.8 CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Affected products

  • Apache Software Foundation Apache Log4cxx
  • apache log4cxx

Classification

Weakness
  • CWE-89 Improper Neutralization of Special Elements used in an SQL Command

References

Sources

Fencer Vulns keeps one entry per vulnerability: the CVE id wins, then GHSA, and records that alias each other are merged, except that two CVEs always keep separate entries. The same data is available as JSON.