Commit Graph
25 Commits
Author SHA1 Message Date
Zac Bergquist 2ae9d770fc Refactor tctl's dependencies (#22693)
* Move configuration from lib/service to lib/service/servicecfg

The new servicecfg package will hold only configuration for services.
This will allow other packages (like tctl and tsh) to depend on
servicecfg without pulling in all of lib/service (which has a number
of platform-specific details).

This is the first step towards being able to build tctl for Windows.

* Move PAM and BPF config into servicecfg

This breaks a compile-time dependency on BPF/PAM for tctl.
2023-03-09 17:48:36 +00:00
Vitor Enes c96809399a Add server_hostname to session.* events (#18812)
With this commit, `session.*` events now also contain a `server_hostname` field.

Example:

```json
{
  "argv": null,
  "cgroup_id": 6926,
  "cluster_name": "vitor.teleport.sh",
  "code": "T4000I",
  "ei": 17,
  "event": "session.command",
  "login": "root",
  "namespace": "default",
  "path": "/usr/bin/date",
  "pid": 98679,
  "ppid": 98668,
  "program": "date",
  "return_code": 0,
  "server_hostname": "ip-172-31-10-157",
  "server_id": "8369d1d1-eea5-4074-8f64-0103f1e1fb00",
  "sid": "a40353c4-93dc-4d6b-a481-5546ecafb83e",
  "time": "2022-11-28T16:32:34.342Z",
  "uid": "cbd9e562-8932-405d-974c-11637f91d711",
  "user": "vitor@goteleport.com"
}
```
2022-11-28 20:28:41 +00:00
Jakub Nyckowski 506e0db534 Enable network BPF modules only when needed. (#18497) 2022-11-25 18:33:40 +00:00
Jakub NyckowskiandAlan Parra bea2e89df5 Run GCI as make fix-imports (#17956)
Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2022-11-04 15:46:46 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Jakub Nyckowski 716c2bdbf9 Fix BPF (#17269)
* Revert "Refactor bpf/restrictedsession usage in lib/srv (#15824)"

This reverts commit 769951fe4b.

* Remove unused Linux BPF includes

* Fix linter issue
2022-10-12 18:41:26 +00:00
Brian Joerger 4c0a6ff5b1 tsh PIV login integration (#15335)
* Add Yubikey PrivateKey implementation for use by Teleport clients.

  - Add yubikey login logic, reusing previously stored private keys.

  - Fix identity file decoding with PIV keys, which sign ecdsa certificates.

  - Add libpcsclite-dev pre-req for building on linux.

  - Remove unnecessary keys.Signer interface and move its functionality to keys.PrivateKey.

  - Move retry and jitter utils to new api/utils/retryutils package.
2022-09-23 19:44:10 +00:00
rosstimothy 769951fe4b Refactor bpf/restrictedsession usage in lib/srv (#15824)
Invert the relationship of `lib/srv` and `lib/bpf`,
`lib/restrictedsession` such that `lib/bpf` is only imported in
`lib/srv/regular`. Since not everything is built with the `bpf`
tag it's important to reduce the surface area of `lib/bpf` such
that it isn't inadvertantly imported. For instance it was entirely
possible to import a package in `tsh` that transitively
depends on `lib/bpf` - which breaks the build since `tsh` is not
compiled with the `bpf` tag.

By refactoring the `srv.Server` interface not to use the `bpf.BPF`
and `restrictedsession.Manager` interfaces directly anything that
imports `lib/srv` now won't require that `-tags=bpf` is set in
order to compile.
2022-09-07 14:49:28 +00:00
Russell Jones 7842f8b569 Fix. 2022-08-18 15:22:10 -07:00
Russell Jones c3c2ca2c96 Fix. 2022-08-18 15:22:10 -07:00
Russell Jones 4fa6d5acdd Refactor tests under bpf tests
Refactored all tests under "lib/bpf" and "lib/restrictedsession" to use
testify instead of gocheck.
2022-08-18 15:22:10 -07:00
Jakub Nyckowski c380f86bd9 Enable BPF tests in CI (#10933) 2022-07-15 00:16:56 +00:00
Norbert SzeteiandZac Bergquist 0ab9716aac oss fuzz integration (#13473)
* Update api/types/fuzz_test.go
* do not fail if the file is missing
* missing go-118-fuzz-build fix

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-06-18 21:28:07 +00:00
Eugene YakubovichandJakub Nyckowski 4de14faa13 Bump to libbpfgo v0.2.5 (#12288)
Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
2022-06-08 05:00:01 +00:00
740e626943 restricted shell: check that LSM BPF is enabled (#10677)
* restricted shell: check that LSM BPF is enabled

Checks that /sys/kernel/security/lsm contains "bpf"
before starting restricted shell. Aborts with error
if the entry is not found.

* Update lib/restrictedsession/restricted.go

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* Remove unused import

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-05-17 01:03:27 +00:00
Zac Bergquist 3b0127f00b Move MockEmitter to eventstestpackage 2022-03-29 12:12:01 -06:00
Zac Bergquist 55cbd0ac97 Remove use of deprecated ioutil package (#11296)
* Remove use of deprecated ioutil package
* Add lint rule to check for ioutil imports
2022-03-21 18:00:34 +00:00
Jakub Nyckowski 6930ee9b98 Disable BPF tests in CI (#10654)
Run BPF tests only if TELEPORT_BPF_TEST environment variable is set. This should prevent on running those tests on machines that doesn't support BPF.
2022-02-28 18:14:38 +00:00
JoelandZac Bergquist 62173e096b use google/uuid instead of pborman/uuid (#9793)
* replace imports

* use google/uuid

* fix test

* reverse changelog changes

* update gomod

* zac steps

* tidy

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-01-19 23:44:48 +00:00
rosstimothy ab857001de Add jitter and backoff to prevent thundering herd on auth (#9133)
Move cache and resourceWatcher watchers from a 10s retry to a jittered backoff retry up to ~1min. Replace the
reconnectToAuthService interval with a retry to add jitter and backoff there as well for when a node restarts due to
changes introduced in #8102.

Fixes #6889.
2021-12-16 11:41:08 -05:00
Zac Bergquist 0bae0d255f Cleanup lint targets
- Don't assume an explicit $GOPATH is set
- Remove golint from linters - it's been deprecated for over a year
  and golangci-lint prints a warning instead of running it.
2021-10-19 09:21:55 -06:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Russell Jones 628e96aa61 Updated BPF asset embedding.
Updated how BPF assets are embedded. Missing object files will now be a
runtime error instead of a build time error. However, this will allow
teleport/lib to used as a module because tools like "go mod vendor" were
failing when attempting to vendor teleport/lib due to the missing object
files.

Added bytecode directory with README.md so "go:embed" does not complain
about missing assets. This allow developers to checkout Teleport and
work on it without needing libbpf or any other BPF tooling.
2021-07-28 17:16:14 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Eugene Yakubovich 67c0eb3b4c Add restricted session
Adds the ability to block network traffic on SSH sessions.
The deny/allow lists of IPs are specified in teleport.yaml file.
Supports both IPv4 and IPv6 communication.

This feature currently relies on enhanced recording for
cgroup management so that needs to be enabled as well.

-- Design rationale:
This patch uses Linux Security Module (LSM) hooks, specifically
security_socket_connect and security_socket_sendmsg, to control
egress traffic. The LSM provides two advantages over socket filtering
program types.
- It's executed early enough that the task information is available.
  This makes it easy to report PID, COMM, etc.
- It becomes a model for extending restrictions beyond networking.

The set of enforced cgroups is stored in a BPF hash map and the
deny/allow lists are stored in BPF trie maps. An IP address is
first checked against the allow list. If found, it's checked for
an override in the deny list. The policy is default deny. However,
the absence of the NetworkRestrictions API object is allow all.

IPv4 addresses are additionally registered in IPv6 trie (as mapped)
to account for dual stacks. However it is unclear if this is sufficient
as 4-to-6 transition methods utilize a multitude of translation and
tunneling methods.
2021-07-16 16:49:04 -07:00