4 ms·
The main design mistake in log4j is that it performs ${…} substitution on the complete log message by default. There’s no way for application code using the lo
by layer8 5y ago
The main design mistake in log4j is that it performs ${…} substitution on the complete log message by default. There’s no way for application code using the log4j front-end API to have input data containing such strings be logged verbatim, without nonstandard log4j back-end configuration (someone correct me if there’s actually a way). In principle, each application has to sanitize all strings to be logged by stripping/escaping all log4j substitution syntax from them, to prevent unexpected substitutions.
- Sohcahtoa82 5y agoWhy did the substitution syntax ever even allow JNDI calls? I mean seriously, who thought this was a good idea? It's about as dumb as allowing a SQL server to execute shell commands or read/write directly to files, or for XML documents to allow external entities that can fetch from URLs or local files. Even worse is when these gaping security holes are enabled by default.
- layer8 5y agoSee the description here for the rationale why JNDI support was added: https://issues.apache.org/jira/plugins/servlet/mobile#issue/LOG4J2-313 https://issues.apache.org/jira/plugins/servlet/mobile#issue/... Nobody there seemed to be aware that the log message text itself is also subject to lookup syntax interpretation and that this would be dangerous given that JNDI also allows remote code-base download and execution from the specified URL.
- Fabricio20 5y agoExcept this particular issue has nothing to do with LDAP! It's perfectly reproducible with RMI for example, another JNDI supported protocol. So much so that the initial RC1 patch was an IF for LDAP, and it was obviously bypassed in seconds.
- layer8 5y agoYou are right, I edited my comment now.
- Sohcahtoa82 5y agoThat page requires a login.
- layer8 5y agoOnly intermittently, try reloading the page.
- jasode 5y agoWhat info does your link provide that the other canonical url for "LOG4J2-313" does not? The url people usually copy&paste that doesn't require a login is: https://issues.apache.org/jira/browse/LOG4J2-313 https://issues.apache.org/jira/browse/LOG4J2-313
- layer8 5y agoIt seems my link is the mobile version. I'm currently on mobile, that's why. I can't edit the original comment anymore unfortunately.
- bcrosby95 5y agoThe main design mistake is including it, by default, in the first place, rather than requiring you to specify some kinda custom appender or whatever. The idea that a logging framework could lead to an RCE like this is completely bonkers. The vast majority of users just want to log straightforward data.
- layer8 5y agoI think it’s okay to allow specifying such substitution variables in the log pattern syntax specified in the logging configuration, but not interpreting the log message strings provided by the application, and certainly not on log message parameters.
- thinkmassive 5y ago> without nonstandard log4j back-end configuration By "nonstandard" do you mean different than default settings? It looks like they changed the default as of v2.15: https://issues.apache.org/jira/browse/LOG4J2-3198 https://issues.apache.org/jira/browse/LOG4J2-3198 For earlier versions (2.10+) it looks like there's a single setting you can toggle to prevent the lookup behavior: log4j2.formatMsgNoLookups=true (or env var LOG4J_FORMAT_MSG_NO_LOOKUPS=true)
- ollien 5y agoCorrect me if I'm wrong, but this means that an application with version 2.15 installed can still be vulnerable, yes?
- layer8 5y agoNot really, because log4j now restricts JNDI-LDAP queries to localhost by default, or to an explicitly configured list of hosts. An attacker would have to have access to the application configuration or start script.
- staticassertion 5y agoNo, you are still vulnerable, even with just what we know today and we're still finding more ways to break this library. 1. Attackers can still load code in your class path. 2. Attackers can steal environment variables, VM information, system information, etc. 3. The issue isn't specific to LDAP in any way, that was just a particularly brutal way to exploit this vulnerability. There are other ways to achieve RCE. We may find even more ways to attack this in the future. It is absolutely not a good idea to assume you're safe right now - if you have log4j in your dependency tree, you should keep a close eye on the discourse as it evolves. edit: I'll just say that I think it's really premature to tell anyone that they're safe.
- layer8 5y agoAs far as log4j is concerned, the substitutions ("lookups" — this includes your #2) are now disabled by default, and can only be enabled by an attacker if he already has access to the application. I’m not sure what you’re referring to in #1 and #3, given that fix.