Java4Shell: RCE in OpenJDK when processing Base64

(calif.io)

419 points | by werrett 3 hours ago ago

73 comments

  • lucasluitjes an hour ago ago

    From the section on performing heap grooming over the network ("Remote Heap Feng Shui"):

    > The current attack is sensitive to network conditions, like RTT and jitter. Low, stable round-trip times are preferred for a more reliable attack. In our controlled environment, we performed this attack over the internet through public IP addresses instead of just assuming perfect laboratory conditions. For the current attack path to achieve optimal stability and reliability in exploitation, Calif turned to physics and utilized money to solve the problem, rather than experimenting with TCP/IP stack configuration. In other words, Calif rented another VM in the same region as our target.

    And the "Limitations" section:

    > There is no universal payload. Each chain needs a decoder route, a live writer, a returned reader or another feedback path, a heap layout, and an application action. Every target needs a bespoke profile. The exploit is not a universal point-and-shoot.

    Based on the complexity and constraints, short-term mass-exploitation seems unlikely. It will take some time before there are reliable exploits, and they may require running on infra close to the target.

    But a long tail of unpatched java applications/services at high-value targets getting exploited, seems plausible to me.

    • luka2233 an hour ago ago

      still pretty scary for multi-tenant infra

    • lowbloodsugar 19 minutes ago ago

      >Based on the complexity and constraints, short-term mass-exploitation seems unlikely.

      Don't see how this is a safe assumption in the modern era of LLMs.

      • afavour 12 minutes ago ago

        > The current attack is sensitive to network conditions, like RTT and jitter.

        LLMs aren’t magic, they can’t alter physics.

        • makeitdouble 3 minutes ago ago

          With only a few major cloud providers, running a VM in physical proximity isn't a herculean task though.

          In particular booting a VM is cheap, having them in all potential regions won't break the bank.

    • afavour 38 minutes ago ago

      Yes, I guess the TL;DR is the chances of a drive by attack are low, but a sufficiently motivated actor with a specific target in mind might be able to exploit it.

      So, patch your systems, governments!

    • jonstewart an hour ago ago

      > Based on the complexity and constraints, short-term mass-exploitation seems unlikely. It will take some time before there are reliable exploits

      Mass exploitation, maybe. But LLMs are pretty good at finding exploits now as Calif showed at unprompted a few weeks ago.

      • AdrenalinMd 36 minutes ago ago

        Indeed, it can be a SKILL.md that writes the exploit. So in the end it could still be quite mass exploitable, only depends how much context is needed to write the exploit.

  • ievans 3 hours ago ago

    Super impressive work by Calif as usual.

    The exploit conditions are very specific but there are still going to be a lot of hosts impacted. We at Semgrep published some free detection scripts here: https://github.com/semgrep/detection-scripts/tree/main/CVE-2...

    They look for these five conditions:

      * HotSpot VM: any OpenJDK build, Oracle JDK, or GraalVM JDK. Only HotSpot generates the stub. OpenJ9 and GCJ are OK. Azul Prime (Zing), which replaces C2 with its own JIT, and any VM name not recognized as HotSpot are [?], never [!].
      * x86-64 JVM on an x86-64 host.
      * Version 17.0.6 or later, not at or above a version listed in FIXED_IN, and no newer than the newest releases checked (see below). Newer versions are [?]: they may carry the fix.
      * The JVM reports avx512_vbmi and avx512bw, and UseAVX >= 3.
      * Base64 intrinsics are on and C2/JVMCI can compile. These turn it off: -XX:-UseBASE64Intrinsics, -XX:DisableIntrinsic=_base64_decodeBlock, -Xint, -XX:TieredStopAtLevel below 4.
    • bikezen 2 hours ago ago

      The write-up itself matches your version assumption, however it also says:

      > According to Oracle, the following Oracle Java SE versions are vulnerable: 8u511b33-perf, 17.0.21.0.3, 21.0.13.0.3, 25.0.5.0.3, 27.0.1.0.3. We thank Oracle for providing this information ahead of publication time.

      So according to Oracle at least, JRE8 versions are affected as well.

    • cjbprime 2 hours ago ago

      Wouldn't it be prudent for someone to patch even if they aren't running their code on an AVX512 system right this moment? They could be running on one.. next moment.

      • Banditoz 2 hours ago ago

        Sure, but I think it brings it down from "patch immediately" severity, to just "bump the JDK with next service deploy" severity.

        Or, do running machines often have their CPU changed from under them without much notice?

        • stackskipton an hour ago ago

          Depends on the company and deployment method. As Ops person, I generally don't think much about rolling out different Kubernetes Nodes and what SKU I select. So yes, you could be running on one node type today and tomorrow I upgrade the nodes under you.

          • xmodem 35 minutes ago ago

            We’re using a second-tier cloud provider’s managed Kubernetes offering, and in investigating our level of exposure to this, I just learned that there is variance within a node pool on whether AVX-512 is available.

        • Sohcahtoa82 39 minutes ago ago

          > Or, do running machines often have their CPU changed from under them without much notice?

          I dunno about other cloud providers, but I know AWS can move your EC2 VM from one system to another transparently. There is a server ID you can get from the metadata, but unless you're checking it frequently, you can be moved without ever being aware.

          • PhilipRoman 6 minutes ago ago

            Question is if they expose it to the guest. Many (most?) cloud platforms will make the guest see the lowest common denominator, specifically to avoid angry customers when their working setup suddenly breaks.

            In the case of transparent migration, I think it's basically a must. No JIT (or even libc probably) is going to support CPU features changing at runtime.

    • bonsai_spool 2 hours ago ago

      This looks like Claudese - may be kind to write such things yourself if you intend for humans to read them. (For example, “ HotSpot VM: any OpenJDK build, Oracle JDK, or GraalVM JDK. Only HotSpot generates the stub. OpenJ9 and GCJ are OK. Azul Prime (Zing), which replaces C2 with its own JIT, and any VM name not recognized as HotSpot are [?], never [!].” — I tried parsing at least five times before realizing you’re asking me to decipher LLM talk)

      • Yokolos an hour ago ago

        I still don't understand what's meant with Azul. Is it affected or not? What is it never?

        • kaboberg 32 minutes ago ago

          Azul Core definitely is - it uses upstream HotSpot.

          Azul Platform Prime (formerly Zing) may or may not be depending on whether they touched the base64 intrinsic. Since it is closed-source there is no way to verify via code, which is how our research team investigates ecosystem events like this.

  • leca 3 hours ago ago

    What’s that old Chinese proverb? “May you live in interesting times”? It feels like we’re living in interesting times. How long will it take for a bad actor to seriously compromise critical infrastructure? My bet is within six months.

    The upside is that it’ll force legacy institutions and organizations with sub-par security to get good at security and modernize their legacy stacks. That, or get pwned in short order.

    • ctoth 2 hours ago ago

      > My bet is within six months

      My bet is it already happened two months ago and there's a whole secret scrum we only vaguely know about happening right now.

      • adrianpike 2 hours ago ago

        Instability is often correlated to urgently performed change, and we've seen a lot of instability around the world lately.

        • pixl97 2 hours ago ago

          A lot of organizations we sitting on internal bugs for years because they thought they were impossible to exploit, and now their red team can break them in hours.

          Most businesses are stuck in a trap now. They know the software is exploitable, but they are organizationally slow in testing and rollout. They have to start moving fast with security and IT organizations that are cut to the bone, yet at the same time contain to much box checking deadweight.

          • jeremyjh 40 minutes ago ago

            3/4 of the Fortune 500 will conclude they should hire expensive consultants to create more checkboxes.

        • ChuckSneed 2 hours ago ago

          Instability can also be attributed to AI slop code. That's the simplest explanation.

      • Analemma_ 2 hours ago ago

        I think this bet is optimistically assuming a far more competent world than the one we actually have. Have you seen the idiot clowns actually in power? The agency that might've been tasked with this hypothetical secret scrum, CISA, has been gutted and left to rot because they thought it was an enemy plot to censor them on social media or whatever. There's no secret room where the smart people are fixing things.

        • scottyah an hour ago ago

          There are many secret rooms where many smart people are fixing many things. It's more telling about yourself that you don't know of any.

          • jeremyjh 39 minutes ago ago

            There is no secret room where smart people people aligned with the interests of the people of the United States are fixing things. There may not be any smart people left in the Federal government who aren't actively engaged in looting it.

          • salamandars 23 minutes ago ago

            Tell us about one of them, then.

  • drum55 2 hours ago ago

    They aren’t wrong that we should be deleting more support and removing more features. The idea that the linux kernel by default builds support for all sorts of ancient systems nobody has ever heard of is absurd.

    • eru 21 minutes ago ago

      You can use the kernel config to remove these things.

  • fsnovask 34 minutes ago ago

    >The best hacker today is neither AI nor human. It is the centaur hacker, part human, part AI.

    I think only really smart people are going to be left in Security and Software. I can barely fathom what this group is doing with AI right now (ignoring that their model probably isn't nerfed and mine would be) and I don't think any of this is trainable for the average developer. This is starting to feel like some of the scientific fields where careers start when you get a MS/PhD. Or like the average developer is on the same level of not being able to convert a Word document to PDF.

    • eru 22 minutes ago ago

      > I think only really smart people are going to be left in Security and Software.

      I'm looking forward to eventually getting there. At the moment, there's so much low hanging fruit that even someone without a clue like me can just point a fuzzer at some random Linux kernel code and still discover problems.

      (Most of the problems I found from that exercise are patched by now, if you use a recent enough kernel.)

      I used Kimi to drive the fuzzer. The model didn't have to do anything smart, just do the tedious work of writing the glue code to make the fuzzing work. AFL++ did the 'smart' parts, and I had the idea to kick it off and oversaw the patches.

    • colonCapitalDee 24 minutes ago ago

      I don't know, it feels like just another skill to me. You learn your debugger, you learn the shell, you learn web development... you learn AI.

      We'll see how long the centaur era lasts though. Hopefully a very long time

      • eru 22 minutes ago ago

        For comparison for chess, it didn't last that long.

  • mzs 3 hours ago ago

    You can also mitigate Java4Shell by starting OpenJDK with either:

    -XX:-UseBASE64Intrinsics to disable hardware-accelerated Base64 encoding and decoding, or

    -XX:UseAVX=2 to disable AVX-512. Apply this flag only on x86-64 hosts. OpenJDK on ARM doesn't recognize it and will fail to start.

    • marginalia_nu 3 hours ago ago

      Might be worth examining whether AVX-512 is even supported on the machine before freaking out, too.

  • Noe2097 2 hours ago ago

    This attack surface (manually optimized assembly code in the middle of software stacks) looks AWESOME

  • rbanffy 2 hours ago ago

    Not everywhere... Requires an x86-64 processir with AVX512.

    • formerly_proven 2 hours ago ago

      Pretty much any Intel server and most AMD servers are going to support AVX512 and conversely most VMs running in the cloud will have access to it.

      • rbanffy 2 hours ago ago

        Speak for yourself. All my cloud VMs are ARM, with one exception, one s390x running Linux.

  • aaronvg an hour ago ago

    Makes me wonder whether we would have the same vulnerability if an LLM had written this decoder. It's tricky to write safe hardware accelerated code.

  • spidermonkey23 2 hours ago ago

    The string of A's reminds me of the ssh exploit recently.

  • dboreham 2 hours ago ago

    "vibe-uncoding" -- have actually been doing quite a bit of that in my older projects.

  • cpach 2 hours ago ago

    .

    • ryanschaefer 2 hours ago ago

      This should be the main thread as this is the primary source

      • cpach an hour ago ago

        Fair!

  • bullen 35 minutes ago ago

    This is the code I use since 20 years back:

    http://move.rupy.se/file/base64.txt

    If this part becomes the bottleneck; so I need to write a GPU accelerated version I'll eat my own hat.

    • CAP_NET_ADMIN 17 minutes ago ago

      Vectorized base64 can reach speeds in the proximity of memory copy.

      I've easily reached a point where it was worth it to go AVX route in my "for funsies" game that I'm making.

      • CAP_NET_ADMIN 14 minutes ago ago

        Just checked, the scalar version reaches around 1-2GB/s when decoding, optimized it gets to 4GB/s, AVX-512 VBMI version reaches 40-55GB/s.

        • bullen 12 minutes ago ago

          Interesting, what game are you making?

  • mushufasa 2 hours ago ago

    where is the dancing girl in the exploit videos???

    • 3dedb728-3f77 2 hours ago ago

      Yes, this is pretty much required now after the last.

      • cpach an hour ago ago

        I’m probably boring, but IMHO a plain video is easier to digest (:

  • DarkmSparks 2 hours ago ago

    me using java for so long I have my own util.Base64 class used everywhere in pure java.

    now panicking in case some LLM imported this without me noticing.

    edit: it did. :(

  • titzer an hour ago ago

    Encode binary data in text because some dumb thing can't process binary. Text back to binary slow, so better make use of ridiculously wide vector width thing to speed up dumb decoding step we should have never become reliant on in hot paths. Derp, memory safety bug. Derp, die because performance "optimization".

    Our incredibly high tower of Jenga blocks is falling down under its own weight.

    So many promotions because of optimizing cosmically unnecessary work, though.

    Derp, derp, this is humans making computers.

    As a person who does these kinds of optimizations, it hits in the feels.

  • LastTrain an hour ago ago

    Seems like security through obscurity might be a thing after all.

  • jeffbee 2 hours ago ago

    If I owned an entire language platform with a JIT, it would not contain assembly in its standard library, it would simply be improved until it generated something at least that fast from high-level source code on that target CPU.

    This is something I really like about LLVM. Their libc isn't spilling over with hand-written assembly. It's written in straightforward C++ under the belief that the compiler does, or will do, a good job.

  • secondcoming 2 hours ago ago

    Why would anyone write the scalar part of a SIMD'd function in assembly code!?

    • magackame 2 hours ago ago

      pure love for the game

  • 9029 2 hours ago ago

    So who leaked it?

  • Sigmazero60 3 hours ago ago

    We set UseAVX=2 on all our jdk hosts last year for unrelated thermal issues, turns out that saved us here

  • eyalitki 3 hours ago ago

    The fact that mainstream modules have such trivial bugs in logic that can be fully covered by testing is staggering. It is about time software developers will have proper test coverage for their code, at least for basic "unit" modules. Maybe we can even name a testing philosophy to match it.

    • Noe2097 2 hours ago ago

      Not sure this is as trivial as it seems. The bug triggers on a specific instruction set, on a precise input length, with a specific character at the end, and when on the hot path, and requires low level memory access checking to be detected.

      • spockz 2 hours ago ago

        For the finished jre yes. But one would hope these kind of checks are also run on a hand rolled decoder function. Fuzzing that one and finding logic bugs is a lot easier

    • ajasmin 2 hours ago ago

      Finding these kind of bugs would have required fuzzing and some kind of bound checking canaries. Not sure all bound checkers work on the hand-optimized assembly.

      Or as it turns out an LLM! Not clear whether their agent spawned any classic tools...

  • spullara 2 hours ago ago

    please stop using native code that hasn't been proven

  • nikanj 2 hours ago ago

    Just as with CVE-2026-98432, Debian is immediately patched at embargo drop, Ubuntu still isn't patched.

    Why do we even pay for Ubuntu?

    • cpach 2 hours ago ago

      Are you sure? I can’t see any Debian advisory for this vuln.

      https://www.debian.org/security/

    • mitchweaver 2 hours ago ago

      Uhh, Debian is NOT patched as of this writing.

      Fortunately I run name-brand Oracle(R) Java(tm), which did publish updated packages.