Skip to content

ssh/tailssh: add back a fake public key handler to support buggy clients#14967

Merged
oxtoacart merged 1 commit intorelease-branch/1.80from
percy/issue14922
Feb 10, 2025
Merged

ssh/tailssh: add back a fake public key handler to support buggy clients#14967
oxtoacart merged 1 commit intorelease-branch/1.80from
percy/issue14922

Conversation

@oxtoacart
Copy link
Copy Markdown
Contributor

@oxtoacart oxtoacart commented Feb 10, 2025

Some clients don't support 'none' authentication and insist on supplying
a public key. This change allows them to do so. It ignores the public key
and uses Tailscale to authenticate.

Updates #14922

I tested this by trying to tunnel pgadmin via a bastion host without and with the fix. Without the fix, it fails to even create the SSH tunnel.

image

With the fix, it gets further.

image

@oxtoacart oxtoacart force-pushed the percy/issue14922 branch 2 times, most recently from 41b2154 to 3892e78 Compare February 10, 2025 17:10
@oxtoacart oxtoacart requested review from awly and bradfitz February 10, 2025 17:11
@oxtoacart oxtoacart marked this pull request as ready for review February 10, 2025 17:11
Copy link
Copy Markdown
Member

@awly awly left a comment

Choose a reason for hiding this comment

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

Do we also need to update nextAuthMethodCallback?

// We then accept any public key since we've already authenticated & authorized them.
func (c *conn) fakePublicKeyHandler(ctx ssh.Context, pubKey ssh.PublicKey) error {
if err := c.doPolicyAuth(ctx); err != nil {
// TODO(maisem/bradfitz): surface the error here.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure what this comment means. It's logged and returned.

Does this mean sending a banner?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not sure, I carried it over from the old code. I'll remove it.

Comment on lines +437 to +438
// Note - tailssh_integration_test does not exercise this functionality because
// the client used for testing does not exhibit this buggy behavior.
Copy link
Copy Markdown
Member

@bradfitz bradfitz Feb 10, 2025

Choose a reason for hiding this comment

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

You can drop "note" ... all comments are notes.

And then add a date, as this is a temporary comment. And a tracking issue.

// As of 2025-02-10, tailssh_integration_test doesn't .... See tailscale/tailscale#nnnn.

@oxtoacart
Copy link
Copy Markdown
Contributor Author

nextAuthMethodCallback

No. This callback is only used if a previous auth method fails. We use it when someone supplies <username>+password as the username, in which case the NoClientAuthCallback sets anyPasswordOkay and returns an error, which will cause "password" to be used as the next auth method and prompt for a password.

In the public key flow, the client is actually hitting the public key callback immediately. I will update the commit comment to clarify this.

Note also that the original change that regressed this did not touch nextAuthMethodCallback.

@oxtoacart oxtoacart force-pushed the percy/issue14922 branch 7 times, most recently from 98e5676 to 55a8b8d Compare February 10, 2025 18:31
if err := c.isAuthorized(ctx); err != nil {
return err
}
c.logf("accepting SSH public key %s", bytes.TrimSpace(gossh.MarshalAuthorizedKey(pubKey)))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's make this message a bit less misleading. It kinda suggests we care/know about that key

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and do we even care to log the MarshalAuthorizedKey value?

Maybe "confused client presented an unnecessary SSH public key; pacifying already-authenticated client by saying it's fine"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll just take it out. We don't log results in the NoClientAuthCallback and I don't know that we need to here either.

Some clients don't support 'none' authentication and insist on supplying
a public key. This change allows them to do so. It ignores the public key
and uses Tailscale to authenticate.

Updates #14922

Signed-off-by: Percy Wegmann <percy@tailscale.com>
@oxtoacart oxtoacart merged commit aff2745 into release-branch/1.80 Feb 10, 2025
@oxtoacart oxtoacart deleted the percy/issue14922 branch February 10, 2025 21:58
@bradfitz
Copy link
Copy Markdown
Member

Oh! You were doing that on the release branch. Please don't do that unless absolutely required. Try to develop on main instead and cherry-pick fixes to the release branch.

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.

3 participants