Skip to content

V2ClientHello first_packet check is slightly off #1298

Closed

Description

@davidben

In ssl3_record.c, the first_packet flag is used to check if a V2ClientHello is acceptable:
https://github.com/openssl/openssl/blob/master/ssl/record/ssl3_record.c#L161

But first_packet is actually set in the state machine layer (first_message or so might be a better name).
https://github.com/openssl/openssl/blob/master/ssl/statem/statem.c#L500
https://github.com/openssl/openssl/blob/master/ssl/statem/statem.c#L558

This is desirable for the record-layer version check; that logic should apply to all records from the ClientHello.
https://github.com/openssl/openssl/blob/master/ssl/record/ssl3_record.c#L1509

But not for V2ClientHello. The peer might send a handshake record containing the first byte of a (V3) ClientHello, followed by a V2ClientHello. I haven't tried this, but by inspection I believe the current logic would accept such an input and get a little confused.

Activity

  1. davidben commented on Jul 11, 2016

    @davidben
    ContributorAuthor

    To clarify, this difference is because handshake messages may be fragmented. The first message may span the first several records if the peer is being obnoxious.

    (This only affects the master branch. 1.0.x uses a very different V2ClientHello mechanism.)

  2. added this to the milestone on Jul 18, 2016
  3. self-assigned this
    on Jul 25, 2016
  4. mattcaswell commented on Jul 29, 2016

    @mattcaswell
    Member

    Should be fixed in 0647719.

  5. davidben commented on Jul 29, 2016

    @davidben
    ContributorAuthor

    Checking s->init_num in the low-level record logic seems kind of a layering violation. And indeed you all also needed to check the empty record count which is weird. Come to think of it, I think you missed another case: what if you got a warning alert before the V2ClientHello?

    Why not add a is_first_record bit? Checking the recv sequence number + asserting we're in the unencrypted epoch is probably also reasonable.

    It should also be easy to write tests for this. (Hrm. We don't have test like this. I'll go fix that...)

  6. davidben commented on Jul 29, 2016

    @davidben
    ContributorAuthor

    (Hrm. We don't have test like this. I'll go fix that...)

    Okay, if you patch these into https://github.com/google/openssl-tests, it might work for verifying this?
    https://boringssl-review.googlesource.com/c/9040/

    (Probably worth a test for server renego too. I didn't add that one because we never accept renegotiations as a server.)

  7. richsalz commented on Aug 1, 2016

    @richsalz
    Contributor
  8. mattcaswell commented on Aug 1, 2016

    @mattcaswell
    Member

    See #1374

  9. mattcaswell commented on Aug 15, 2016

    @mattcaswell
    Member

    Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions