By design, the JDBCAppender in Log4j 1.2.x accepts an SQL statement as a configuration parameter where the values to be inserted are converters from PatternLayout. The message converter, %m, is likely to always be included. This allows attackers to manipulate the SQL by entering crafted strings into input fields or headers of an application that are logged allowing unintended SQL queries to be executed. Note this issue only affects Log4j 1.x when specifically configured to use the JDBCAppender, which is not the default. Beginning in version 2.0-beta8, the JDBCAppender was re-introduced with proper support for parameterized SQL queries and further customization over the columns written to in logs. Apache Log4j 1.2 reached end of life in August 2015. Users should upgrade to Log4j 2 as it addresses numerous other issues from the previous versions.
Workaround:
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.
Link | Tags |
---|---|
https://logging.apache.org/log4j/1.2/index.html | vendor advisory |
https://lists.apache.org/thread/pt6lh3pbsvxqlwlp4c5l798dv2hkc85y | vendor advisory mailing list issue tracking |
http://www.openwall.com/lists/oss-security/2022/01/18/4 | third party advisory mailing list |
https://www.oracle.com/security-alerts/cpuapr2022.html | third party advisory patch |
https://security.netapp.com/advisory/ntap-20220217-0007/ | third party advisory |
https://www.oracle.com/security-alerts/cpujul2022.html | third party advisory patch |