100 Commits
Author SHA1 Message Date
Andrew LeFevre d664e77758 mask setuid/setgid/sticky bits when transferring files via SFTP (#67784)
* mask setuid/setgid/sticky bits when transferring files via SFTP

* use correct ordering when creating hardlinks and symlinks
2026-08-05 20:13:41 +00:00
Andrew LeFevre 458469d859 set supplemental groups and reject symlinks when reading .tsh/environment file (#67779)
* set supplemental groups and reject symlinks when reading .tsh/environment file

* moved safefile out of internal
2026-08-05 19:12:27 +00:00
Andrew LeFevre 4f19256298 support disk events on Linux kernel 7.0+ by conditionally hooking do_file_open (#67650)
* support disk events on Linux kernel 7.0+ by conditionally hooking do_file_open

* default to do_file_open
2026-06-24 18:07:01 +00:00
Andrew LeFevre 51c87fff76 cleanup ebpf resources when bpf.New returns with an error (#67567) 2026-06-10 21:27:36 +00:00
Andrew LeFevre 9f9f7a639d expose error when PAM fails to write to stream (#67570) 2026-06-09 13:05:54 +00:00
Andrew LeFevre 6f11a4a57f handle allowed bpf events in SSH access permit consistently (#66919)
* handle allowed bpf events in SSH access permit consistently

* log error if closing the session fails

* fix tests failing

* add regression test
2026-06-05 21:45:35 +00:00
Andrew LeFevreandErik Tate 6dacb41989 check arguments for NULL in converse PAM converse func, trim trailing newlines in user input (#67481)
* check arguments for NULL in converse PAM converse func, trim trailing newlines in user input

* Update session/pam/pam.c

Co-authored-by: Erik Tate <[email protected]>

---------

Co-authored-by: Erik Tate <[email protected]>
2026-06-05 21:36:12 +00:00
Andrew LeFevre 2a0d84e69f multiple small fixes around PAM error handling and cleanup (#67278)
* ensure PAM retval is always valid when calling pam_end, prevent deadlock in PAM.free()

* don't call PAM.free in PAM.codeToError, require explicit cleanup to avoid confusion

* unregister handler if Open fails

* always return an error from codeToError
2026-06-05 21:16:29 +00:00
Andrew LeFevre f62ceb241c return an error when an absolute path isn't specified in a moderated upload, or if the path is a dir (#67346)
* return an error when an absolute path isn't specified in a moderated upload, or if the path is a dir

* don't show the filename to moderators

* revert change to comment
2026-06-05 18:54:34 +00:00
Andrew LeFevre ce12c7736f handle failing to load PAM getenvlist symbol correctly (#67477) 2026-06-04 18:24:30 +00:00
Andrew LeFevre 1228255afd ensure the expected ebpf hook will handle command events (#66914)
* ensure the expected ebpf hook will handle command events

* added comments to inflight_exec_t fields

* add comments to disk counterpart

* rename valid fields to valid_unsent

* add space in comment
2026-06-04 15:04:02 +00:00
Andrew LeFevre ffc5de690d surface error when arguments were not able to be read in ebpf command events (#66929)
* handle empty truncated arguments correctly in ebpf command events

* explicitly add message to audit event when args could not be read

* address codex comment

* zero structs from ringbuffer

* set failed to read args boolean in exit_execve
2026-06-03 18:41:53 +00:00
Andrew LeFevreandAndrew LeFevre 7e0e6c9794 Fix unreadable Enhanced Session Recording events (#64581)
* refactor command and disk eBPF programs to fix some events not getting emitted

* fixed handling of flags in disk events

* remove unused constants to appease linter

* handle failing to read filename in enter_execve correctly

* added more tests

* prevent potential panic if args_len exceed args buffer size

* handle empty args in command events correctly

* minor changes from feedback

* update comments in eBPF files

---------

Co-authored-by: Andrew LeFevre <[email protected]>
2026-05-04 12:25:25 +00:00
Andrew LeFevre 0a0f33b303 unset XAUTHORITY env var for the networking command (#65713)
* unset XAUTHORITY env var for the networking command

When Teleport passes almost all the environment variables to the child
processes that are born of a reexec. This is an issue when XAUTHORITY is
set as it will be passed to the networking process, causing `xauth` to
use a different file than the one that the SSH session process will use.
This is because the SSH session process only inherits a small subset of
the environment variables from the parent process, and XAUTHORITY is not
one of them. This causes X11 forwarding to fail.

* add Remove method to SafeEnv
2026-04-22 18:49:35 +00:00
Andrew LeFevre cee8aba4cb update SSH SELinux module to work with cilium/ebpf (#65049)
Also ensure the specified Teleport binary has the proper context
restored when using the SELinux module install script.
2026-04-14 20:44:49 +00:00
Andrew LeFevre 9eab44a7e4 Improve Enhanced Session Recording flakiness (#64583)
* ensure all bpf events are processed before stopping, refactor tests a bit to make the stress test much more consistent

* prevent startSession/endSession blocking during shutdown

* make lost event tracking in tests work correctly between sub-tests

* Remove accidental extra wg.Wait call

* simplify LostEventTracker

* improved log message and switched to use a time.Timer

* fix not building without bpf tag

* drop events if the buffer is full
2026-04-14 15:29:57 +00:00
Andrew LeFevreandAndrew LeFevre 2078c88da9 Fix logs from reexecuted processes not being logged in tests (#64038)
* ensure logs for reexec processes are shown when running unit tests

* log audit session login IDs as strings

---------

Co-authored-by: Andrew LeFevre <[email protected]>
2026-03-25 09:31:26 +00:00
Andrew LeFevre 7ec6d03b52 use the audit login session ID to track sessions when using Enhanced Sesssion Recording (#63050) 2026-02-19 18:20:18 +00:00
Andrew LeFevreandjoerger 6fb284b786 expose logs of Teleport child processes (#61297)
* expose logs of Teleport child processes

Configures Teleport child proceses to log with the exact same
configuration as the parent process. Logs from child processes
previously were essentially discarded.

* Fix issues around os_log; Fix log spam from child process.

* Address comments; Fix lint.

* * Only write remote command failure errors to client tty

* Don't try to write errors to unserviced os.Stderr/Stdout of child process

* Don't connect networking stderr to parent process, just use logger

* Don't log client-responsible shell errors, e.g. shell interrupt

* Mention running teleport as root for common subprocess permission errors.

* Pass io.Discard pipe to child process if a log writer is not available.

* Fix tests with nil log writer.

* Add default child logger for tests.

* Fix lint.

* default to discard writer for tests.

* Write reexec errors to os.Stdout for parent process to digest.

* Address comments.

* Clean up child pipe copy logic.

* Cleanup log config inheritance.

* Address comments.

* Revert whitespace change.

* Fix typo.

* Fix merge conflict.

---------

Co-authored-by: joerger <[email protected]>
2025-12-09 20:27:31 +00:00
Andrew LeFevre 8f5de088ed use a map of strings to empty structs instead of bools for ESR configured events map (#61523) 2025-11-19 14:59:35 +00:00
Andrew LeFevre 3e8e3caf59 only monitor the types of events configured in role options when Enhanced Session Recording is enabled (#61450) 2025-11-19 03:05:22 +00:00
Andrew LeFevre 8e41e5da36 add bpf integration tests (#61408) 2025-11-17 20:24:28 +00:00
Andrew LeFevre d46bec8af0 fixed bpf-bytecode make target exiting with error when not called (#61240) 2025-11-11 20:39:40 +00:00
7a7f08cb39 Replace aquasecurity/libbpfgo with cilium/ebpf (#60541)
* start the refactor away from aquasecurity/libbpfgo to use cilium/ebpf

Remove debug statements and unused code in BPF library

This commit eliminates unnecessary debug log statements from bpf_test.go and removes unused code in disk.go and network.go files within BPF library. The aim is to make codebase cleaner, enhancing readability and maintainability without losing track of functional aspects. It's part of an ongoing effort to maintain optimal code quality across the project.

Revise Dockerfile and Makefile instructions

Adjusted Dockerfile and Makefile commands to optimize build process. The changes ensure better readability and maintainability of code, especially with respect to BPF bytecode and test preparations. A clause was also added to check for the presence of clang before building BPF bytecode.

Refactor BPF code and tests

Refactored BPF source code and its corresponding tests for better readability and efficiency. This includes updating data structures like rawExecEvent, rawOpenEvent, rawConn4Event and rawConn6Event to their more meritorious versions like commandDataT, diskDataT, networkIpv4DataT and networkIpv6DataT respectively. Also, generated concise and clear bindigs for eBPF programs to replace the previous multi-arch setup. Furthermore, correspondingly adapted all related test cases arising in bpf_test.go, command.go and other files.

Remove counter_test from BPF and related test code

This commit removes the file counter_test.bpf.c from the enhanced recording in BPF. Following this file deletion, corresponding test functions in bpf_test.go, that were originally testing the functionality provided by counter_test.bpf.c, have been removed as well.

Refactor BPF test and improve error handling

The commit refactors the BPF test suite to run each test as a sub-test by using t.Run, easing debugging and error tracing. It also simplifies the 'executeCommand' function by removing redundant function calls related to finding executable files, and improves error handling. In 'cgroup.go', the code has been adjusted to retry on EBUSY errors when removing a cgroup, instead of ignoring them.

Update cgroup deletion process and error handling

The changes made introduce a retry mechanism when deleting a cgroup in case the cgroup is busy. This prevents a failed attempt from immediately returning an error. Additionally, error handling has been improved in the 'writePids' function to better handle 'no such process' errors.

Enhance cgroup monitoring in disk.bpf.c

The code has been updated to check if current cgroup is being monitored in the "enter_open" method of "disk.bpf.c". If the cgroup is not marked for monitoring, it will be ignored, enhancing overall cgroup management.

Improve resource handling

This commit introduces a deferred close to the sendEvents function to ensure proper resource handling of the eventBuf object.

Add rlimit package to remove resource limits

Introduced the "github.com/cilium/ebpf/rlimit" package and added a function to remove resource limits for kernels less than 5.11. This operation is necessary for kernels with a lower version because they may face issues when running applications with allocated memory limitations.

Fix a test after rebase

Refactor BPF testing setup and implement session closing

This commit updates the BPF testing structure to remove the context dependency in event generation functions, simplifying the test setup. Additionally, it adds a 'closed' field to the 'open', 'conn', and 'exec' structs alongside mutex protection. This implementation allows checking if a session is closed before any operations, correctly handling already closed sessions. Furthermore, it corrects tracepoints for handling 'openat' and 'openat2' system calls for different platforms. This refactoring effort aims to improve the robustness and readability of the BPF testing suite.

Update conditions for BPF bytecode building

This update modifies the Makefile to add a conditional check for the presence of /usr/include/bpf/bpf_helpers.h. This new requirement must be met along with the existence of /usr/include/linux/bpf.h and the installation of Clang, in order to facilitate the correct build of BPF bytecode. Consequently, this change enhances the reliability of the build process.

Add conditional for bpf_helpers.h in Makefile

This commit adds an additional check in the Makefile for the existence of /usr/include/bpf/bpf_helpers.h. This ensures that BPF bytecode only gets built when both bpf.h and bpf_helpers.h exist, and Clang is installed, improving the build process reliability.

Refactor and improve BPF bytecode generation

This commit refactors and improves the BPF bytecode generation process. It introduces distinct bytecode structures for different architectures, ensuring better compatibility and execution. The BPF test is adjusted due to its tendency to fail unpredictably, hence it's commented out to avoid unnecessary build failures. This commit also eliminates certain redundancies in `common.mk`, improving the clarity of the build process.

Comment out test code in bpf_test.go

The test code in the file bpf_test.go has been commented out. These changes are circumstantial and do not imply that the test code is obsolete or unnecessary. The use of such tests may be needed in future commits or for local development testing and debugging.

Remove libbpf dependency from Vagrantfile and update README

The Vagrantfile and README have been updated to remove the no longer needed libbpf dependency. This change simplifies the project set up by eliminating unused build steps in the Vagrantfile and correcting related instructions in the README. This results in a more streamlined, intuitive build process and reduced potential for code complexity and dependency conflicts.

Remove obsolete dependencies and related code blocks

The 'aquasecurity/libbpfgo' library referencing and the related code blocks have been removed from the test files and core modules. The corresponding setup instructions in the dockerfiles and build scripts have also been eliminated. This update simplifies the build process and overall project structure while reducing unnecessary dependency risks.

Remove aquasecurity/libbpfgo dependency

Remove restricted.bpf.c

Migrate disk events to cilium

Migrate network events to cilium

Remove restricted session

Use cilium/ebpf for BPF

* fix build issues caused by stale branch

Also updated bpf bytecode, updated github.com/cilium/ebpf to 0.19.0,
and updated bpf/README to reflect changes

* fix tests and a bit of cleanup

Also added a subtest and fixed receiving IPv6 network events and
fixed attempting to create tracepoints for syscalls that are not
present on arm64.

* repurpose buffer size configs to set event channel buffer size

* add new GHA job to check that generated eBPF files are up to date

* fix lost event promethus counters and address feedback

* address feedback

* use only unsafe instead of CGO to convert C strings

* rename common_data_t comm -> command

* convert strings in bpf programs from char arrays to u8 or uint8 arrays so we can convert them to Go strings without the use of the unsafe package

---------

Co-authored-by: Jakub Nyckowski <[email protected]>
Co-authored-by: Tim Ross <[email protected]>
2025-11-11 15:33:32 +00:00
Andrew LeFevre ca4ee9bad6 add libbpf-dev to buildbox (#60978) 2025-11-04 01:40:55 +00:00
Andrew LeFevre 4f1444f9ee fix starting an SFTP server when under SELinux enforcement (#59405) 2025-10-02 19:10:36 +00:00
Andrew LeFevre c27ca5c2e1 fix teleport-update labeling itself when installing SELinux SSH module (#57659)
* fix teleport-update labeling itself when installing SELinux SSH module

* always set SELinux env var when reexec'ing

* skip extracting selinux install script
2025-09-18 14:47:41 +00:00
Andrew LeFevre 6044e0459a fix panic when running 'teleport backend clone' on non-Linux platforms (#58240) 2025-08-25 23:13:19 +00:00
Andrew LeFevre e7eedce4d3 RFD for official SELinux module for SSH agents (#52529) 2025-08-08 01:06:22 +00:00
Andrew LeFevre c6010eb0db allow teleport-update to configure Teleport SSH SELinux module (#54108)
* allow teleport-update to configure Teleport SSH SELinux module

* fix setting selinux env var
2025-07-23 16:43:22 +00:00
Andrew LeFevre e4a9bcbae7 SELinux improvements (#55487)
Ensure that Teleport is running under the correct
SELinux context when --enable-selinux is passed,
set the SELinux exec label later so the
checkhomedir child process will inherit the
parent's SELinux domain.
2025-06-18 14:01:10 +00:00
Andrew LeFevre fc9f47fc5d fixes a broken link in the SELinux docs (#55674)
Looks like Red Hat dumbed down their SELinux content for newer Red Hat versions for some reason, this useful page is only available for RHEL 7 docs
2025-06-12 17:30:21 +00:00
Andrew LeFevre 802bc4af55 add documentation for SSH SELinux module (#55256) 2025-06-11 23:02:05 +00:00
Andrew LeFevre bcb9a19ee2 label calling binary's path for SELinux (#55307) 2025-06-05 17:25:56 +00:00
Andrew LeFevre bb9bcca12c make session ID env vars agree (#53652) 2025-05-29 17:36:05 +00:00
Andrew LeFevre fbb6a71dee add SELinux test cases to test plan (#55180) 2025-05-28 12:12:05 +00:00
Andrew LeFevre c21fda1ad3 add SELinux install script to release tarball (#55128) 2025-05-27 23:42:31 +00:00
Andrew LeFevre 6bf6aa60e6 add SELinux module for SSH service (#53424) 2025-05-13 20:54:51 +00:00
Andrew LeFevreandErik Jankovic 822e941c1f [buddy] Make sure (*Struct).Fields map is not nil before assignment (#53035)
* fix: make sure Fields map is not nil

* move new test to existing file, allocate map for struct up front

* make linter happy

---------

Co-authored-by: Erik Jankovic <[email protected]>
2025-03-13 17:30:48 +00:00
Andrew LeFevre eecd072cc0 verify cluster name of TLS peer certificates (#52128) 2025-02-13 21:25:52 +00:00
Andrew LeFevre 8d0bcc1302 fix app access regression when the app is on a leaf cluster (#47778)
* only redirect to the public addr of an app when an app redirect is required

* rename local variable from 'host' to 'addr'

* rename param
2024-11-01 23:43:10 +00:00
Andrew LeFevre 1589413a56 emit an audit event with file transfer statistics when an SFTP session is completed (#48051)
* emit an audit event with file transfer statistics when an SFTP session is completed

* remove unused SFTP event codes, don't embed os.File

* send oneof events to parent process to make event unmarshaling easier to reason about

* protect tracked files with mutex
2024-10-30 18:52:20 +00:00
Andrew LeFevre 6614832058 enforce a smaller read limit on HTTP request reads for endpoints that create or update resources (#47416) 2024-10-10 17:31:13 +00:00
Andrew LeFevreandAndrew LeFevre df91f1a3e7 Require all audit events to be able to be trimmed (#45931)
* ensure 'db.session.result', 'desktop.recording' and 'static_host_user.*' events can be converted from EventFields

* add TrimToMaxSize methods for all audit events and make it a required method

* ensure callers of TrimToMaxSize check the size of the returned event

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-09-10 20:16:10 +00:00
3c2887192d add the kind in a resource YAML example for the SSO client redirect docs (#45568)
* add the kind in a resource YAML example for the SSO client redirect docs

* Update docs/pages/admin-guides/access-controls/sso.mdx

Co-authored-by: Zac Bergquist <[email protected]>

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
Co-authored-by: Zac Bergquist <[email protected]>
2024-08-29 17:12:41 +00:00
Andrew LeFevreandAndrew LeFevre ac9658cb6c don't allow empty database names or user names for Postgres connections (#45178)
* don't allow empty database names or user names for Postgres connections

* adopt postgres behavior when the database name is empty

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-08-15 18:23:58 +00:00
bc95391ba8 fix regression that denied access to launch some Apps (#45024)
* fix regression that denied access to launch some Apps

* Fix test, and wrap new URL with its own try catch block

* improve URL parsing fail error message

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
Co-authored-by: Lisa Kim <[email protected]>
2024-08-06 15:37:49 +00:00
Andrew LeFevreandAndrew LeFevre 55268d12bc fix some events not getting converted to AuditEvents correctly (#44632)
* fix some events not getting converted to AuditEvents correctly

* test converting events

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-08-05 12:05:38 +00:00
Andrew LeFevreandAndrew LeFevre 555264fc79 hide the flag that allows users to pass their own Okta SCIM auth token to tctl (#44474)
Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-08-05 11:44:08 +00:00
Andrew LeFevreandAndrew LeFevre bca2943dca add option to allow client redirects from IPs in specified CIDR ranges in SSO client logins (#44556)
Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-07-30 21:02:57 +00:00
7edc922bd9 fix X-Forwarded-For HTTP header not getting passed in app access requests (#44579)
* fix X-Forwarded-For HTTP header not getting passed in app access requests

* Use `XForwardedFor` constant

Co-authored-by: Zac Bergquist <[email protected]>

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
Co-authored-by: Zac Bergquist <[email protected]>
2024-07-24 18:02:51 +00:00
Andrew LeFevreandAndrew LeFevre 12e1179bcc add audit events for integration actions (#43767)
Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-07-15 23:45:27 +00:00
Andrew LeFevreandAndrew LeFevre e22c004f5d check that an FQDN belongs to a known app before redirecting to it (#43525)
Fixes https://github.com/gravitational/teleport-private/issues/1492, updates https://github.com/gravitational/teleport-private/issues/1418.

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-07-13 01:24:48 +00:00
Andrew LeFevreandAndrew LeFevre 2d2123e7b6 add discovery config events to the web UI (#43797)
Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-07-11 14:33:06 +00:00
Andrew LeFevreandAndrew LeFevre 629f2d347f added audit events for discovery config actions (#43750)
Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-07-03 12:41:22 +00:00
Andrew LeFevreandAndrew LeFevre 54a9e79968 audit when the MFA for admin actions requirement is changed (#43245)
Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-06-26 13:25:48 +00:00
Andrew LeFevreandAndrew LeFevre b97c865995 use httputil Rewrite instead of Director (#42800)
* use httputil Rewrite instead of Director

Director will remove HTTP headers if they are
deemed to be hop-by-hop headers which could result
in a security vulnerability. Use httputil Rewrite
instead to ensure that HTTP headers added by our
reverse proxy are not unintentionally removed.

* ensure removed forwarded headers are added back

* use a separate request object in TestHeaderRewriter

---------

Co-authored-by: Andrew LeFevre <Andrew LeFevre>
2024-06-21 16:42:57 +00:00
Andrew LeFevreandPaul Gottschling ff401d518c add a note in the docs about an SSRF between root and leaf Proxies and how to prevent it (#41932)
* add a note in the docs about an SSRF between root and leaf Proxies and how to prevent it

* Update docs/pages/management/admin/trustedclusters.mdx

Co-authored-by: Paul Gottschling <[email protected]>

---------

Co-authored-by: Paul Gottschling <[email protected]>
2024-06-06 17:49:51 +00:00
Andrew LeFevre 5806d3324c prevent session id reuse (#42123)
* prevent SSH session id reuse

If a user sets `TELEPORT_SESSION` to a session ID
that isn't running, the sent session ID is ignored
and a new one is used to prevent the user
controlling the value. When parsing a session ID
the parsed result is used to ensure all session
IDs will have the same format.
`CreateSessionTracker` is updated to create
instead of upsert to ensure `SessionTracker`
resources cannot be overwritten by accident.

Clients often need to know the current session ID,
and before when they were in control of it that
wasn't an issue. To fix this servers will send the
current session ID in a SSH channel request on the
channel the SSH session was created on. This
should be fully backwards compatible, as when an
unknown SSH request type is received clients will
just ignore it/reply with false.

* add test for wrappedSSHConn
2024-05-29 14:01:15 +00:00
Andrew LeFevre 120efb9bd7 ensure kube watcher writes and flushes are sequential (#41584)
* ensure kube watcher writes and flushes are sequential

* rename to flushLocked
2024-05-15 17:03:49 +00:00
Andrew LeFevre cdb227b59c add the new/changed SAML connector to create and update audit events (#40062) 2024-05-02 17:51:05 +00:00
Andrew LeFevre 06b15b28fb add lock target to lock deletion audit events (#40057) 2024-04-30 22:56:49 +00:00
Andrew LeFevre ebeee68e75 allow attaching to pods in kube integration tests (#40971) 2024-04-27 00:07:32 +00:00
Andrew LeFevre d4c706a471 fix kube ephemeral container test flakiness (#40871) 2024-04-25 03:55:42 +00:00
Andrew LeFevreandTiago Silva ebee592033 fix k8s moderated sessions bypass with ephemeral containers (#40792)
* rebase with master

* only retrieve logs on a specific error

* fix cache test again and a linter issue

* only look for ephemeral container name when waiting for the container to start

* address feedback

* add support for other merge strategies

* handle case

* reorganize gomod

* address feedback

* fix missing patchtype

* propagate errors

* Update lib/kube/proxy/sess.go

Co-authored-by: Tiago Silva <[email protected]>

* add hint of exec process into session tracker

* address feedback

* optionally filter listed waiting conts server-side

* add TODO to test against tsh kubectl

* Revert "optionally filter listed waiting conts server-side"

This reverts commit 9a33868363e427f52bba8d95ead2bfc0d939e6e7.

* fix failing integration test, undo accidental dep update

---------

Co-authored-by: Tiago Silva <[email protected]>
2024-04-23 16:55:56 +00:00
Andrew LeFevre 9a8e92aa1a always require MFA when joining a session if at least one role requires session MFA (#39602)
* extend role 'join_sessions' so MFA can be required at the role level when joining sessions

* add test cases

* update operator CRDs

* remove change to 'join_sessions', instead require MFA if any roles require it

* add comment

* address feedback

* add additional test cases

* add authhandler test

* fix role from test case not getting used in test
2024-03-23 00:09:18 +00:00
Andrew LeFevre ca51fb4700 fix a few bugs with kube waiting container backend (#39690) 2024-03-21 17:42:53 +00:00
Andrew LeFevre 2143f5ba64 add kubernetes waiting container backend service and API (#39317)
* add kubernetes waiting container backend service and API

* remove other resource type

* add unit test

* fix after rebasing

* address feedback

* remove KubeWaitingContainerRequest

* check for nil in validation func

* remove UnwrapResource153

* fix test

* address feedback

* address linter issues

* fix cache watch kind test
2024-03-20 16:03:39 +00:00
Andrew LeFevre 5eaae8b200 ignore SSH keepalive requests in SFTP moderated sessions integration test (#39436)
* ignore SSH keepalive requests in SFTP moderated sessions integration test

* fix misspelling
2024-03-16 00:19:03 +00:00
Andrew LeFevre e551bde5da add protobuf definitions for kubernetes waiting container messages (#39316) 2024-03-14 17:46:42 +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
Andrew LeFevre 79583f754b emit audit events when SFTP or SCP commands are blocked (#36977)
* emit audit events when SFTP or SCP commands are blocked

* include user name in SCP web audit message

* use 'an' instead of 'a'

* make SCP audit message use consistent language, fix type check error

* fix unused var
2024-01-27 00:10:02 +00:00
Andrew LeFevre b1a2444061 fix useless type assertion in session recorder test (#33267) 2023-10-11 14:59:42 +00:00
Andrew LeFevreandZac Bergquist bbd6701e22 Report exit code of rsync processes if they fail in TestWithRsync (#33175)
* report exit code of rsync processes if they fail

* use correct 't' when asserting

* Update tool/tsh/common/proxy_test.go

Co-authored-by: Zac Bergquist <[email protected]>

---------

Co-authored-by: Zac Bergquist <[email protected]>
2023-10-10 17:34:03 +00:00
Andrew LeFevreandrosstimothy 31ac8ee746 fix leaf SSH sessions not getting recorded (#32163)
* fix leaf SSH sessions not getting recorded

* add integration test

* address feedback, overhaul integration test

* make each test case use fresh clusters to fix failing case

* address feedback

* Apply suggestions from code review

Co-authored-by: rosstimothy <[email protected]>

* fix integration test failures

---------

Co-authored-by: rosstimothy <[email protected]>
2023-10-06 12:54:57 +00:00
Andrew LeFevreandPaul Gottschling 492e3b36d0 re-add agentless node manual installation docs (#31647)
* re-add agentless node manual installation docs

* fix linter issues

* Add missing closing paren

Co-authored-by: Paul Gottschling <[email protected]>

* use tabs in manual install guide

* removed more ScopedBlocks I missed

* add note about upgrading to v14

* add redirect and notes linking the two guides to one another

* addressed feedback

* Apply suggestions from code review

Co-authored-by: Paul Gottschling <[email protected]>

* fix links

---------

Co-authored-by: Paul Gottschling <[email protected]>
2023-09-28 23:00:29 +00:00
Andrew LeFevre 61bce3e3ec document OIDC connector 'max_age' field (#31800)
* document OIDC connector 'max_age' field

* addressed feedback

* address feedback
2023-09-14 14:53:31 +00:00
Andrew LeFevre 5054cb685c return an error when attempting to join a session of an OpenSSH node (#31472)
* return an error when attempting to join a session of an OpenSSH node

* remove item from test plan and note to docs

* add test coverage to integration test

* fix integration test

* fixed linter issue
2023-09-08 22:16:02 +00:00
Andrew LeFevre a89e2eebcb add tsh slow on Windows entry to FAQ (#29546) 2023-08-21 22:05:31 +00:00
Andrew LeFevre b029928a11 fix forwarding a SSH agent in a Cygwin environment (#29068)
* fix forwarding a SSH agent in a Cygwin env

* added more comments

* use os.Getenv

* add examples to regex vars, make formatting of guid more clear

* parse strings as uints, improve error messages

* make it more clear uint32s are used for UIDs

* turns out calling "bash" isn't needed
2023-08-16 20:38:30 +00:00
Andrew LeFevre 929a8bba84 add option to force re-authentication for OIDC connectors (#29815)
* add option to force re-authentication for OIDC connectors

* expose max_age directly

* update comment for MaxAge, regen operator manifests to make linter happy

* make max_age nullable

* make max_age a duration

* use google.protobuf.Duration

* Revert "use google.protobuf.Duration"

This reverts commit e6c3b7deaf9ffebb33492e3b6e575289e3ad1c37.

* make it more clear that max age is a full duration

* document how MaxAge duration is represented

* rebuild operator manifests
2023-08-09 21:52:41 +00:00
Andrew LeFevre 2e6973470b crdgen: handle OIDCConnectorSpecV3.MaxAge as a special case (#29916)
* crdgen: handle OIDCConnectorSpecV3.MaxAge as a special case

* move logic into separate function

* update testdata

* removed unnecessary files from testdata

* update testdata after merging master
2023-08-09 20:40:36 +00:00
Andrew LeFevre 1ca745ca0e allow the default editor role to create nodes (#29763) 2023-08-01 16:32:26 +00:00
Andrew LeFevre c399d8ac9d use correct session recording mode in session start and end events (#29584) 2023-07-26 15:14:18 +00:00
Andrew LeFevre ea3d933294 wait longer for auth preference to get updated in rsync test (#29529) 2023-07-25 14:23:16 +00:00
Andrew LeFevre 5adceac922 add rsync integration test (#28493)
* add rsync integration test

* wip mock headless auth with re-exec

* fix headless sub-test

* fix broken Alias tests

* poll for updated auth preference instead of sleeping
2023-07-20 22:15:42 +00:00
Andrew LeFevre 1e1937e9dc update e ref (#29018) 2023-07-12 18:56:55 +00:00
Andrew LeFevre 473214eb45 remove changes that temporarily kept e builds working (#28979) 2023-07-11 21:43:39 +00:00
Andrew LeFevre d4b3afe9a1 split recording session events and emitting audit events (#27873)
* split recording session events and emitting audit events

This is a refactor of how audit events and session events are handled.
Previously, all events were emitted using the same interface,
api/types/events.Emitter. This lead to event-related code getting to be
very confusing, as it was often unclear whether a given event was being
recorded as a session event and emitted as an audit event, or only one
of the two. Naturally, a few bugs arose due to this.

To simplify event handling, a separate interface for recording session
events has been created. A api/types/events.Recorder should now only be
used to record session events, and an Emitter should now only be used to
emit audit events. Instead of using a confusing TeeWriter that would
transparently (and confusingly, given its name) hold a few event types
that only belonged in session recordings, callers can now explicitly
record and/or emit an event when necessary.

* ensure e build won't break
2023-07-11 19:53:33 +00:00
Andrew LeFevre 7c556ff796 add rsync to buildbox (#28503) 2023-06-30 14:25:28 +00:00
Andrew LeFevre e02b6f6575 update agentless docs to use 'teleport join openssh' (#26925)
* update agentless docs to use 'teleport join openssh'

* addressed feedback

* addressed feedback
2023-06-08 13:08:07 +00:00
Andrew LeFevre 3243fa6e7d fix GitHub connector API endpoint URL path getting ignored when making HTTP requests (#24830) 2023-05-23 23:00:50 +00:00
Andrew LeFevre 1e6a684843 return an error if a moderated session is created for an agentless node (#25561) 2023-05-05 16:40:56 +00:00
Andrew LeFevre 35b837de87 use "google.golang.org/protobuf" to clone protobuf messages (#25466)
"github.com/gogo/protobuf/proto.Clone" has multiple bugs that cause
panics, so create a wrapper function that uses a thoroughly tested
cloning function from "google.golang.org/protobuf".
2023-05-04 21:22:01 +00:00
Andrew LeFevre 68feffbf82 fix connecting to agentless leaf nodes (#25206)
* fix connecting to agentless leaf nodes

Pass user and role information to Auth server signing OpenSSH cert
so avoid user/role lookup errors if the target node is on a leaf
cluster. Also use role and trait information from the current
connection rather than the backend to support role impersonation.

* make protobuf changes backwards-compatible
2023-05-02 17:39:47 +00:00
Andrew LeFevre 506f537bbe fix file copy check not happening for agentless SSH connections (#25012) 2023-04-28 19:16:06 +00:00
Andrew LeFevre e343989f52 fix session recordings from Web UI to agentless nodes having name set as node UUID (#25109) 2023-04-25 13:22:48 +00:00
Andrew LeFevre 00bb19661e ensure forwarded SSH agent is always closed (#24947)
Previously when handling an SSH agent forward request from a SSH
connection to a registered SSH node, the forwarding SSH server would
open a SSH channel for the SSH agent but never close it. tsh wasn't
affected by this and would exit cleanly when the SSH session was closed.
OpenSSH ssh would hang waiting for the open SSH agent channel to close,
which would never happen.
2023-04-21 22:58:20 +00:00
Andrew LeFevre 3cf48120af don't rely on info in SSH user cert when connecting to agentless nodes (#24935)
After finding now 2 very similar bugs today related to trying to pull
connection information out of SSH certificates instead of just passing
it directly, opt to pass the information directly to prevent future bugs.
2023-04-21 13:44:17 +00:00
Andrew LeFevre 4160f8e438 use correct certificate extension when getting cluster of agentless node (#24909)
lib/utils.CertTeleportClusterName is set by the SSH user key auth
handlers, so it should always be set.
2023-04-20 19:22:48 +00:00