Skip to content

Transport.connect(): fix host key test - #1066

Open
SebastianDeiss wants to merge 1 commit into
paramiko:2.2from
SebastianDeiss:2.2-gsskex-hostkey-check-fix
Open

SebastianDeiss wants to merge 1 commit into
paramiko:2.2from
SebastianDeiss:2.2-gsskex-hostkey-check-fix

Conversation

@SebastianDeiss

Copy link
Copy Markdown

Skip the host key check in Transport.connect() only, if the transport actually used gssapi-keyex.

Before this change, a MITM attack on the paramiko ssh client with gss_kex=True was possible by having a server that does not support gssapi-keyex and gives any or no host key.

This pull fixes the same issue as #1059, but for Transport.connect().

Skip the host key check only, if the transport actually used
gssapi-keyex.
Comment thread paramiko/transport.py
# If GSS-API Key Exchange was performed, we are not required to check
# the host key.
if (hostkey is not None) and not gss_kex:
if (hostkey is not None) and not self.gss_kex_used:

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.

is this "too early"? might gss_kex_used be set just below via self.auth_gssapi_keyex(username)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

gss_kex_used is not set in transport.py. It is set in kex_gss.py. The host key check is performed during key exchange (or not, if GSS-API is used) and therefore must be done in Transport.connect().

In Transport.auth_gssapi_keyex(username) the user is authenticated if a successful GSS-API key exchange was performed. That's a different layer in the SSH protocol.

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 see, makes sense (gss is setup via start_client() -> start() -> run() -> _send_kex_init() / _expect_packet()) - I'm not familiar with gss, just clarifying :)

@bitprophet bitprophet added this to the 2.2.3 milestone Sep 19, 2017
@bitprophet bitprophet modified the milestones: 2.4.x, Next bugfix May 1, 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.

3 participants