Commit Graph
64 Commits
Author SHA1 Message Date
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Alan Parra 5d077ed91d fix: Correctly handle non-registered U2F keys (#37710)
* Test non-registered U2F key failure

* fix: Correctly handle non-registered U2F keys

* Be resilient to open errors
2024-02-02 17:28:39 +00:00
Alan Parra 0f1a096692 Skip the RPID pre-flight check whenever possible (#37542) 2024-01-31 18:56:29 +00:00
Alan Parra 5f644b6c30 Use FIDO2 touch functions to wait for touch (#37203)
* Use FIDO2 touch functions to wait for touch

* nit: Initialize nonInteractiveError uniformly

* Change fido2TouchMaxWait to 200ms

* Log dev.TouchBegin() errors

* Apply various error-handling fixes
2024-01-31 18:06:03 +00:00
Alan Parra fc3e21bf93 feat!: Rewrite FIDO2 device interactions to be non-concurrent (#37181)
* Bump go-libfido2 to 399e6dce025f0fae1e47088e4912e113512240cb

bump

* Add the IsFIDO2 and Close functions to FIDODevice

* Rewrite FIDO2 device interactions as single-threaded

* test: Wait for device goroutines on tests

* test: Drop "metered" tests

* test: Adjust tests according to behavioral changes

* nit: Invert u2f flag to fido2

* Reintroduce Info retries

* nit: Update old comments

* Delete unused code

* test: Fix minor lint issues

* Set the libfido2 device timeout

* Appease linter

* Revert "test: Wait for device goroutines on tests"

This reverts commit 2f871273b5c508627f177a37f74660ab1cea1618.

* nit: Function declaration indent

* Document that openedDevices.devices doesn't change length after assigned

* Log the retry interval

* Bump go-libfido2 to v1.5.3-teleport.1
2024-01-30 17:00:43 +00:00
Brian Joerger 6e1955a67c Scoped WebAuthn: MFA extension flow (#36667)
* Use SessionData with extensions in Webauthn flow.

* Pass MFAChallengeExtensions through webauthn flow.

* Opportunistically enforce Webauthn challenge scope.

* Don't delete webauthn session data when reuse is allowed.

* Return more login data from webauthn flow.

* Enforce reuse when provided by the caller.

* Address comments.

* Fix test.

* Add unit test for scope and reuse.

* use pointer for challenge extension parameters.

* Address comments.
2024-01-20 00:07:50 +00:00
Brian JoergerandAlan Parra 00f37d4866 Scoped WebAuthn: Refactor SessionData (#36666)
* fix: Use random scopes on TestIdentityService_UpsertGlobalWebauthnSessionData_maxLimit

* Replace webauthn SessionData proto definition with an internal definition.

* Remove unused SessionData proto message.

* Address comments; Fix test.

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2024-01-19 21:21:45 +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
fheinecke 83b6062220 Fixed additional license format issues (#34726) 2023-11-17 21:14:08 +00:00
Paul Schisa 7135486f5c Update fido2.go (#34529) 2023-11-14 17:55:53 +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
Alan Parra 64832452c1 chore: Address crypto/elliptic package deprecations (#32806)
* chore: Address crypto/elliptic package deprecations

* Pre-allocate slices, drop needless `[:]`
2023-10-03 21:39:23 +00:00
Brian Joerger 1c88f9ed1b Move lib/utils/prompt to api/utils/prompt (#32334)
* Move /lib/utils/prompt to /api/utils/prompt.

* Replace uses of lib/utils/prompt with api/utils/prompt and delete pacakge.

* go mod tidy.
2023-09-25 19:31:37 +00:00
Joel b0eac11430 Remove dead KNNRetriever class (#31176)
* Remove dead KNNRetriever class

* go mod tidy

* add back some needed fns

* fmt

* nolint markings for now
2023-08-30 00:25:13 +00:00
Mike Jensen 94562cf023 Fuzz Test Improvements 3 (#30576)
* restrictedsession/fuzz_test.go: Add basic IP and CIDR seeds

* proxyline_test.go: Add fuzzing for Proxy Line v1

Adds a fuzzing test case and seeds for proxy line v1.
This commit also enables both fuzzing tests in oss-fuzz.

* client/fuzz_test.go: Add fuzz coverage and seeds

This adds some fuzzing coverage to some previously missing functions.
In addition seeds (primarily from unit test cases) were added to all fuzz test cases, and all cases were enabled in oss-fuzz.

* Add fuzzing for lib/auth/webauthncli.parseU2FRegistrationResponse

This adds fuzzing coverage and seeds for the function `parseU2FRegistrationResponse`.  This commit also enables this test in oss-fuzz.
2023-08-17 14:55:15 +00:00
Alan Parra b30d9c22c5 Remove lib/auth/webauthn dependency from webauthncli (#30377)
* Alias `api/types/webauthn` imports to `wanpb`

* Use `webauthnpb` as the default package name

* Move messages.go to webauthntypes/

* Move extensions.go to webauthntypes/

* Move proto.go to webauthntypes/

* nit: Use consistent license style

* Use the `wantypes` alias for webauthntypes

* Use the `wanwin` alias for webauthnwin

* nit: Move winwebauthn.go to webauthnwin.go

* Document package webauthntypes

* Alias types required by e/

* Appease linter

* Add all main types/method to compat.go

* Reinstate spaces on proxy_test.go

* Alias newly-added usages
2023-08-14 21:24:37 +00:00
Alan Parra 63698a93a9 Represent protocol within wanlib and update go-webauthn (#29750)
* Represent the entirety of protocol within lib/auth/webauthn

* Bump github.com/go-webauthn/webauthn to v0.6.2

* Fixes for v0.6.x: Challenge, RPOrigins

* Bump github.com/go-webauthn/webauthn to v0.7.2

* Document new v0.7.2 fields

* Bump github.com/go-webauthn/webauthn to v0.8.2

* Fixes for v0.8.x: UserEntity.ID

* Bump github.com/go-webauthn/webauthn to v0.8.6

* Let bots update go-webauthn

* Drop support for RP and User icon

* Update generated protos

* Add a brief godoc to cloned types
2023-08-02 17:09:57 +00:00
rosstimothy 119dc7a3a3 Reduce login latency (#28499)
Reuse the root cluster auth client during the login process
to reduce latency.

Closes #26712.
Partially addresses #26712.
2023-07-05 15:51:56 +00:00
Alan Parra 45cfe60624 Return a better message on "lacks registered credentials" errors (#26079) 2023-05-11 19:07:31 +00:00
Alan Parra b4e5d788c4 Record and verify WebAuthn RPIDs (#25238)
* Add the credential_rp_id field to WebauthnDevice

* Update generated protos

* Record credential RPID on registration and login

* React to unexpected RPIDs when issuing challenges

* Log number of allowed credentials

* Fix TestServer_CreateAuthenticateChallenge_authPreference

* Use slices.Delete

* Try to appease the flaky test detector
2023-04-27 18:58:21 +00:00
Nic Klaassen b0c1c3e8da feat: early feedback for successful security key taps (#21691)
This commit adds a user message ("Detected security key tap") that is
printed at the earliest opportunity after `tsh` succesfully detects a
security key tap.

This solves a problem users have when there is significant latency in
their connection to their teleport proxy, where there may be zero
visible feedback to the user for upwards of 8 seconds after they tap
their security key.
This often causes users to think that the tap was not detected or
failed, and they attempt to tap again.
This can cause the user to accidentally paste a "yubisneeze" into their
terminal, which is not great from a security perspective.

As an API choice here I added a `TouchAcknowledger` returned by they
`PromptTouch` of the `LoginPrompt` interface.
It may seem like a bit of a weird API, but I did it this way so that all
callers of `PromptTouch` are forced to explicitly acknowledge the touch
or explicitly ignore that return value, they cannot simply forget to ack.

This applies to WebAuthn and Passwordless logins from `tsh`, no changes
are made to Connect.
2023-02-13 23:23:38 +00:00
Tobiasz Heller 77e10d6ff0 Replace deprecated duo-labs/webauthn with go-webauthn/webauthn (#19476) 2022-12-19 18:07:30 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Alan Parra 48e6140d01 Improve FIDO2 UX with user-friendly errors (#17441)
Improves FIDO2 login/registration UX by letting users choose (almost) any
available key and then presenting a user-friendly error if the operation cannot
be done.

New devices are now polled for continuously, as we can't eagerly filter devices
anymore. All FIDO2 devices, regardless of their capabilities, are made to wait
for user interaction: once the user interacts with the device we either complete
the operation successfully or return a reason for failure.

U2F-only devices are still silently ignored, as before. They don't respond well
to FIDO2 APIs and proved to be unwieldy in practical tests. (Maybe we can tackle
those in a follow up.)

Examples of new UX:

```shell
# Attempting passwordless login on a non-capable device (lack of PIN)
$ tsh login --proxy=zarquon --user=ihaveitall --auth=passwordless
> Tap your security key
> ERROR: device not registered for passwordless

# Attempting passwordless registration on a non-capable device (lack of PIN)
$ tsh mfa add --type=WEBAUTHN --name=test --allow-passwordless
> Tap any *registered* security key
> Tap your *new* security key
> ERROR: device lacks PIN or user verification capabilities
```

Closes #15037.
2022-10-19 14:02:21 +00:00
Tobiasz Heller c8abfa0209 Windows Webauthn connect with webauthncli package 2022-10-14 09:59:24 +02:00
Alan Parra 1024949cee Fix tsh fido2 diag command (#17196)
Add the missing RelyingParty.Name field and tweak error messages.
2022-10-10 14:30:50 +00:00
Tobiasz Heller 239192c7bf Move webauthncli validation to common place (#16879)
Move webauthncli validation to common place.
Be a little bit more strict with validation.
2022-10-06 16:34:48 +00:00
Gavin Frazar ca959d0b5f fix tsh u2f debug spam (#17037)
* Suppress u2f debug error spam

* Ignore hid: not permitted as well
2022-10-05 22:31:29 +00:00
Alan Parra 53b3c93b4e fix: Handle failures when checking for excluded credentials (#16737)
U2F devices, like the Yubikey4, fail in a slightly unexpected way when
assertions set UP=false. Handle this edge case and also make sure that failures
when checking for excluded credentials won't break the entire ceremony.

Similar to #15975, but in the registration flow this time.

Repro steps:

1. Register a Yubikey 4
2. Attempt to register a different security key
3. Registration fails with a "user presence required" error
2022-09-27 16:41:24 +00:00
Alan Parra 8b387b4c2b Update duo-labs/webauthn to 20220815211337 and use new APIs (#16724)
Update duo-labs/webauthn to latest and adapt/make use of new APIs.

Relevant commits:
- ResidentKey: https://github.com/duo-labs/webauthn/commit/048000f85ea880227b7d76ff2c0e4a0b89994cb2
- Discoverable login (aka passwordless): https://github.com/duo-labs/webauthn/commit/09bc59f7770df2eb03b0d11f990481d92c1b61e3

* Update duo-labs/webauthn to `20220815211337`
* Use the new ResidentKey field
* Use the new passwordless APIs
* Record AppID TODOs for posteriority
2022-09-26 21:28:48 +00:00
Alan Parra d3fd9342c1 Add a timeout for device cancels (#16575)
U2F devices, like Yubikey 4, don't seem to respect cancels, locking the program
if a different security key is chosen.

There isn't a clean way to cancel when Cancel() doesn't work, so I've added a
timeout to let the program complete. It's OK for the timeout to be short, it's
not tied to user interaction and by the time we get to it all cancels were
already issued.
2022-09-22 22:04:11 +00:00
Tobiasz Heller 314b7a853e Add retries on operation denied in fido2 (#15947)
* Add retries on operation denied in fido2
* Improve error message on fido2 device blocked (#15949)
2022-09-02 08:40:39 +02:00
Alan Parra b420aa8e74 Avoid wrongly filtering Yubikey4 devices (#15975)
Fixes an issue where libfido2 code wrongly interprets
`libfido2.ErrUserPresenceRequired` as `libfido2.ErrNoCredentials`.

Added some logging for good measure.

#14657

* Simulate Yubikey4 UP=false behavior
* Avoid wrongly filtering Yubikey4 devices
2022-08-31 14:49:17 +00:00
Alan Parra 2d66b86033 Add better handling for common libfido2 errors (#15323)
Improve the error message for libfido2 error 60 (UV blocked) and automatically
retry error 63 (UV invalid).

libfido2 error 63 happens with some frequency with Yubikey Bio. The biometric
sensor is a bit finicky, so if the finger is a bit off it tends to happen.

Fixes #13900.

* Simulate libfido2 errors 60 and 63
* Add better handling for common libfido2 errors
2022-08-10 18:53:56 +00:00
Lisa Kim 13cc52f70d Add passwordless login capability to Connect (#14759) 2022-08-05 17:11:28 +00:00
Alan Parra ca476c4861 Fix the behavior of tsh mfa add --allow-passwordless (#15013)
The `--allow-passwordless` flag was ignored when set, which makes tsh do
non-passwordless registrations. This causes all sorts of confusing behavior.

I'm taking the chance to also add some additional logging to webauthncli.

* Correctly use the value of --allow-passwordless
* Add additional logging to wancli
2022-08-02 19:30:45 +00:00
Alan Parra 67ed8eda6f Fix the device detection loop for U2F devices (#14760)
The FIDO1/2 device detection loop makes an incorrect [assumption about the
Info()][1] method, which breaks the loop for FIDO devices. That was in turn
compounded by a swallowed error, causing a rather confusing behavior.

We now correctly handle FIDO devices by assuming they have no FIDO2-like
capabilities and treat our errors more gracefully (or less silently).

Fixes #14657.

[1]: https://github.com/gravitational/go-libfido2/blob/45a8c53e4500d24b209a94b86dbc6cefeafaa649/fido2.go#L339

* Add a registration/login test for U2F devices
* Fix the device detection loop for U2F devices
2022-07-22 16:20:25 +00:00
Alan Parra f93e68e157 Implement the Touch ID credential picker (#14493)
Implement the Touch ID credential picker.

During passwordless authentication, when more than one login is present in
Enclave credentials, `tsh` now asks the end user to pick their desired login.
Credential picker terminal prompts are preceded by a system Touch ID prompt,
which is then reused for authentication, provided less than 10 seconds pass in
the meantime.

I've done a couple of refactors to make the `CredentialInfo` structs similar
between the `webauthncli` and `touchid` packages, so it's easier to trace
parallels between them.

#13901

* Refactor touchid.CredentialInfo
* Refactor wancli.CredentialInfo
* Move fido2_prompt*.go to prompt*.go
* Define the touchid credential picker API
* Add Touch ID credential picker tests
* Implement touchid credential picker
2022-07-19 14:31:00 +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
Alan Parra 77bde20fb7 Retry UV failures and correctly handle single accounts (#14198)
Address the following FIDO2 issues:

1. Retry assertions without UV if UV=true if the PIN is set
2. Correctly handle single account responses from authenticators

1 happens in the wild and the fix is confirmed. The fix is based in the fact
that the authenticator will set the UV bit in the resulting assertion when the
PIN is present, regardless of us asking for it. We do need the UV bit to clear
server-side validation, that haven't changed.

2 was a misunderstanding on my part; the spec doesn't require authenticators to
return user names for single account responses, which they effectively don't. In
practical terms we are unable to guarantee the `--user` flag for single account
scenarios, but not failing seems better than failing. See the
[authenticatorGetAssertion response][1], user member.

[1]: https://fidoalliance.org/specs/fido-v2.1-ps-20210615/fido-client-to-authenticator-protocol-v2.1-ps-20210615.html#authenticatorgetassertion-response-structure

* Add tests for UV failure and single account
* Correctly handle single account responses
* Retry without UV if a PIN is set
2022-07-11 16:00:24 +00:00
Alan Parra a22bbb0b4c Add missing newline to invalid user message (#14167)
Add newline missing from PR #14033.
2022-07-07 16:50:28 +00:00
Alan Parra e005f6060e Implement FIDO2 credential picker (#14033)
Add a credential picker to the tsh FIDO2/WebAuthn backend.

The PR pulls a recent patch in our go-libfido2 fork that makes it correctly
return multiple assertions from the authenticator. This allows us to implement
the credential picker for FIDO2, simplify our implementation and provide the
exact same UX that browsers use (always 1-touch for bio, touch->PIN->touch
otherwise).

I've dropped concepts like "optimistic assertions" and "eager PIN prompts" in
favor of a simple, uniform implementation.

Issue #13901.

* Prompt for credentials in LoginPrompt
* Update go-libfido2
* Implement FIDO2 credential picker
* Drop optimistic assertions, only set user if explicit
* Add license to fido2_prompt_test.go
2022-07-01 16:24:26 +00:00
Alan Parra be460541d1 Do not dereference assertion before checking for nil (#13761)
Fixes comment from #13712 on master.
2022-06-22 21:47:12 +00:00
Alan Parra f1fe4a6e24 Favor newer Touch ID credentials within the allowed set (#13672)
Favor newer Touch ID credentials in the allowed set for MFA, or just the newer
credential for passwordless.

Fixes a capture-by-reference bug and adds coverage for it.

Issue #13340.

* Add tests for Touch ID credential-choosing logic
* Favor newer Touch ID credentials within the allowed set
* Warn about origin vs RPID mismatch
2022-06-21 16:14:56 +00:00
Alan Parra 9ca045bacd Expand --mfa-mode and disable stdin hijack by default (#13134)
Avoid "input swallowing" bugs by disabling stdin hijacking by default.

Only `tsh login` is allowed to hijack stdin, as it is expected to exit right
after authentication. Any MFA authentication attempts resulting from
non-`tsh login` invocations default to the user's strongest auth method.

Defaulting to the strongest auth method can cause problems in constrained
environments for users that have both Webauthn and OTP registered. For example,
someone using `tsh` under WSL (Windows Subsystem for Linux) or a remote machine
could be locked into Webauthn MFA, which they can't use because their
environment lacks USB access or they don't have physical access to it. In order
to solve this problem I've slightly modified the meaning of the `--mfa-mode`
flag so `otp` can be specified.

The `TELEPORT_MFA_MODE` environment variable may be set to avoid constant flag
passing.

Fixes #12675 and #13021.

* Expand --mfa-mode and disable stdin hijack by default
* Use TELEPORT_ instead of TSH_ for FIDO2 env var
* Use t.Setenv in tests
2022-06-03 22:13:50 +00:00
Alan Parra 59fa9f0dae Drop validation and references to U2F Facets (#12892)
U2F facets don't serve a purpose since Webauthn became the de-facto MFA
mechanism. This should make it easier for users to write v10-style
authentication configs.

The remaining U2F fields are still relevant for when we derive Webauthn settings
from U2F, so those are kept (and validated).

Note that we still keep the fileconf field, since we don't want configs to
needlessly break during version upgrades.

#10375

* Remove references to U2F.Facets
* Remove Facets from U2F proto
* Reinstate proto Facets field

U2F gets marshaled as JSON to storage, so we better keep the field to
avoid issue with resource configs.

* Add deprecation notice on comment
* Update generated protos
2022-05-31 21:00:24 +00:00
Lisa Kim 833848594f Add passwordless option with user reset/invite (#11748)
* Allow register passwordless on invite/reset
* Specify the type of device usage when registering new device
* Minor refactoring to reduce number of parameters to funcs
* Check if device register requested pwdless, response is pwdless capable
2022-05-12 17:31:10 +00:00
Alan Parra 68392918ef Wire touch ID login and registration to tsh (#12475)
Add the --mfa-mode flag and wire touch ID into tsh authn/registration.

In the default MFA mode (auto), touch ID should be eager if there is a
credential present in the system. Users may change this behavior using other MFA
modes.

See https://github.com/gravitational/teleport/blob/master/rfd/0054-passwordless-macos.md.

#9160

* Add AuthenticatorAttachment/MFAMode to tsh
* Add support for touch ID in wancli.Login
* Warn users about passwordless in U2F mode
* Add support for touch ID in `tsh mfa add`
2022-05-09 14:44:28 +00:00
Alan Parra ba1a74c70d Fix race on TestFIDO2Login/NOK_cancel_after_PIN (#12238)
Fixes a rather exoteric race condition where a goroutine beats an
already-cancelled context in a select.

The select in question sits on selectDevice / fido2.go#L729. It is not an error
for the select to go either way, instead this is a failure of test setup. The
 fix is simple: we use authenticators that do have resident credentials for the
 test, so their Assertion operations block waiting for user interaction,
 eliminating the race in the test in question.

Example flaky execution:
https://console.cloud.google.com/cloud-build/builds/ceaa0674-db49-444b-b059-a17e01b0328f?project=ci-account

#9160
2022-04-26 21:14:52 +00:00
Alan Parra 058a262a6b Document FIDO2 support in ./lib/auth/webauthncli (#11955)
Document the different implementations, fallbacks, build tags, and provide some
install/use instructions.

#9160

* Document FIDO2 support in ./lib/auth/webauthncli
* Add license
2022-04-19 20:40:47 +00:00