Skip to content

Comments

Fixes integer underflow with SSL_trace support#5706

Closed
catenacyber wants to merge 1 commit intoopenssl:masterfrom
catenacyber:tracedos
Closed

Fixes integer underflow with SSL_trace support#5706
catenacyber wants to merge 1 commit intoopenssl:masterfrom
catenacyber:tracedos

Conversation

@catenacyber
Copy link
Contributor

Since this is a non-default debug option, this doesn't look like a security issue.

Bug is in function ssl_print_extension in file ssl/t1_trce.c
In case TLSEXT_TYPE_application_layer_protocol_negotiation
There is a mistake in adding 1 to xlen instead of plen
So when xlen -= plen + 1;can underflow and as glen is size_t, it becomes 0xFFFFFFFFFFFFFFFF

To reproduce it, I run
./openssl s_server -trace
Then I run a malicious client which gives n+2 instead of n for the length of the string
And we keep reading the memory until something bad happens (segfault)

@dot-asm dot-asm added the approval: review pending This pull request needs review by a committer label Mar 21, 2018
size_t plen = *ext++;

if (plen > xlen + 1)
if (plen + 1 > xlen)
Copy link
Member

Choose a reason for hiding this comment

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

Side note: This stuff really needs to be rewritten to use the PACKET stuff. This is a typical example of the kind of issue we used to have before we switched to PACKET everywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This stuff really needs to be rewritten to use the PACKET stuff

I agree :-)

@mattcaswell mattcaswell added approval: done This pull request has the required number of approvals branch: master Applies to master branch 1.1.0 branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) branch: 1.0.2 Applies to OpenSSL_1_0_2-stable branch (EOL) and removed approval: review pending This pull request needs review by a committer labels Mar 21, 2018
@dot-asm
Copy link
Contributor

dot-asm commented Mar 21, 2018

??? There is no corresponding case in 1.1.0 (or 1.0.2)...

@mattcaswell
Copy link
Member

??? There is no corresponding case in 1.1.0 (or 1.0.2)...

Ok, great. I assumed there was, and was just about to go and double check it. It sounds like you already did.

@mattcaswell mattcaswell removed branch: 1.0.2 Applies to OpenSSL_1_0_2-stable branch (EOL) 1.1.0 labels Mar 21, 2018
@mattcaswell mattcaswell added this to the 1.1.1 milestone Mar 21, 2018
@mattcaswell
Copy link
Member

Pushed. Thanks.

levitte pushed a commit that referenced this pull request Mar 21, 2018
Reviewed-by: Andy Polyakov <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #5706)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants