Commit Graph
295 Commits
Author SHA1 Message Date
Andrew LeFevre bb9bcca12c make session ID env vars agree (#53652) 2025-05-29 17:36:05 +00:00
rosstimothy 52816e8427 Bump golangci-lint to v2 (#54410)
* Bump golangci-lint to v2

* fix lints

* update e

* fix: delete removed cli option
2025-05-07 22:14:51 +00:00
Andrew Burke 1563f87db1 Add session details for agentless sftp sessions (#53360)
This change updates SFTP to emit sftp and sftp_summary events
for sessions on agentless nodes.
2025-04-08 17:36:10 +00:00
rosstimothy b25252a39e Prevent reauthentication for tilde prefix expansion errors (#51464)
In https://github.com/gravitational/teleport/pull/24254 expansion
of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was
explicitly denied. However, because the error returned to the user
is a trace.BadParameter error the reauthentication logic kicks in
and attempts to resolve the issue with fresh credentials. This
error is now caught and wrapped in a NonRetryableError to prevent
the authentication logic from providing a weird UX.

Updates https://github.com/gravitational/teleport/issues/22886.
2025-01-29 22:48:01 +00:00
Erik Tate 707c2ac807 adding additional audit log context around SSH port forwarding (#50932) 2025-01-17 01:04:08 +00:00
STeve (Xin) Huang f0abbce0fd GitHub proxy part 6: proxing Git using SSH transport (#49980)
* GitHub proxy part 6: proxing Git using SSH transport

* better command parsing and update suite

* refactor

* revert unnecearrty files

* address review comments

* ut fix

* revert localsite_test.go

* change special suffix to teleport-github-org for routing

* fix routing ut

* minor typo edit

* fix ut after sshca change

* add UT to sshutils

* minor review comments

* fix api ut because of special suffix change

* GitServerReadOnlyClient

* downgrade error to warning

* run go mod tidy. not sure why it's needed

* rename mock.go to mock_test.go
2025-01-14 21:48:04 +00:00
rosstimothy c80bdf8153 Convert lib/sshutils to use slog (#49829)
In addition to the conversion, the reverstunnel server now has
a slog.Logger provided so that it can be passed into the
sshutils.Server, is not used otherwise. A similar migration will
be performed in the future for the reversetunnel package.
2024-12-10 17:54:36 +00:00
STeve (Xin) Huang 903fee053f GitHub Proxy part 3: gen github user cert and export CA (#49396)
* GitHub Proxy part 3: gen github user cert and export CA

* address pr comment

* minor refactor

* use cache

* fix build and cache
2024-12-03 18:17:21 +00:00
Edoardo Spadolini bcbfa8192e Get rid of math/rand in favor of math/rand/v2 (#49294)
* Get rid of math/rand in favor of math/rand/v2

* Update retryutils to use rand.N

* Update e ref
2024-11-21 12:57:32 +00:00
rosstimothy e92dd312a4 Add host resolution support to tsh scp (#48465)
Extends tsh scp functionality to honor any defined proxy templates
when resolving the remote host.

Closes https://github.com/gravitational/teleport/issues/45465
2024-11-19 18:24:29 +00:00
Andrew Burke b8522ffa10 Fix remote port forwarding reporting wrong hostname (#48831)
This change fixes a bug in remote port forwarding where Teleport reports
the hostname from the created remote listener, rather than the
hostname requested in the tcpip-forward request.
2024-11-14 21:29:00 +00:00
Nic Klaassen 0a0d4137db eliminate rsa.GenerateKey and lib/auth/native (#47768) 2024-10-21 20:55:22 +00:00
Rafał Cieślak 7cf6119266 Reword errors shown in GUIs when attempting to download a folder (#46595)
* Use trace.Errorf instead of trace.BadParameter

* Rewrite err when downloading dir through Web UI and Connect
2024-09-13 14:27:23 +00:00
Andrew Burke a372c00393 Create host users once per conn (#45102)
This change updates host user creation to create users at the start
of a new SSH connection, rather than at the start of certain new
channels opening.
2024-08-21 21:13:49 +00:00
Brian Joerger 297500ac6a Fix flaky test caused by killed networking process. (#45641) 2024-08-21 18:22:59 +00:00
Brian Joerger ed8c7e1254 Try next x11 display on permission denied. (#45484) 2024-08-15 18:11:40 +00:00
Alan Parra dfbbba60ff chore: Bump golangci-lint to v1.60.1 (#45469)
* chore: Bump golangci-lint to v1.60.1

* Fix new golangci-lint offenders

* Fix api/ lint offenders
2024-08-14 14:46:57 +00:00
Brian JoergerandSakshyam Shah d26ca00120 Add teleport networking subprocess for port/agent/x11 forwarding (#43756)
* Add networking subprocess for port and agent forwarding.

* Remove extraneous x11 forwarding logic.

* Add x11 forwarding to the networking subprocess.

* Fix lint.

* Try create host user before starting networking process.

* Resolve comments

* Fix networking process memory leak.

* Run networking subprocess as root but change to user login after PAM call.

* Update agent forwarding socket dir permissions.

* Handle networking requests synchronously to maintain the current PAM context.

* Use user environment in networking process.

* Fix issue with PAM thread state being locked to the main goroutine; Clean up homeDir logic; Fix PAM thread state for xauth commands.

* Selectively handle some networking requests in goroutines.

* Address comments.

* Use an interrupt signal to trigger graceful exit in the networking subprocess.

* Cleanup unix sockets from the child namespace.

* Address comments.

* Remove extraneous network forwarding socket validation.

* Fix tests and lint.

* Re-add networking process done channel to avoid deadlocks on reading unix sockets passed to a dead process.

* Remove broken test.

* Address comments.

* Cleanup; remove unused child error file.

* - Explicility list file paths to clean up at the end of the networking process.
- Use terminate FD instead of interrupt to signal the process to exit.
- Log errors from the parent process.
- Read networking request response without goroutine.

* Cleanup.

* Make request socket a stream.

* Remove extraneious Chmod.

* Send request level error to request conn.

* Don't unlink unix sockets from the parent process.

* Read full error message from stream.

* Remove remaining logs in child process.

* Fix typos.

* web: support SAML resource deletion in unified resources view (#44311)

* update SAML app edit mechanism to accomodate both edit and delete functions

* use user saml idp access to disable menu actions

* add comment to ResourceActionButton props

* refactor: SamlAppActionContext to edit and delete Saml application

* address review comments

* Add networking process tests to replace old tests.

* Don't close remote file descriptor before the child process has a chance to connect to it.

* Fix lint; skip broken test.

* Disable broken test and restore older test to cover for it.

* Remove unused agent forwarding test.

* Fix lint, replace broken test.

* Fix old test that used testify/require in goroutine.

* Close request context immediately to avoid deadlock (extended timeout) on reading from the closed process.

---------

Co-authored-by: Sakshyam Shah <sshah@goteleport.com>
2024-08-13 21:59:39 +00:00
Nic Klaassen afca8aefc8 allow EC ssh keys in FIPS mode (#44476)
* allow EC ssh keys in FIPS mode

* fix test
2024-07-19 19:59:54 +00:00
Nic Klaassen b5cb34a307 support separate SSH and TLS keys in generateUserCert (#43894)
* support separate SSH and TLS keys in `generateUserCert`

This PR splits the SSH and TLS public keys passed to
`auth.(*Server).generateUserCert`. The attestation statement associated
with the public key is also split.

Now, `sshPublicKey` will be the subject public key of the returned SSH
certificate, and `tlsPublicKey` will be the subject public key of the
returned TLS certificate. If either is not provided, the corresponding
certificate is not generated or returned.

This does not update any code paths to actually use different keys here,
but prepares for that in the future.

* use public key conversion func

* fix public key format in db tests
2024-07-10 16:50:53 +00:00
Edoardo Spadolini 863230629b Get rid of uds.Conn (#43588) 2024-06-27 12:38:29 +00:00
Brian Joerger d13061b584 Check if listener is nil before wrapping. (#43201) 2024-06-21 00:32:17 +00:00
Edoardo Spadolini 33e80cd8f2 Support dynamic SSH host signers (#41227)
* Add a host signers callback to sshutils.Server

* Lift host signers callback into regular.Server

* Lift host signers callback into reversetunnel.Server
2024-05-13 13:11:44 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Andrew Burke 491130b20c Add remote port forwarding for Teleport nodes (#38828)
* Add remote port forwarding for Teleport nodes

This change adds support for remote port forwarding (ssh -R) for
Teleport nodes.

* Fix windows build
2024-03-15 22:58:36 +00:00
rosstimothy 1aec5414f1 Replace constants from trace with equivalents defined in teleport (#39307)
* Remove logging from circuit breaker

The logging is never output, and if it was would be very verbose.
Instead of dropping the level down to trace the logger is removed
entirely.

* Add constants from trace library

The logging functionality in trace is being removed in an upcoming
release. To prepare the logging component keys are copied from trace
into teleport.

* Convert trace.ComponentFields to teleport.ComponentFields

* Replace trace.Component with teleport.ComponentKey

* Replace trace logging constants
2024-03-14 13:04:29 +00:00
Andrew LeFevre 30400231de ensure moderated file transfers only perform allowed operations (#39091)
* ensure moderated file transfers only preform allowed operations

* fix sess test

* wip integration test

* integration test working

* tweak some error messages and test cases

* allow setstat for uploads

* address nits from code review

* expand paths when necessary when creating file transfer request

* improve UX of errors in web UI

* deny request when an invalid user tries to transfer files

* don't allow open requests, they aren't done by the webui

* address feedback

* use a buffered reader when reading the file request, address a few nits
2024-03-14 00:10:48 +00:00
Brian Joerger 6cd713f667 Fix ssh -X -oControlMaster to agentless nodes. (#38779)
* Fix X11 forwarding with OpenSSH option control master when connecting through the Proxy ssh forwarding service.

* Add X11Forwarding integration test with ControlMaster subtest.

* Refactor forwarding server to always forward x11 channel requests.

* Address comments.

* Fix x11 forwarding integration tests.
2024-03-12 17:45:54 +00:00
Andrew Burke 2277cf893d Add remote port forwarding for openssh servers (#38047)
This change adds server-side support for remote port forwarding
(ssh -R) for OpenSSH nodes.
2024-02-29 18:26:33 +00:00
Edoardo Spadolini bd47f0e02a Improve Teleport reload behavior (#37773)
* clean up pidfile and reloads

* reduce log spam during graceful shutdowns

* hold an exclusive advisory lock on the pidfile

* do systemd reloads with the pidfile rather than $MAINPID

* prioritize signals over internal restarts
2024-02-13 15:27:54 +00:00
rosstimothy b7318b5c7e Enable errorlint via golangci-lint (#37669)
Adds the new linter and configures it to prevent direct error
comparisions and type assertions in favor of errors.Is and errors.As.
All current violations caught by the linter have been updated
accordingly.
2024-02-02 15:59:24 +00:00
d25385dc3b SSH connection resumption (#36518)
* Add pre- and post-detect hooks to the multiplexer

This gets rid of the dedicated "already written" mechanism in
multiplexer.Conn.

* Add a way for net.Conn to override ServerVersion

* Resumption handshake, client and server

* Enable SSH resumption in teleport and tsh

* Disable resumption in a subtest of TestIntegrations/Disconnection

* Add back the removed tests

* minor refactor of runClientResumable

* Disable resumption for a different subtest

* Add an option to disable SSH connection resumption in Connect (#36712)

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
Co-authored-by: Grzegorz Zdunek <gzdunek@users.noreply.github.com>
2024-01-19 21:30:22 +00:00
Reed Loden d14548746c Update FIPS algorithms inline with upstream x/crypto/ssh proposed changes (#36685)
`x/crypto/ssh` is adding a `fipsonly` mode (similar to `crypto/tls/fipsonly`) in
golang/go#64769. Once this has landed and been released, we'll swap to using it.
In the meantime, update our hardcoded algorithm set to match the algorithms listed
in https://go-review.googlesource.com/c/crypto/+/550515.

The only difference is that `aes192-ctr` is kept in `FIPSCiphers`, as it seems to be
approved by NIST SP 800-131A rev 2 (page 17).

Additionally, we now define a list of approved public key authentication algorithms for
SSH server connections. This isn't configurable for normal use case (yet), only handled
for FIPS builds.
2024-01-15 17:36:35 +00:00
Reed Loden 95aa537f68 Increase minimum password length and account lock interval (#36389)
* Increase `MinPasswordLength` from 6 to 12 characters
  - PCI DSS v4.0 control 8.3.6 requires a minimum password length of 12 characters.
  - NIST SP 800-63B section 5.1.1.1 requires a minimum password length of 8 characters.

* Increase `AccountLockInterval` from 20 to 30 minutes
  - PCI DSS v4.0 control 8.3.4 requires a minimum lockout duration of 30 minutes.

This will contribute to better supporting customers to meet certain compliance requirements.

Ref #1936.
Ref #7687.
2024-01-10 04:11:28 +00:00
rosstimothy d81a4d95c6 Remove support for the deprecated SSH tracing channel and request (#36357) 2024-01-09 23:18:15 +00:00
Forrest cbbb7aad24 handle all direct-tcpip requests via single child per connection (#35148)
* handle all direct-tcpip requests via single child per connection

* implement uds helpers and rework forwarding
2023-12-19 03:35:36 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
Edoardo Spadolini 731b9bf52b Avoid using deadlines in ObeyIdleTimeout (#35006)
* Avoid using deadlines in ObeyIdleTimeout

* wrap the error on Close

* add test and fix a bug

* switch to just including a clockwork.Timer
2023-11-29 11:36:42 +00:00
fheinecke 83b6062220 Fixed additional license format issues (#34726) 2023-11-17 21:14:08 +00:00
Zac Bergquist f8c5164bbb Fix incorrect permissions for X11 Unix socket (#34613)
We were passing decimal 1777 instead of octal.

Closes #24819
2023-11-15 14:27:09 +00:00
rosstimothy d5a796c056 Enable testify lint (#34222)
Updates our golangci-lint configuration to enable testifylint and
fixes all issues found.

Bump e ref to include gravitational/teleport.e#2567
2023-11-06 20:38:38 +00:00
Edoardo Spadolini 21d86a9fcf Special case the subsystems handled by teleport exec (#34089)
* Special case the subsystems handled by teleport exec

This only applies to sftp, and lets us do a real reexec where that's
possible (i.e. launching /proc/self/exe on Linux), making sftp work even
if Teleport has been replaced by some wrapper or has been deleted.

* Delete leftover comment

* Update godoc for ExecCommand.Command
2023-11-02 08:50:09 +00:00
rosstimothy 24ebac905b Track user connections across clusters (#32688)
Ensure that `proxy_ssh_sessions_total` is incremented in both the
root and the leaf cluster if a session to a node in the leaf cluster
is established through the root cluster. This now also prevents
leaf clusters from terminating during a graceful shutdown if there
is an active connection that was created from the root.

Fixes #32605.
2023-10-04 15:35:11 +00:00
Andrew Burke cf3bf183b9 Drain unused SSH channels (#32505)
This change drains unused SSH channels and requests to prevent a
situation where an attacker could repeatedly open channels and
send data that won't be read, causing Teleport to eventually run
out of memory.
2023-09-27 17:05:48 +00:00
rosstimothy 22f28130ab Prevent zombie sessions being left behind for web sessions (#32141)
The ssh session was not being closed for web sessions which resulted
in zombie sessions being left around until the ssh service was
restarted. TestTerminal was updated to assert that the session
tracker eventually transitions to the terminated state when the
client terminates the web socket.

Fixes #32120
2023-09-20 13:45:55 +00:00
Anton Miniailoandrosstimothy b6bf8120c2 Make SSH node listener to use multiplexer to leverage parsing of signed PROXY headers (#30380)
* Make SSH node listener to use multiplexer to leverage parsing of signed PROXY headers

Before for backward compatibility reason we used regular listener and later
we wrapped connection into handler that could parse signed PROXY header or
proxyHelloSignature for getting correct user IP. But
after removal of proxyHelloSignature we don't need the wrapper anymore.

* Improve error message

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-08-26 03:47:10 +00:00
Alan Parra 0c964aab05 chore: Bump gravitational/trace to v1.3.0 (#30064)
* chore: Bump gravitational/trace to v1.3.0

* Replace `trace.IsEOF` with `errors.Is`

* Fix IsPermanentEmitError
2023-08-04 21:39:24 +00:00
Mike Jensen b90e362e7b Fuzz Test Improvements (#29918)
* Added Fuzz Seeds for services/fuzz_test.go

* Fuzzing improvements for `lib/srv/db` fuzzing

This ensures that all fuzzing under `lib/srv/db` has the following:
* Good seeds that provide basic levels of coverage
* Enabled in OSS-Fuzz

* Fuzzing improvements for `lib/sshutils`

This improves the fuzzing in `lib/sshutils/sftp/parse_test.go` and `lib/sshutils/x11/display_test.go`.
Seeds were added and additional local fuzzing was done.  In addition these functions are now enabled in `oss-fuzz`.
2023-08-02 18:55:55 +00:00
Alan Parra 5aac6d8bc5 Listen on "localhost" for tests (#29732)
* Listen on "localhost" for tests

Avoids popups on macOS.

* Revert changes on webclient_test.go

* Partially revert sshserver_test.go
2023-08-01 13:51:34 +00:00
Anton Miniailo 05e9d0499e Remove usage of TELEPORT_CLIENT_ADDR env var (#29751) 2023-07-29 18:25:40 +00:00