On Mon, 2 Nov 2026 05:22:39 GMT, Timofei Fedotov <[email protected]> wrote:

>> DTLSReassembler can queue fragments of the same handshake message with 
>> different total messageLength values. Reassembly holes are initialized from 
>> the first fragment, while the output array is allocated using the fragment 
>> with the lowest offset.
>> 
>> For the same epoch, message sequence, and HELLO_REQUEST type, submit these 
>> fragments in order:
>> offset 5, length 50, total message length 100;
>> offset 0, length 5, total message length 10;
>> offset 55, length 45, total message length 100.
>> 
>> The final fragment completes the holes, but copying the buffered fragments 
>> into the array sized for a ten-byte message triggers 
>> ArrayIndexOutOfBoundsException. SSLEngineImpl catches this runtime exception 
>> and reports a fatal SSLException; it does not establish a JVM crash.
>> 
>> Expected behavior the inconsistent handshake metadata must be rejected as a 
>> protocol error before fragment reassembly.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Timofei Fedotov has updated the pull request incrementally with two 
> additional commits since the last revision:
> 
>  - Verify complete DTLS handshake fragment reassembly
>  - Test inconsistent DTLS handshake fragment types

test/jdk/javax/net/ssl/DTLS/InconsistentFragmentLength.java line 29:

> 27:  * @summary Reject inconsistent metadata in DTLS handshake fragments
> 28:  * @library /test/lib
> 29:  * @run main InconsistentFragmentLength

Nit: this line is not really needed, `main()` is called by default.

test/jdk/javax/net/ssl/DTLS/InconsistentFragmentLength.java line 129:

> 127:         }
> 128:         Asserts.assertEquals(engine.getHandshakeStatus(),
> 129:                 SSLEngineResult.HandshakeStatus.NEED_WRAP);

Here is the sequence of events:

1. `unwrap()` returns NEED_TASK.
2. The application executes `DelegatedTask.run()`, which catches and stores an 
exception.
3. A later `wrap()` or `unwrap()` calls `checkTaskThrown()` and rethrows that 
exception.

Thus, after running the tasks, call `wrap()` and assert successful ClientHello 
output. This also exposes any saved exception.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/33633#discussion_r4444990988
PR Review Comment: https://git.openjdk.org/jdk/pull/33633#discussion_r4444984433

Reply via email to