Skip to content

8350830: Values converted incorrectly when reading TLS session tickets #24535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

nibjen
Copy link
Contributor

@nibjen nibjen commented Apr 9, 2025

Session resumption without server side state was added under JDK-8211018.
While it is TLSv1.2 session resumption, the client hello message is being parsed in SSLSessionImpl for each extensions.

Customer has reported handshake failure and is reproducible locally with exception NegativeArraySizeExceptions when there is ServerNameIndication with size > 127.
According to RFC 3546, the host_name limit allowed is 255.
With a sample testcase when the host_name length is > 127, exception is thrown:
javax.net.ssl|DEBUG|71|Thread-1|2025-04-06 17:13:07.278 UTC|ClientHello.java:825|Negotiated protocol version: TLSv1.2
javax.net.ssl|WARNING|71|Thread-1|2025-04-06 17:13:07.281 UTC|SSLSocketImpl.java:1672|handling exception (
"throwable" : {
java.lang.NegativeArraySizeException: -1
at java.base/sun.security.ssl.SSLSessionImpl.(SSLSessionImpl.java:399)
at java.base/sun.security.ssl.SessionTicketExtension$T12CHSessionTicketConsumer.consume(SessionTicketExtension.java:468)

e.g.
int l = buf.get();
b = new byte[l]; <-------------------- NegativeArraySizeException thrown here when > 127

For TLSv1.3, its not an issue until length > 255.

According to RFC 5077, PSK identity length allowed is <0..2^16-1> and so its value conversion being taken care of under this change.
Master secret is allowed for 48 bytes - master_secret[48], shouldnt be an issue.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 2 Reviewers)

Issue

  • JDK-8350830: Values converted incorrectly when reading TLS session tickets (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24535/head:pull/24535
$ git checkout pull/24535

Update a local copy of the PR:
$ git checkout pull/24535
$ git pull https://git.openjdk.org/jdk.git pull/24535/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24535

View PR using the GUI difftool:
$ git pr show -t 24535

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24535.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 9, 2025

👋 Welcome back nibjen! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 9, 2025

@nibjen This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8350830: Values converted incorrectly when reading TLS session tickets

Reviewed-by: djelinski, ascarpino

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 608 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@djelinski, @ascarpino) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 9, 2025
@openjdk
Copy link

openjdk bot commented Apr 9, 2025

@nibjen The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Apr 9, 2025

Webrevs


import javax.net.ssl.*;
import javax.net.ssl.SSLEngineResult.HandshakeStatus;
import java.io.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: wildcard import

Copy link
Member

@djelinski djelinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Here's a +1 from me, but please wait for the usual reviewers.

/reviewers 2 reviewer

@openjdk
Copy link

openjdk bot commented Apr 14, 2025

⚠️ @nibjen the full name on your profile does not match the author name in this pull requests' HEAD commit. If this pull request gets integrated then the author name from this pull requests' HEAD commit will be used for the resulting commit. If you wish to push a new commit with a different author name, then please run the following commands in a local repository of your personal fork:

$ git checkout JDK-8350830
$ git commit --author='Preferred Full Name <[email protected]>' --allow-empty -m 'Update full name'
$ git push

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 14, 2025
@openjdk
Copy link

openjdk bot commented Apr 14, 2025

@djelinski
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 2 Reviewers).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Apr 14, 2025
@ascarpino
Copy link
Contributor

I will look at this.. At the time I wrote this I avoided using Record for a reason, but I don't remember why right now.

@nibjen
Copy link
Contributor Author

nibjen commented Apr 27, 2025

@ascarpino @jnimeh since I am waiting for one more review, can you please review it.

Copy link
Contributor

@ascarpino ascarpino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good. When stateless was integrated, I remember seeing a problem with Record, but at least from your changes I don't see that problem here. I'm assuming you have tested this change with jdk_security1, 2, 3, and 4?

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 2, 2025
@nibjen
Copy link
Contributor Author

nibjen commented May 7, 2025

Thanks @ascarpino. Yes I have run/verified for all tiers explicitly.

@nibjen
Copy link
Contributor Author

nibjen commented May 7, 2025

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label May 7, 2025
@openjdk
Copy link

openjdk bot commented May 7, 2025

@nibjen
Your change (at version 9e0e0bc) is now ready to be sponsored by a Committer.

@djelinski
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented May 8, 2025

Going to push as commit 2c1eb33.
Since your change was applied there have been 622 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 8, 2025
@openjdk openjdk bot closed this May 8, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels May 8, 2025
@openjdk
Copy link

openjdk bot commented May 8, 2025

@djelinski @nibjen Pushed as commit 2c1eb33.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security [email protected]
Development

Successfully merging this pull request may close these issues.

5 participants