# Java4Shell: Write once, RCE everywhere

Malformed Base64 input triggers negative length in OpenJDK's AVX-512 assembly decoder, writing 62 bytes past a 50-byte buffer, enabling memory disclosure or RCE.

- Payout: Research
- Severity: critical
- Program: OpenJDK
- Write-up by: @calif_io
- Disclosed: 2026-11-17
- CVE: CVE-2026-114938
- Write-up quality: 7/10
- Original: https://calif.io/java4shell/
- Library page: https://bugbountylibrary.com/r/blog%3Acalif-io-java4shell
- Tags: area:oss domain:oss impact:data-leak impact:rce kind:research platform:research sev:critical tech:java technique:chained technique:source-review vuln:memory-corruption

**Target:** OpenJDK Base64 decoder (AVX-512 VBMI assembly path)
**Root cause:** The hand-rolled assembly handling the final Base64 characters mishandles a stray '=' padding char, computing a negative output length that is treated as a full 64-byte write, overflowing the allocated output array.
**Steps:**
1. Run on x86-64 CPU supporting AVX-512 VBMI.
2. Decode the 65-char input `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=` (128 A's + `=` on older OpenJDK 17).
3. Decoder allocates 50-byte result array, decodes first 64 chars, then mishandles the stray `=` producing a negative length.
4. Negative length becomes a 64-byte write, sending 62 bytes past the array end into neighboring objects before Java rejects the input.
**How found:** Calif used AI agents to hunt the OpenJDK codebase; Quang Luong found the bug in an hour and built the first working exploit in two more, aided by pre-built pipelines and strategies directing the agents.
**Exploitation:** Corruption of neighboring heap objects after the 50-byte output array; with careful heap grooming the overflow can leak sensitive memory (Heartbleed-style) or be shaped into RCE. No universal exploit: chains differ per application depending on how Base64 is reached (auth, file upload, TLS client). Demonstrated pre-auth RCE in Keycloak, Jira, Confluence, Artifactory, Jenkins, PingFederate; post-auth in Kafka, Solr, Elasticsearch, Gerrit, Spinnaker; also Struts/Spring Boot apps and a client-side TLS exploit by samczsun.
**Escalation:** Chained the memory corruption into full RCE across multiple default-config products, and a client-side variant where a Java program connecting to a malicious TLS server is compromised without exposing any service.
**Insight:** Native/assembly fast paths bolted onto memory-safe runtimes (SIMD Base64, crypto, compression) are prime targets: audit the tail/padding handling of hand-written SIMD loops where length arithmetic can go negative, and reach them through ordinary features like auth and file upload.

## Proof of concept (copied exactly from the original report)

**Base64 trigger input for memory corruption**

```
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
```

## Write-ups of the same bug (oldest first)
- 2026-11-17: [Java4Shell: Write once, RCE everywhere](https://bugbountylibrary.com/r/blog%3Acalif-io-java4shell) — @calif_io (this one)
- 2026-11-18: [Aikido's Deep Review finds Java4Shell in the PR that introduced it](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-deep-review-finds-java4shell-in-pr) — Aikido Security
- 2026-11-18: [CVE-2026-114938 | Oracle Java SE and OpenJDK Base64 Decoder Heap Buffer Overflow Vulnerability (Java4Shell)](https://bugbountylibrary.com/r/blog%3Ahorizon3-ai-attack-research-vulnerabilities-cve-2026-114938) — Horizon3

