A security vulnerability in OpenJDK’s Base64 decoder implementation was identified, according to a GitHub pull request discussing issue 8392044. The bug exists in the AVX-512 VBMI (Vector Byte Manipulation Instructions) path of the StubGenerator::generate_base64_decodeBlock() function on x86_64 architecture.

The flaw occurs in code that handles leftover bytes during Base64 decoding. When processing inputs with lengths shorter than 4 bytes, the function incorrectly calculates an output size that can become negative. This negative value produces an invalid output mask, causing the stub to write data past the logical output length before returning to Java. According to the pull request discussion, this overwrites memory on the heap, potentially corrupting data structures.
Valid Base64 inputs always have lengths that are multiples of 4, so the vulnerability only triggers on malformed or invalid inputs. The example provided in the technical discussion is a string such as "A".repeat(64)+"=", which leaves 1 byte after the main processing loop.
The proposed fix is straightforward: add an early return to Java if the input length is less than 4, preventing the vulnerable code path from executing. This avoids the negative output size calculation and the resulting heap corruption.
According to comments in the pull request, the issue was resolved by having other developers take over the fix on the master branch, and the vulnerable code has since been removed from the codebase. The pull request itself became inactive and was eventually closed after remaining untouched for more than 8 weeks, with the resolution occurring through alternative means.
The Base64 decoder vulnerability demonstrates the risks of using SIMD (Single Instruction Multiple Data) intrinsics for security-sensitive operations without proper bounds checking and validation of edge cases. The discussion in the pull request raises questions about whether such optimizations should be implemented as internal vector intrinsics with comprehensive safety checks rather than as direct stub implementations.
Key facts
- The bug exists in the AVX-512 VBMI path of OpenJDK’s Base64 decoder on x86_64
- Invalid inputs shorter than 4 bytes trigger an output size calculation that becomes negative
- The negative output mask causes the decoder to write past the logical output buffer boundary, corrupting heap memory
- Valid Base64 inputs always have lengths that are multiples of 4, so malformed inputs are required to trigger the vulnerability
- The fix involves adding an early return to Java when input length is less than 4
