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

Set SSL_OP_LEGACY_SERVER_CONNECT when peeking at servers #1839

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rousskov
Copy link
Contributor

Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

noteNegotiationError: hold TLS write on FD 15 despite
SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
automatically enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.

Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

    noteNegotiationError: hold TLS write on FD 15 despite
    SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
_automatically_ enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.

----

Cherry-picked bag52a commit 9ef428c; fixed build by including IoManip.h.
@rousskov
Copy link
Contributor Author

Equivalent v5-based changes were successfully tested in production.

There is a mailing list thread related to this PR at https://lists.squid-cache.org/pipermail/squid-users/2024-June/026732.html.

Copy link
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

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

There is a CVE involved here, so while this appears "safe enough" at casual reading, I believe we would be better overall implementing more restricted support - that would be good also for the stare case, not just peek.

Which is https://www.rfc-editor.org/rfc/rfc5746 section 3.4 :

   o  The client MUST include either an empty "renegotiation_info"
      extension, or the TLS_EMPTY_RENEGOTIATION_INFO_SCSV signaling
      cipher suite value in the ClientHello.  Including both is NOT
      RECOMMENDED.

... so if both of those are absent from details we can safely set SSL_OP_LEGACY_SERVER_CONNECT. Otherwise leave OpenSSL doing its default thing, the client wants whatever validation it can get.

Also, consider doing this in applyTlsDetailsToSSL() with the other client feature pass-thru.

squid-anubis pushed a commit that referenced this pull request Jun 21, 2024
Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

    noteNegotiationError: hold TLS write on FD 15 despite
    SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
_automatically_ enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 21, 2024
squid-anubis pushed a commit that referenced this pull request Jun 22, 2024
Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

    noteNegotiationError: hold TLS write on FD 15 despite
    SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
_automatically_ enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 22, 2024
squid-anubis pushed a commit that referenced this pull request Jun 23, 2024
Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

    noteNegotiationError: hold TLS write on FD 15 despite
    SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
_automatically_ enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 23, 2024
squid-anubis pushed a commit that referenced this pull request Jun 25, 2024
Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

    noteNegotiationError: hold TLS write on FD 15 despite
    SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
_automatically_ enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 25, 2024
squid-anubis pushed a commit that referenced this pull request Jun 26, 2024
Squid TLS Server Hello parser does not treat legacy servers specially,
but enabling legacy server support in OpenSSL allows OpenSSL to advance
enough in its Server Hello processing to provide SslBump code with the
server certificate (that Squid then validates). Successful certificate
validation, in turn, may result in Squid splicing the connection, even
if OpenSSL detected other errors:

    noteNegotiationError: hold TLS write on FD 15 despite
    SQUID_TLS_ERR_CONNECT+TLS_LIB_ERR=2000068+TLS_IO_ERR=1

This change assumes that admins should not expect a peeking Squid to
_automatically_ enforce a particular set of handshake conditions (e.g.,
"no legacy TLS servers"). Peeking is interpreted as "get as much
handshake information as possible without breaking things" rather than
"automatically validate handshake, even if it risks breaking things". A
peeking Squid still validates the received origin certificate (where
available). If that assumption is proven wrong, we will need to make the
choice configurable.

TODO: When staring, apply tls_outgoing_options.
@squid-anubis squid-anubis added M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels labels Jun 26, 2024
@rousskov rousskov added M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels S-waiting-for-more-authors needs developer help labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels M-passed-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels S-waiting-for-more-authors needs developer help
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants