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

Proxy X11 Forwarding Support #3803

Merged
merged 1 commit into from
Jun 24, 2020
Merged

Proxy X11 Forwarding Support #3803

merged 1 commit into from
Jun 24, 2020

Conversation

fspmarshall
Copy link
Contributor

@fspmarshall fspmarshall commented Jun 4, 2020

Support for X11 forwarding to openssh nodes (WIP):

  • Basic forwarding logic to allow recording proxy to correctly handle X11 forwarding requests and channels.
  • Make X11 forwarding controllable via RBAC.
  • Support the permit-x11-forwarding cert extension.
  • Emit audit events for x11 forwarding requests & channels (recording proxy only).

Closes #3401


This PR enables minimal X11 forwarding support for teleport clusters by adding the ability to control the permit-X11-forwarding certificate extension via RBAC and giving teleport proxies the ability to correctly handle X11 forwarding requests/channels when in recording mode (X11 forwarding technically already worked when not in recording mode, but wasn't particularly useful without permit-X11-forwarding extension support). In order to leverage X11 forwarding, the user must hold a role with the permit_x11_forwarding option enabled:

kind: role
metadata:
  # ...
spec:
  options:
    permit_x11_forwarding: true
  # ...
version: v3

Since this PR only adds support to the proxy, openssh still needs to be used for both the client and node. Assuming node.example.com were an openssh node and alice had permit_x11_forwarding: true, she could graphically edit the contents of example.txt like so:

$ ssh -X -J proxy.example.com [email protected] gvim example.txt

Which, if the proxy is running in recording mode, would produce an audit event something like this:

{
    "event": "x11",
    "code": "T3008I",
    "user": "alice",
    "time": "2020-06-12T00:43:26Z",
    // ...
}

@ollyg
Copy link

ollyg commented Jun 10, 2020

just to note that I think the extension is permit-X11-forwarding (uppercase X) and this caught me out! thank you so much for working on this 😄

@fspmarshall fspmarshall force-pushed the fspmarshall/x11-fwd-proxy branch 3 times, most recently from e2f031a to 5807c8c Compare June 12, 2020 00:08
@fspmarshall fspmarshall marked this pull request as ready for review June 12, 2020 00:52
Copy link
Contributor

@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.

Please add unit and/or integration tests

lib/services/role.go Outdated Show resolved Hide resolved
lib/services/types.proto Show resolved Hide resolved
lib/srv/forward/sshserver.go Show resolved Hide resolved
lib/srv/forward/sshserver.go Outdated Show resolved Hide resolved
lib/srv/forward/sshserver.go Outdated Show resolved Hide resolved
lib/srv/forward/sshserver.go Outdated Show resolved Hide resolved
lib/srv/forward/sshserver.go Show resolved Hide resolved
@benarent benarent added the OpenSSH For customers using Teleport and OpenSSH label Jun 15, 2020
lib/events/api.go Outdated Show resolved Hide resolved
lib/srv/forward/sshserver.go Outdated Show resolved Hide resolved
@fspmarshall fspmarshall force-pushed the fspmarshall/x11-fwd-proxy branch from 5807c8c to c583418 Compare June 22, 2020 21:35
lib/srv/forward/sshserver.go Show resolved Hide resolved
lib/srv/regular/sshserver_test.go Outdated Show resolved Hide resolved
lib/srv/regular/sshserver_test.go Outdated Show resolved Hide resolved
case <-ctx.Done():
return
}
c.Assert(nch.ChannelType(), Equals, teleport.ChanSession)
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe c.Assert is not thread-safe.
Probably easier to keep as is, but the race detector might complain.

lib/srv/regular/sshserver_test.go Outdated Show resolved Hide resolved
lib/srv/regular/sshserver_test.go Outdated Show resolved Hide resolved
lib/srv/regular/sshserver_test.go Outdated Show resolved Hide resolved
lib/srv/regular/sshserver_test.go Outdated Show resolved Hide resolved
lib/srv/regular/sshserver_test.go Show resolved Hide resolved
@russjones russjones added this to the 4.3 "Oceanside" milestone Jun 23, 2020
- Role options now include a `permit_x11_forwarding` bool
which is set to `false` by default.

- Recording proxies now forward X11 requests and channels
when when permitted by RBAC.

- User certs will now include the `permit-X11-forwarding`
extension when permitted by RBAC.

- If X11 forwarding is requested for a session a new `x11`
audit event is emitted by recording proxies.
@fspmarshall fspmarshall force-pushed the fspmarshall/x11-fwd-proxy branch from c583418 to 27ee262 Compare June 23, 2020 20:29
@fspmarshall fspmarshall merged commit dfd40d2 into master Jun 24, 2020
@fspmarshall fspmarshall deleted the fspmarshall/x11-fwd-proxy branch June 24, 2020 18:40
@sjackman
Copy link

sjackman commented Apr 6, 2022

$ tsh version  
Teleport v7.3.3 git: go1.17.2
$ tsh ssh -X remote-host
ERROR: unknown short flag '-X'

How do I use X11 forwarding with tsh ssh?

@ollyg
Copy link

ollyg commented Apr 6, 2022

Hi @sjackman you can only use -X with the openssh client (so, using ssh instead of tsh ssh). There are other restrictions such as not using recording mode on the proxy, best to get with Gravitational support for the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OpenSSH For customers using Teleport and OpenSSH
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support OpenSSH Extensions: permit-X11-forwarding
6 participants