When java4shell was written up, I wanted to see how far I could get at understanding it from the source alone, before reading a full analysis. The method turned out to be mechanical enough that an LLM did most of the work.

Original notes and their hash

I posted the SHA-256 hash of my notes on X. Download the original Markdown, preserved byte-for-byte as written.

Step 1 — Find where it starts

The first question for any version-dependent bug: which release introduced it, and not just the major, the exact minor. For java4shell the trail led into the AVX-512 Base64 code — a direction I got from a public DataDog note pointing at that area, which saved a lot of blind searching.

Step 2 — Diff adjacent versions, pairwise

For every affected major.minor, diff it against major.minor-1. Do that for all the pairs, not just one. The bug lives in whatever each newly affected minor changed.

On java4shell this surfaces two things in stubGenerator_x86_64.cpp: the entry-gate threshold that decides when the AVX-512 path runs (128 bytes in JDK 17, 31 bytes in JDK 21), and the handful of instructions around the Base64 decode where the output size is computed.

Step 3 — Take the union

Collect the changes across all those diffs and union them. What’s left is a small set of lines: the threshold change, and the output-size math where a short input can make the size underflow — a negative value that becomes an all-ones mask and an out-of-bounds write. Comparing JDK 21.0.12 vs 21.0.13 confirms the decode stub itself is byte-identical; the real difference is the gate, so the fix lands in a later patch release.

OpenCode source analysis comparing JDK versions and AVX-512 entry thresholds, with terminal tab names redacted.

Source analysis during the investigation. Click the screenshot to read it at full size.

That’s the whole human part.

Step 4 — Let the model reproduce it

I handed the relevant source and the diffs to an LLM (GLM) and asked it to analyse the mechanism and build a reproduction. It read the code, worked out the underflow, and produced a crash case.

It reproduced the underflow — the memory-corruption primitive — not a working exploit. Turning a bounded out-of-bounds write into reliable remote code execution is a much harder, separate problem, and one this post deliberately stops short of.

ChatGPT comparison of my findings with the published Java4Shell analysis, with the conversation URL redacted.

A later model-generated comparison with the published analysis; this is a summary, not independent validation.

What I took from it

  • Version bisection plus pairwise diffs is a great fit for an LLM. The work is repetitive, the signal sits in small diffs, and a model holds the whole set at once better than I do.
  • A single public pointer (“look at the AVX-512 code”) collapsed the search. The method scales; direction still matters.
  • There’s a real line between understanding and reproducing a crash and weaponizing it, and it’s worth naming. This post is about the first.
  • One coding assistant declined to help while the vulnerability was still embargoed. That is the disclosure window working as intended: the same analysis is routine once a bug is public, and off-limits before.