Skip to content

Real CVEs: Java4Shell (CVE-2026-114938), November 2026

Real CVEMemory safetyIntermediate+151 -0

Click a line to select it, or press and drag down the changes to select a block (Shift-click works too). Then name the weakness and submit the finding. Each finding is marked as soon as you submit it. On the keyboard, Tab to a file's changes, move with the arrow keys, hold Shift to select a block, and press Enter to flag it.

src/hotspot/cpu/x86/stubGenerator_x86_64.cppmodified+151-0
src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
@@ -2675,0 +2675,69 @@
2675+ __ BIND(L_process64);
2676+
2677+ __ evmovdquq(pack24bits, ExternalAddress(StubRoutines::x86::base64_vbmi_pack_vec_addr()), Assembler::AVX_512bit, r13);
2678+
2679+ __ cmpl(length, 63);
2680+ __ jcc(Assembler::lessEqual, L_finalBit);
2681+
2682+ __ mov64(rax, 0x0000ffffffffffff);
2683+ __ kmovql(k2, rax);
2684+
2685+ __ align32();
2686+ __ BIND(L_process64Loop);
2687+
2688+ // Handle first 64-byte block
2689+
2690+ __ evmovdquq(input0, Address(source, start_offset), Assembler::AVX_512bit);
2691+ __ evmovdquq(translated0, lookup_lo, Assembler::AVX_512bit);
2692+ __ evpermt2b(translated0, input0, lookup_hi, Assembler::AVX_512bit);
2693+
2694+ __ vpor(errorvec, translated0, input0, Assembler::AVX_512bit);
2695+
2696+ // Check for error and bomb out before updating dest
2697+ __ evpmovb2m(k3, errorvec, Assembler::AVX_512bit);
2698+ __ kortestql(k3, k3);
2699+ __ jcc(Assembler::notZero, L_exit);
2700+
2701+ // Pack output register, selecting correct byte ordering
2702+ __ vpmaddubsw(merge_ab_bc0, translated0, pack16_op, Assembler::AVX_512bit);
2703+ __ vpmaddwd(merged0, merge_ab_bc0, pack32_op, Assembler::AVX_512bit);
2704+ __ vpermb(merged0, pack24bits, merged0, Assembler::AVX_512bit);
2705+
2706+ __ evmovdqub(Address(dest, dp), k2, merged0, true, Assembler::AVX_512bit);
2707+
2708+ __ subl(length, 64);
2709+ __ addptr(source, 64);
2710+ __ addptr(dest, 48);
2711+
2712+ __ cmpl(length, 64);
2713+ __ jcc(Assembler::greaterEqual, L_process64Loop);
2714+
2715+ __ cmpl(length, 0);
2716+ __ jcc(Assembler::lessEqual, L_exit);
2717+
2718+ __ BIND(L_finalBit);
2719+ // Now have 1 to 63 bytes left to decode
2720+
2721+ // I was going to let Java take care of the final fragment
2722+ // however it will repeatedly call this routine for every 4 bytes
2723+ // of input data, so handle the rest here.
2724+ __ movq(rax, -1);
2725+ __ bzhiq(rax, rax, length); // Input mask in rax
2726+
2727+ __ movl(output_size, length);
2728+ __ shrl(output_size, 2); // Find (len / 4) * 3 (output length)
2729+ __ lea(output_size, Address(output_size, output_size, Address::times_2, 0));
2730+ // output_size in r13
2731+
2732+ // Strip pad characters, if any, and adjust length and mask
2733+ __ addq(length, start_offset);
2734+ __ cmpb(Address(source, length, Address::times_1, -1), '=');
2735+ __ jcc(Assembler::equal, L_padding);
2736+
2737+ __ BIND(L_donePadding);
2738+ __ subq(length, start_offset);
2739+
2740+ // Output size is (64 - output_size), output mask is (all 1s >> output_size).
2741+ __ kmovql(input_mask, rax);
2742+ __ movq(output_mask, -1);
2743+ __ bzhiq(output_mask, output_mask, output_size);
@@ -2745,0 +2745,48 @@
2745+ // Load initial input with all valid base64 characters. Will be used
2746+ // in merging source bytes to avoid masking when determining if an error occurred.
2747+ __ movl(rax, 0x61616161);
2748+ __ evpbroadcastd(input_initial_valid_b64, rax, Assembler::AVX_512bit);
2749+
2750+ // A register containing all invalid base64 decoded values
2751+ __ movl(rax, 0x80808080);
2752+ __ evpbroadcastd(invalid_b64, rax, Assembler::AVX_512bit);
2753+
2754+ // input_mask is in k1
2755+ // output_size is in r13
2756+ // output_mask is in r15
2757+ // zmm0 - free
2758+ // zmm1 - 0x00011000
2759+ // zmm2 - 0x01400140
2760+ // zmm3 - errorvec
2761+ // zmm4 - pack vector
2762+ // zmm5 - lookup_lo
2763+ // zmm6 - lookup_hi
2764+ // zmm7 - errorvec
2765+ // zmm8 - 0x61616161
2766+ // zmm9 - 0x80808080
2767+
2768+ // Load only the bytes from source, merging into our "fully-valid" register
2769+ __ evmovdqub(input_initial_valid_b64, input_mask, Address(source, start_offset, Address::times_1, 0x0), true, Assembler::AVX_512bit);
2770+
2771+ // Decode all bytes within our merged input
2772+ __ evmovdquq(tmp, lookup_lo, Assembler::AVX_512bit);
2773+ __ evpermt2b(tmp, input_initial_valid_b64, lookup_hi, Assembler::AVX_512bit);
2774+ __ evporq(mask, tmp, input_initial_valid_b64, Assembler::AVX_512bit);
2775+
2776+ // Check for error. Compare (decoded | initial) to all invalid.
2777+ // If any bytes have their high-order bit set, then we have an error.
2778+ __ evptestmb(k2, mask, invalid_b64, Assembler::AVX_512bit);
2779+ __ kortestql(k2, k2);
2780+
2781+ // If we have an error, use the brute force loop to decode what we can (4-byte chunks).
2782+ __ jcc(Assembler::notZero, L_bruteForce);
2783+
2784+ // Shuffle output bytes
2785+ __ vpmaddubsw(tmp, tmp, pack16_op, Assembler::AVX_512bit);
2786+ __ vpmaddwd(tmp, tmp, pack32_op, Assembler::AVX_512bit);
2787+
2788+ __ vpermb(tmp, pack24bits, tmp, Assembler::AVX_512bit);
2789+ __ kmovql(k1, output_mask);
2790+ __ evmovdqub(Address(dest, dp), k1, tmp, true, Assembler::AVX_512bit);
2791+
2792+ __ addptr(dest, output_size);
@@ -2812,0 +2812,24 @@
2812+ __ BIND(L_padding);
2813+ __ decrementq(output_size, 1);
2814+ __ shrq(rax, 1);
2815+
2816+ __ cmpb(Address(source, length, Address::times_1, -2), '=');
2817+ __ jcc(Assembler::notEqual, L_donePadding);
2818+
2819+ __ decrementq(output_size, 1);
2820+ __ shrq(rax, 1);
2821+ __ jmp(L_donePadding);
2822+
2823+ __ align32();
2824+ __ BIND(L_bruteForce);
2825+ } // End of if(avx512_vbmi)
2826+
2827+ if (VM_Version::supports_avx2()) {
2828+ Label L_tailProc, L_topLoop, L_enterLoop;
2829+
2830+ __ cmpl(isMIME, 0);
2831+ __ jcc(Assembler::notEqual, L_lastChunk);
2832+
2833+ // Check for buffer too small (for algorithm)
2834+ __ subl(length, 0x2c);
2835+ __ jcc(Assembler::less, L_tailProc);
@@ -2903,0 +2903,5 @@
2903+ __ bind(L_tailProc);
2904+
2905+ __ addl(length, 0x2c);
2906+
2907+ __ vzeroupper();
@@ -2940,0 +2940,5 @@
2940+ __ bind(L_lastChunk);
2941+
2942+ __ shrl(length, 2); // Multiple of 4 bytes only - length is # 4-byte chunks
2943+ __ cmpl(length, 0);
2944+ __ jcc(Assembler::lessEqual, L_exit_no_vzero);

This challenge is Training Content. We encourage you to discuss it and to publish your own write-ups and videos of it. See the terms of service.

Opens in a new tab.