Skip to content
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

Backport 2.7: Fix unsafe bounds check in ssl_load_session() #2132

Merged
merged 4 commits into from
Dec 7, 2018

Conversation

hanno-becker
Copy link

Summary: This is the backport to Mbed TLS 2.7 of #2131 fixing #659.

Internal Reference: IOTSSL-1046.

@hanno-becker hanno-becker added bug mbed TLS team needs-review Every commit must be reviewed by at least two team members, component-tls labels Oct 24, 2018
AndrzejKurek
AndrzejKurek previously approved these changes Oct 25, 2018
@hanno-becker
Copy link
Author

@AndrzejKurek Please re-review.

return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );

memcpy( session, p, sizeof( mbedtls_ssl_session ) );
p += sizeof( mbedtls_ssl_session );

#if defined(MBEDTLS_X509_CRT_PARSE_C)
if( p + 3 > end )
if( 3 > end - p )
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing (size_t)

@@ -219,14 +219,17 @@ static int ssl_load_session( mbedtls_ssl_session *session,
size_t cert_len;
#endif /* MBEDTLS_X509_CRT_PARSE_C */

if( p + sizeof( mbedtls_ssl_session ) > end )
if( end < p )
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is not in the original PR - is this intentional?

Copy link
Contributor

@AndrzejKurek AndrzejKurek left a comment

Choose a reason for hiding this comment

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

Please see my comments.

Hanno Becker added 4 commits October 26, 2018 10:08
Use `( x >> y ) & z` instead of `x >> y & z`. Both are equivalent
by operator precedence, but the former is more readable and the
commonly used idiom in the library.
@hanno-becker
Copy link
Author

@AndrzejKurek I was waiting for approval for the main PR before adapting the backports - sorry for not mentioning that. Please re-review.

@hanno-becker hanno-becker dismissed AndrzejKurek’s stale review October 26, 2018 09:28

Backport reworked in line with the changes in the main PR.

@hanno-becker hanno-becker removed the needs-review Every commit must be reviewed by at least two team members, label Oct 30, 2018
@Patater Patater merged commit 7cf2857 into Mbed-TLS:mbedtls-2.7 Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants