Commit Graph
793 Commits
Author SHA1 Message Date
Marco André Dinis a60d1c0f43 Download mTLS files from Web (#14526)
In the context of Teleport Discover we are trying to ease the usage of Teleport for the user's first interaction.

When adding a new database resource the user must, among other things, generate the mTLS files
Examples:
https://goteleport.com/docs/database-access/guides/postgres-self-hosted/#step-25-create-a-certificatekey-pair
https://goteleport.com/docs/database-access/guides/mysql-self-hosted/#step-24-create-a-certificatekey-pair

This PR aims to reduce this friction: the user should be able to setup the resource without prior setup of local tools (`tsh login`)
We're doing this by providing an endpoint that will return those exact files


Demo
```shell
marco@lenix ~/p/downloadmtls> curl --silent --insecure 'https://127.0.0.1.nip.io:3080/v1/webapi/sites/lenix/sign' --dat
a '{"hostname":"discover.example.com", "ttl":"9999h", "format": "db"}' --header 'Authorization: Bearer 308bf3dd3019ddc4
2cff44a48e028480' --header 'Content-Type: application/json' -OJ
marco@lenix ~/p/downloadmtls> tar -xvf teleport_mTLS_discover.example.com.tar.gz
server.key
server.crt
server.cas
marco@lenix ~/p/downloadmtls> head -1 server.*
==> server.cas <==
-----BEGIN CERTIFICATE-----

==> server.crt <==
-----BEGIN CERTIFICATE-----

==> server.key <==
-----BEGIN RSA PRIVATE KEY-----
```

Fixes https://github.com/gravitational/teleport/issues/14049
2022-08-01 10:14:18 +01:00
Marco André Dinis 89f4d5476a Create and List Connection Diagnostics (#14781)
In Teleport Discover, we want to improve the UX of adding a resource.
We'll suggest users to test accessing a resource, and give them immediate feedback using the UI.

Note: we'll add this feature to Server Access, later one we'll add other resources.

After adding a server resource, the user will be presented with a command to test the connection:
`tsh ssh --test-id=123 user@host`

Running that command will provide the user feedback right in the UI of whether or not it worked.
If not, a short message will be displayed describing why it didn't work and how the user can solve the problem.

---

To achieve this we'll need a couple of changes:
1. new resource that stores the result of trying to connect to a given resource, so that the UI can ask for it
2. change `tsh ssh` to receive the `--test-id` flag and write the result to a record of this new resource

This PR addresses 1 - new resource.

A new resource is created:
```
Connection Diagnostics
- success (bool)
- message (string)
```

Two new rpc methods:
- create connection diagnostics
- read connection diagnostics

One new HTTP Endpoint:
- read connection diagnostics

Related to
https://github.com/gravitational/teleport/issues/13957
2022-08-01 08:49:35 +01:00
Joel b7a319d40d Correctly propagate information about the target during forwarding (#14564) 2022-07-28 11:05:45 +00:00
rosstimothy 9b22af6a5e SSH request tracing (#14124)
* SSH request tracing

Add tracing support for ssh global requests and  channels. Wrappers
for `ssh.Client`, `ssh.Channel`, and `ssh.NewChannel` provide a
mechanism for tracing context to be propagated via a `context.Context`.

In order to maintain backwards compatibility the ssh.Client wrapper
tries to open a TracingChannel when constructed. Any servers that
don't support tracing will reject the unknown channel. The client
will only provide tracing context to servers which do NOT reject
the TracingChannel request.

In order to include pass tracing context along all ssh payloads
are wrapped in an Envelope that includes the original payload
AND any tracing context. Servers now try to unmarshal all payloads
into said Envelope when processing messages. If there is an Envelope
provided, a new span will be created and the original payload will
be pass along to handlers.

Part of #12241
2022-07-27 14:56:06 +00:00
Bernard Kim 26e3df82b5 Display license out of compliance warnings (#14114) 2022-07-26 19:31:50 -07:00
Roman Tkachenko 38b8bb4307 Add support for proxying TCP apps (#13455)
Add support for proxying tcp apps
2022-07-26 19:01:39 +00:00
STeve (Xin) Huang 2da838fca1 Support AWS external id (#14086) 2022-07-26 14:47:12 +00:00
Nic Klaassen c063a186e1 Add tsh request drop command (#14766) 2022-07-25 15:42:59 +00:00
Andrew LeFevre 395a42f8c0 Add error messages to SFTP audit events (#14767)
add error messages to SFTP audit events
2022-07-22 20:06:35 +00:00
NajiObeid 8a3e682181 new license fields (#14279)
* new license fields

* remove monthly active users field from license
2022-07-21 15:40:45 +00:00
Krzysztof Skrzętnicki 26a442dfbf Better error message on ping parse error. (#14700) 2022-07-20 20:11:53 +00:00
Marco André DinisandIsaiah Becker-Mayer 9fa5705ed1 Remove update verb requirement when creating Tokens (#14506)
The used method to create a token in the UI is UpsertToken.
This method requires Create and Update verbs.

It shouldn't be necessary to have the Update verb - we are only creating
and not changing anything.

This PR adds
- a new method - CreateToken - which only requires the Create verb.
- apiserver uses this method to issue a new token

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
2022-07-19 07:24:09 +00:00
MatheusandRafał Cieślak b787b9579f Add UpgradeWindowStartUpdate audit event (#14433)
* Added event UpgradeWindowsUpdate

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2022-07-14 20:24:10 +00:00
Noah Stride 02b4f8575f Configure linter to catch British 🇬🇧 spellings 🇺🇸 🦅 📖 (#14363)
* configure golangci-lint misspell to check for anglicized spellings

* Americanize spellings

* fix aws constant value with british spelling 🇬🇧

* update api types with americanized spellings

* use american spellings .cloudbuild/scripts
2022-07-14 10:51:23 +00:00
Marco André Dinis af2d9c56ea WebAPI: return user traits (#14138)
* WebAPI: read user

We currently need to fetch the whole list of users to get User's
information.
Adding more fields increases the probabilty of having performance
issues.

This PR adds a new endpoint which returns a single user.
This endpoint returns the information we already return when listing
users but also returns the user's traits

This is a follow up of
https://github.com/gravitational/teleport/pull/14076

The following traits are returned:
- Logins
- DB Users
- DB Names
- Kube Users
- Kube Groups
- Windows Logins
- AWS Role ARNs
2022-07-13 10:06:34 +00:00
Aaron Friel fe66bc8637 Fix panic on equality, add symmetric equality tests (#13588) 2022-07-13 00:07:08 +00:00
Gus Luxton 51b3bc3dda tsh: Also create a PuTTY PPK-formatted keypair on login (#12733)
PuTTY uses its own keypair format which has the extension .ppk on Windows, hence PPK.
The specification for the file format is here: https://the.earth.li/\~sgtatham/putty/0.76/htmldoc/AppendixC.html\#ppk
2022-07-11 23:31:06 +00:00
rosstimothy ad1d9b1aae Prevent forwarding traces to servers which don't support tracing (#14281)
* Prevent forwarding traces to servers which don't support tracing

Tracing clients can detect if a server doesn't support tracing by
checking for a trace.NotImplented error in response to an
UploadTraces request. Since the grpc.Conn used by the client is
likely to be bound to that server for the duration of its life
it doesn't make sense to keep trying to forward traces. Instead
the client now remembers that a server doesn't support tracing
and will drop any spans.

Part of #12241
2022-07-11 21:09:32 +00:00
STeve (Xin) Huang 13abca6638 Optimize tsh db ls performance (#14092) 2022-07-09 20:22:47 +00:00
Jakub NyckowskiandRafał Cieślak c3dde989cc Update protoc to v3.20.1 (#14097)
Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2022-07-07 23:21:32 +00:00
Andrew LeFevre a150b0c8e1 SFTP server side support (#13491)
add sftp server functionality
2022-07-07 20:08:26 +00:00
Marco André Dinis 24cb3e3124 WebAPI: update user traits (#14076)
* WebAPI: update user traits

Web API only supports updating the roles property for a given User.

This PR adds the possibility of updating User's traits
- Logins
- DB Users
- DB Names
- Kube Users
- Kube Groups
- Windows Logins
- AWS Role ARNs

It only updates if the requests contains a non-nil value for the trait's
list.
It deduplicates the trait's list before applying it.
2022-07-06 15:55:45 +01:00
Marek Smoliński d19e9af21f Fix SQLServer procname -> proc_name json tag (#14095) 2022-07-06 11:31:34 +02:00
Edoardo Spadolini f3ceca0278 Push CAs after establishing watchers in remoteSite. (#13895)
Update CAs on connection in remoteSite
2022-06-30 21:25:54 +02:00
Reed Loden 83eb9b2acb Bump go.mod to use Go 1.18 (#13771)
We're now using Go 1.18 features (native fuzzing in https://github.com/gravitational/teleport/pull/13473),
which means we need to accurately state that we require Go 1.18 in our go.mod.
2022-06-29 02:14:12 +00:00
Forrest Marshall cb712e3f0b add peer addr substitution to control-stream hb 2022-06-28 12:22:33 -07:00
Zac Bergquist 0a60853399 Check error when generating tokens with the API client (#13932)
Fixes #13925
2022-06-28 15:59:59 +00:00
Tim Buckley 70a73355c9 Properly handle empty list of role requests (#13456)
* Properly handle empty list of role requests

Currently, an empty list of role requests results in an ambiguous
situation: we usually use the presence of role requests to determine
whether or not we'd return impersonated certs or not. An empty list
of role requests returns a fresh set of non-impersonated certs
(possibly renewed if allowed), while a non-empty list of role requests
returns certs with just those roles.  However, if a client _intends_
to request impersonated certs but provides an empty list of role
requests it will instead receive non-impersonated (possibly renewable)
certs with the full permissions of the original user.

This could theoretically result in privilege escalation if a Machine
ID bot: (a) had any worthwhile permissions of its own, which is not
the case unless the bot role was manually modified and (b)
accidentally handed certs off to an attacker.

In practice this bug is fairly difficult to hit: `tbot` always
auto-fills all requestable roles if they are otherwise unset, and
`tctl bots add` requires `--roles=` to be passed. An empty string
here can trigger the bug however it is unlikely a user would pass this
by accident. Moreover, a bot without requestable roles cannot
accomplish much of anything, so this is exceedingly unlikely to
be intended behavior.

Additionally, certificate generation checks help to mitigate the
issue: bots currently lock themselves by accident after the first
renewal when this bug is triggered as they don't explicitly handle
receiving renewable certs when impersonated certs are expected. If an
attacker were to attempt a renewal, the generation counter would
similarly limit access, and as noted previously, the bot role grants
only minimal read-only access anyway.

---

To resolve the issue, this adds a new `RoleRequestsOnly` flag to
`UserCertsRequest` that allows clients to unambiguously specify if
they wish to receive a non-impersonated, possibly renewable, cert with
all the original user's roles and permissions, or if they wish to
receive only role-impersonated certs (or an error if roles are empty).
Machine ID passes this flag in all situations where an impersonated
cert is desired.

Additionally, we also now ensure users add at least one role in
`CreateBot()` (called by `tctl bots add`) as this is almost certainly
an unintended situation.

Fixes #13411

* Address review feedback, rename flag to UseRoleRequests

* Return a local error if no roles are specified
2022-06-27 16:25:12 +00:00
Brian Joerger 9a32c60171 Fix nil pointer exception when joining non-existent session (#13596) 2022-06-24 01:48:26 +00:00
Gavin Frazar 1858aafa15 Fix http proxy basic auth (#13140)
* Fix http proxy basic auth

* Update docs about HTTP CONNECT env var formats
2022-06-23 00:27:29 +00:00
c5ebb53d79 implements setting FIPS support on AWS S3 and DynamoDB (#13388)
use FIPS for AWS S3 and DynamoDB when --fips flag is passed
[#11291, #13222]
golint
reorder to allow explicit override

Update lib/events/dynamoevents/dynamoevents_test.go

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

review comments

review comments

review comments

Update lib/events/dynamoevents/dynamoevents.go

Co-authored-by: Roman Tkachenko <roman@goteleport.com>

move fips config to cluster audit config

review

address nits

Update lib/events/fips.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

review comments

review comments
2022-06-21 13:08:06 -04: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
Nic Klaassen f4eb28223e Check if resource request is possible before attempting (#13586) 2022-06-17 16:57:44 +00:00
Brian Joerger 2aae5b5899 Fix SSO AuthRequest backwards compatibility. (#13589) 2022-06-17 01:21:29 +00:00
Forrest Marshall 31f258fec9 inventory control stream & certs 2022-06-15 22:26:24 -07:00
Nic Klaassen 7f3944b2e5 Add MachineID and Resource Access Requests license features (#13392) 2022-06-15 17:58:50 -07:00
Roman Tkachenko 683d11d23e Update versions to 11 (#13528) 2022-06-15 23:28:08 +00:00
Joel ef9937a83e Add webapi routes for fetching session trackers (#13205) 2022-06-15 07:42:31 +00:00
ad171dfdc2 Check for unimplemented error during stream receive in Client.GetAccessRequests (#13459)
* test + fix

* Update api/client/client_test.go

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* fix error handling

* remove first check

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-06-14 19:33:16 +00:00
STeve (Xin) Huang 85016a9a3e MemoryDB support (#13069) 2022-06-14 19:09:31 +00:00
Brian Joerger b5472d41ec Convert GenerateToken to gRPC. (#9024) 2022-06-14 17:43:39 +00:00
Krzysztof Skrzętnicki 7f8a2e6e7b Adjust tctl sso commands to new teams_to_roles field. (#13463) 2022-06-14 10:10:27 +00:00
NajiObeid 430ac0e1e2 fix moderated sessions setter and getter (#13287)
* fix moderated sessions setter and getter

* fix godoc

* add tests

* address pr comments

* simplify test
2022-06-13 21:29:16 +00:00
Lisa Kim a61d38a1a7 Add de-duplicating apps, dbs, and desktops when sorting/totalCount is needed (#12685)
Fixes total count errors for the web UI:
- Adds de-duplicating matches for `FakePaginate` func. 
- This change does makes `FakePaginate` less efficient b/c 
  it will always run filter for every resource per fetch versus just 
  running it on the initial fetch to get the total count. 
- Removes inaccurate de-dupping in the web api layer since we 
  do it from the back now
- Adds another criteria when de-duplicating `applications` by checking 
  for its `public_addr` as well as its name.
2022-06-13 19:45:22 +00:00
Joel c083518645 Access request compatibility for servers without v2 api (#13373) 2022-06-13 18:11:04 +00:00
rosstimothy e5c745f331 Add manual tracing instrumentation to tsh (#13204)
Create spans for all public facing TeleportClient,
ProxyClient, and NodeClient methods. This makes
correlating spans easier to reason about when
looking at `tsh` traces. As a result of creating
spans, some additional context propagation is
required as well to ensure that spans are linked
properly.

This also removes the unused `quiet` argument from
`ConnectToCluster`. It's usage was not consistent
by existing callers, and it was ignored, so in order
to avoid confusion in future calls, it was removed.

#12241
2022-06-11 15:34:40 +00:00
Nic Klaassen 27a1f1c3d6 Prune roles for Resource Access Requests (#13323) 2022-06-10 16:50:55 +00:00
Alex McGrath 502b001130 Add sudoers provisioning support (#12061)
* Add sudoers provisioning support

* Add a fix for macos tests
2022-06-09 16:06:18 +00:00
Przemko Robakowski 951aff47ed IP-based validation for SSH (#13243)
This change adds IP-based validation for SSH certificates.
There's new option in role definition:

kind: role
metadata:
  name: dev
spec:
  options:
    pin_source_ip: true
When that is set to true client IP must be the same when generating certificates and using them. It uses source_address critical option that should be supported by both teleport and sshd and only applies to certificates we send to user (like in tsh login), we don't pin IP in certificates issued for web UI as they can't leak.
This change also omits machine ID (it uses different code path) - it will be added in separate PR.

Most of the lines changed are from regenerating types.proto, change itself is not that big

Relates #11719
2022-06-08 22:49:37 +00:00
2717c1d2e0 Security fixes (#13298)
* Add CSRF mitigations

This commit includes two fixes:

1. Enforce an application/json Content-Type server-side.
2. When checking the bearer token, verify that the user
   associated with the token matches the user associated
   with the cookie.

* Fix TEL-Q122-13: Access Requests Denial Of Service Via Request Reason (#125) (#127)

* Ignore input when data flow is off in TermManager

When data flow is disabled in TermManager (at the beginning or when TermManager.Off was called) we should ignore all input we receive (currently we buffer it)

* Agent forwarding socket security fix.

Co-authored-by: Lisa Kim <lisa@goteleport.com>
Co-authored-by: Joel <jwejdenstal@icloud.com>
Co-authored-by: Przemko Robakowski <przemko@przemko-robakowski.pl>
2022-06-08 18:12:45 +00:00