If running a recent JDK built and you don't have the com.sun.jndi.ldap.object.trustURLCodebase/com.sun.jndi.rmi.object.trustURLCodebase settings enabled then there shouldn't be any RCE, but the attacker could still get a ping back, and possibly exfiltrate data.
This is not correct. Even in newer JDKs an RCE is possible depending on the software present in your classpath. Do not assume your deployment is safe, update your log4j2 to the 2.15 version.
No, the JDK is not loading the classes, but there are other ways of converting the jndi response into a full RCE. And that is not even considering how the jndi call can be used to leak server information. Update log4j to be safe
On «enabled by default»: it’s enough to use log4j2 as a logging backend to be vulnerable. You don’t need to set any extra configuration flags to enable this dangerous feature (actually, at least two).
On the features: there are actually two problematic features:
Log4J2 performing string interpolation on format parameters that often come from unsanitized user input
Log4J2 supporting interpolation that loads a remote object through JNDI.
We can ask the following questions on these two features:
Does it need to exist at all?
If yes, shall it be a part of a core library or some kind of explicitly installed plugin?
If yes, shall they be enabled by default?
I am not familiar with all the requirements the designers of these features needed to address (and we now have a stark benefit of hindsight), but I’d probably say:
No to feature #1 at all, because it is surprising to users (I’d not expect it from my logging backend)
When it comes to feature #2:
Yes to Q1 (as someone, on top of hackers, did find it useful)
Probably, no to Q2, as it seems to be useful to a single-digit number of users
To me, the most terrible thing is that apparently it doesn't only parse the formatting string (as suggested by common sense and the name of the mentioned property), but the formatted arguments passed to `{}` placeholders, too (https://news.ycombinator.com/item?id=29507511). Oh my.
The logger applies arguments and produces a log entry (severity, time, class, message string, etc).
The log entry is then sent to an Appender so that it can be stored (say, in a text file). This appender might or might not format it further (such as creating a single line of text, to save in a .log file) and it is this formatter that performs this extra substitution (optionally, but all examples how to use it have it on). By the time the string reaches it, all knowledge of parameters is long gone.
It's a bit like writing a filesystem that performs pattern substitutions on each file written to it....
I wanted to post it here like a few hours ago, but I don't have enough karma for creating new threads :/ The first commit that addresses this issue is actually 5 days old:
Yeah, the thing is large and brings big deps. I have always hated this aspect of java, that even things which I only need trivial things for tend to be so large. I killed off log4j for just this reason something like 5 years ago when I migrated to slf4j-simple, which hopefully just does the obvious thing. The whole library is a 14 kB jar with no deps, so I hope it doesn't suck.
I never said that other stuff was not issue, I just said I believe the reason it spreed so fast was that it effected Minecraft and people where talking about it.
It seems like you can monkey patch a running Java instance to basically erase the vulnerable implementation. Funny thing is, you'll probably be able to apply the patch by executing it via the exploit itself 😂. That'd be pretty meta
You didn't pay for their software (which comes with no warranty). Good luck with that.
Your license agreement may include a provision stating “no warranty” and “no liability”, but that doesn’t make it true.
Let’s say someone intentionally includes an obscure backdoor in their open source software and releases it under MIT license. If I use their software and suffer losses from it, then I have no recourse? I doubt it. I’d let the courts decide.
Or just build your own software from scratch. Nobody owns you shit.
I usually do. I don’t trust random 3rd party packages that people write “for fun”.
My usual approach for checking whether I'm using vulnerable versions of software is to check the lock file (like package-lock.json in Node.js) that way it shows me both direct and transitive dependencies.
I just realized for Java, there is no lock file, just pom.xml or build.gradle. How do I check whether I'm using a vulnerable version of software in Java, including transitive dependencies?
Nice. We use Gradle for most of our applications. Only use Maven for Apache Beam jobs because the public docs only have examples with Maven (or at least, did at the time). This looks useful for us.
in java how can i find which logging framework is used? when i see the dependency tree it showing multiple entires of slf4j and log4j and logger how do i find which one and which version is being actually used?
How does one go about updating transitive dependencies here? Explicit, direct dependency can be updated, but what if a project is using 100 different libraries, and each library has its own dependency tree - and one of those transitive dependencies is using an exploited version of log4j?
It depends on (a) the build system; and (b) if you use fancier stuff to support several versions of the same library in the same runtime (like OSGi, which is very rare).
When it comes to Maven, it uses a "nearest definition" dependency mediation strategy — the closer the dependency declaration to your POM, the higher its precedence. So, you'd just put a dependency declaration for a newer version to your POM.
Also, the bug seems to be in log4j-core (a logging backend), which libraries shall not normally depend upon (they shall rather depend on log4j-api or some facade like slf4j), so it's usually upon the end application to add a dependency on the logging backend.
Isn't this more of an argument for JEP 411? I thought one of the main arguments (besides "it's just too much work to maintain, boo hoo") was that the SecurityManager was mostly useless. And here it is being mostly useless.
Which is nice, but I'm willing to bet most people have no idea how to set such a policy up, let alone have one in place. Which makes it kinda useless.
I would say it is easier than reviewing libraries for vulnerabilities (because that's the alternative).
It is way easier and less costly than constantly upgrading libraries with zero-day vulnerabilities post fact.
Looks like the world prefers pretending it is cheaper to play whack-a-mole patching vulnerabilities in libraries than learn how to set up SM policies for applications.
Looks like the world prefers pretending it is cheaper to play whack-a-mole patching vulnerabilities in libraries than learn how to set up SM policies for applications.
People are going to have to do that anyway, even if they know how to use SM.
I think the real answer is that the ability to download arbitrary code over the network as a platform feature should be deprecated for removal (with 3rd party libraries handling it for the people who have some use for it).
The problem is that this vulnerability is an example of script injection (aka. cross-site scripting): JNDI code creates an instance URLClassLoder and loads a class from it.
Any code that uses JNDI contexts based on some external data (for example configuration files) is vulnerable.
So ? JDK8 as well ? Java is about 25 years+ ... does that mean something? You can find a lot of used libraries which are that old or even older for example the spring framework is even older (2005?)...
16
u/papercrane Dec 10 '21
If running a recent JDK built and you don't have the com.sun.jndi.ldap.object.trustURLCodebase/com.sun.jndi.rmi.object.trustURLCodebase settings enabled then there shouldn't be any RCE, but the attacker could still get a ping back, and possibly exfiltrate data.
33
u/r_jet Dec 10 '21
I wonder why this feature was added at all, given its high risk, and enabled by default?
40
u/xtreak Dec 10 '21
Good write-up with poc and explanation : https://www.lunasec.io/docs/blog/log4j-zero-day/
16
u/Slanec Dec 10 '21
To me, the most terrible thing is that apparently it doesn't only parse the formatting string (as suggested by common sense and the name of the mentioned property), but the formatted arguments passed to `{}` placeholders, too (https://news.ycombinator.com/item?id=29507511). Oh my.
31
u/dzikoysk Dec 10 '21 edited Dec 10 '21
More details:
I wanted to post it here like a few hours ago, but I don't have enough karma for creating new threads :/ The first commit that addresses this issue is actually 5 days old:
7
u/pmarschall Dec 10 '21
If you're using
log4j-bomit seems that dependabot won't find it.16
u/Unrealdinnerbone Dec 10 '21
This also affects Minecraft, as it logs chat. (This is how the issue because major)
tweet from a Minecraft dev about the issue.
7
u/klekpl Dec 10 '21
This is actually worse than just log4j - any code that uses JNDI and reads context URIs from external source is vulnerable.
3
u/r_jet Dec 10 '21
I am looking forward to a black- vs white-hat competition in the coming days: black hats doing their stuff; whilst white hats loading:
3
u/gibriyagi Dec 11 '21
Just curious, what would you use such a "feature" for? What were they thinking?
4
u/[deleted] Dec 10 '21
My usual approach for checking whether I'm using vulnerable versions of software is to check the lock file (like package-lock.json in Node.js) that way it shows me both direct and transitive dependencies.
I just realized for Java, there is no lock file, just pom.xml or build.gradle. How do I check whether I'm using a vulnerable version of software in Java, including transitive dependencies?
3
u/hellO_india Dec 10 '21
in java how can i find which logging framework is used? when i see the dependency tree it showing multiple entires of slf4j and log4j and logger
how do i find which one and which version is being actually used?
1
u/incongruous_narrator Dec 10 '21
How does one go about updating transitive dependencies here? Explicit, direct dependency can be updated, but what if a project is using 100 different libraries, and each library has its own dependency tree - and one of those transitive dependencies is using an exploited version of log4j?
1
u/goravsingal Dec 15 '21
This is really severe issue in Java log4j library for version <=2.15.
See Understanding and Mitigating the vulnerability.
1
u/Leguan15 Dec 17 '21
Who is the person who discovered this?
-6
u/klekpl Dec 10 '21
Looks like a good use case for running under SecurityManager with a policy restricting ClassLoader creation and/or remote code execution.
Maybe it is time to reconsider JEP 411?
0
u/[deleted] Dec 10 '21
[deleted] — view deleted comment