Skip to content

8293176: SSLEngine handshaker does not send an alert after a bad parameters #15148

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

djelinski
Copy link
Member

@djelinski djelinski commented Aug 4, 2023

Please review this patch that ensures that all exceptions thrown by SSLEngine delegated tasks are translated to alerts.

All exceptions should already be translated to SSLExceptions and alerts by the time we exit from context.dispatch; these exceptions are rethrown by conContext.fatal without modification. With this patch the remaining exceptions are translated to internal_error alerts.

SSLSocket implements similar handling in SSLSocketImpl#startHandshake. SSLSocket rethrows SocketExceptions without modification, and translates other IOExceptions to handshake_failure alerts. SSLEngine does not need to handle SocketExceptions, and IMO internal_error is a better choice here.

Tier1-3 tests pass.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8293176: SSLEngine handshaker does not send an alert after a bad parameters (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15148

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2023

👋 Welcome back djelinski! 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 openjdk bot changed the title 8293176 8293176: SSLEngine handshaker does not send an alert after a bad parameters Aug 4, 2023
@openjdk
Copy link

openjdk bot commented Aug 4, 2023

@djelinski 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.

@openjdk openjdk bot added the security security-dev@openjdk.org label Aug 4, 2023
@djelinski djelinski marked this pull request as ready for review August 4, 2023 08:33
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 4, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 4, 2023

Webrevs

try {
eng.wrap(emptyBuf, alert);
throw new RuntimeException("Expected wrap to throw");
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Catching Exception here will consume the RuntimeException being thrown.

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, right. Fixed.

eng.wrap(emptyBuf, alert);
throw new RuntimeException("Expected wrap to throw");
} catch (Exception e) {
System.err.println("Received expected exception:");
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it useful when looking at logs to have the message explicitly say what exception is expected.

*/
public class SSLEngineDecodeBadPoint {
static final byte[] clientHello = HexFormat.of().parseHex(
"160303013a0100013603031570" +
Copy link
Contributor

Choose a reason for hiding this comment

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

This may be the github display but this line is indented differently than the others.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing it out, fixed. Apparently my IntelliJ prefers this style of formatting multiline strings. I wonder if that's configurable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe so, but I still have to do some of the formatting by hand.

Copy link
Contributor

@mpdonova mpdonova left a comment

Choose a reason for hiding this comment

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

LGTM

@djelinski
Copy link
Member Author

Can I get another review on this?

Copy link
Member

@jnimeh jnimeh left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk
Copy link

openjdk bot commented Sep 26, 2023

@djelinski 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:

8293176: SSLEngine handshaker does not send an alert after a bad parameters

Reviewed-by: mdonovan, jnimeh

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 703 new commits pushed to the master branch:

  • 36ac839: 8073061: (fs) Files.copy(foo, bar, REPLACE_EXISTING) deletes bar even if foo is not readable
  • efb7e85: 8316935: [s390x] Use consistent naming for lightweight locking in MacroAssembler
  • 4e1e579: 8315920: C2: "control input must dominate current control" assert failure
  • 1f7dfda: 8316671: sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java test fails intermittent with Read timed out
  • 20ff603: 8316735: Print LockStack in hs_err files
  • e510dee: 8316098: Revise signature of numa_get_leaf_groups
  • 1513e79: 8316940: Serial: Remove unused declarations in genCollectedHeap
  • 52983ed: 8303737: C2: Load can bypass subtype check that enforces it's from the right object type
  • 9e6cb62: 8316851: Add @sealedGraph to Executable
  • 3fe6e0f: 8308479: [s390x] Implement alternative fast-locking scheme
  • ... and 693 more: https://git.openjdk.org/jdk/compare/0a3c6d6bd010231d02e92016037149e85fb1db3f...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Sep 26, 2023
@djelinski
Copy link
Member Author

Thanks for the reviews!

/integrate

@openjdk
Copy link

openjdk bot commented Sep 27, 2023

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

  • fd52be2: 8316895: SeenThread::print_action_queue called on a null pointer
  • e39197e: 8316933: RISC-V: compiler/vectorapi/VectorCastShape128Test.java fails when using RVV
  • b659e03: 8316897: tools/jpackage/junit tests fail on AIX after JDK-8316547
  • 83806ab: 6450193: After the first Serialization, JTableHeader does not uninstall its UI
  • 2f311d5: 8316211: Open source several manual applet tests
  • 65227a3: 8316389: Open source few AWT applet tests
  • 788e6e1: 8316218: Open some swing tests 5
  • ee9776f: 8304839: Move TestScaffold.main() to the separate class DebugeeWrapper
  • 36ac839: 8073061: (fs) Files.copy(foo, bar, REPLACE_EXISTING) deletes bar even if foo is not readable
  • efb7e85: 8316935: [s390x] Use consistent naming for lightweight locking in MacroAssembler
  • ... and 701 more: https://git.openjdk.org/jdk/compare/0a3c6d6bd010231d02e92016037149e85fb1db3f...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Sep 27, 2023
@openjdk openjdk bot closed this Sep 27, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Sep 27, 2023
@openjdk
Copy link

openjdk bot commented Sep 27, 2023

@djelinski Pushed as commit fee9d33.

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

@djelinski djelinski deleted the sslengine-bad-clienthello branch September 27, 2023 08:09
Copy link
Contributor

@bradfordwetmore bradfordwetmore left a comment

Choose a reason for hiding this comment

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

This comment comes too late to catch this integration, but a thought as I was looking over the code.

*/
public class SSLEngineDecodeBadPoint {
static final byte[] clientHello = HexFormat.of().parseHex(
"160303013a0100013603031570" +
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe so, but I still have to do some of the formatting by hand.

} catch (Exception e) {
throw context.conContext.fatal(Alert.INTERNAL_ERROR,
"Unhandled exception", e);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any chance this will double alert?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really. Only the first call to fatal sends an alert, subsequent calls just rethrow the given exception, wrapping it in a SSLException if necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for confirming.

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 security-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

4 participants