Skip to content

Address feedback on SSLv2 ClientHello processing - #1374

Closed
mattcaswell wants to merge 5 commits into
openssl:masterfrom
mattcaswell:sslv2hello-layering
Closed

mattcaswell wants to merge 5 commits into
openssl:masterfrom
mattcaswell:sslv2hello-layering

Conversation

@mattcaswell

Copy link
Copy Markdown
Member

Feedback on the previous SSLv2 ClientHello processing fix was that it
breaks layering by reading init_num in the record layer. It also does not
detect if there was a previous non-fatal warning.

This is an alternative approach that directly tracks in the record layer
whether this is the first record.

GitHub Issue #1298

@mattcaswell mattcaswell added this to the 1.1.0 milestone Aug 1, 2016
@mattcaswell

Copy link
Copy Markdown
Member Author

Ping @davidben. Thoughts?

Comment thread ssl/record/ssl3_record.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(I believe read_hash/enc_read_ctx are indeed redundant, yeah. Likewise with the s->first_packet check. Though I'm not familiar with the 1.1.0 record-layer code so perhaps I'm missing something.)

This is a remarkably long-winded comment that, now that the logic is pretty straightforward, doesn't seem to add much. I'd probably just have written:

/*
 * The first record received by the server may be a V2ClientHello.
 */
if (s->server && RECORD_LAYER_is_first_record(&s->rlayer)
        && (p[0] & 0x80) && (p[2] == SSL2_MT_CLIENT_HELLO)) {

And maybe stuck the redundant checks in as asserts if they seemed interesting enough.

@davidben

davidben commented Aug 2, 2016

Copy link
Copy Markdown
Contributor

No tests? ;-)

Comment thread ssl/record/record_locl.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If is_first_record is really just a boolean, you may not need the vull versatility of setting a specific vlaue; just a RECORD_LAYER_clear_first_record() call would be sufficient.

@mattcaswell

Copy link
Copy Markdown
Member Author

I've added three new commits to this:

  • One addresses the feedback received so far
  • One implements a set of tests for V2ClientHello processing
  • One fixes a bug where we didn't send an alert if we received a non-initial record with the wrong version discovered as a result of the above tests.

@mattcaswell

Copy link
Copy Markdown
Member Author

Needs a team member review.

@davidben

davidben commented Aug 3, 2016

Copy link
Copy Markdown
Contributor

(Non-team-member lgtm. But I don't really know perl, so I just glossed over those bits.)

Comment thread test/recipes/70-test_sslrecords.t Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This line is unneeded.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed

@kaduk

kaduk commented Aug 3, 2016

Copy link
Copy Markdown
Contributor

Another non-team-member lgtm, modulo the commented duplicate line, and I only sort-of looked at the perl.

@mattcaswell

Copy link
Copy Markdown
Member Author

Duplicate line removed. So two non-team member reviews done - still need another team review!

@mattcaswell

Copy link
Copy Markdown
Member Author

Ping any team member!!

Feedback on the previous SSLv2 ClientHello processing fix was that it
breaks layering by reading init_num in the record layer. It also does not
detect if there was a previous non-fatal warning.

This is an alternative approach that directly tracks in the record layer
whether this is the first record.

GitHub Issue openssl#1298
If we receive a non-initial record but the version number isn't right then
we should send an alert.
Test that we handle a TLS ClientHello in an SSLv2 record correctly.
@mattcaswell

Copy link
Copy Markdown
Member Author

Rebased this.

@t-j-h

t-j-h commented Aug 15, 2016

Copy link
Copy Markdown
Member

+1 - code looks much clearer to me at least

@mattcaswell

Copy link
Copy Markdown
Member Author

Merged. Thanks @t-j-h.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants