rfd/0131-adminitrative-actions-mfa.md
Enforce MFA verification for administrative actions. For example:
This will apply to administrative actions performed from any Teleport client,
including tctl, tsh, the Teleport Web UI, and Teleport Connect.
Currently, Teleport only prompts for MFA verification in a few circumstances:
As a result, the vast majority of Teleport actions do not require timely MFA verification. If an admin's login session is compromised, it can be used to perform attacks pertaining to privilege escalation, security downgrades, Auth connector changes, and other forms of cluster sabotage.
Adding an MFA restriction to administrative actions limits this attack vector by re-verifying the user's identity promptly before performing any administrative action.
An administrative action will be defined as an action which creates, updates, or deletes an administrative teleport resource. For example:
tctl rm/create/edittctl users add/rm/resetThere are hundreds of actions which could qualify as administrative actions, but to restrict the scope of this feature, we will start with a "short" list of actions which modify the following administrative resources.
CreateUser, UpdateUser, UpsertUser, DeleteUserCreateRole, UpdateRole, UpsertRoleV2, UpsertRole, DeleteRoleCreateDevice, UpdateDevice, UpsertDevice, DeleteDevice, BulkCreateDevices, CreateDeviceEnrollToken, SyncInventoryCreateUserGroup, UpdateUserGroup, DeleteUserGroup, DeleteAllUserGroupsChangeUserAuthentication, StartAccountRecovery, VerifyAccountRecovery, CompleteAccountRecovery, CreateAccountRecoveryCodesSetClusterNetworkingConfig, ResetClusterNetworkingConfigSetSessionRecordingConfig, ResetSessionRecordingConfigSetAuthPreference, ResetAuthPreferenceSetNetworkRestrictions, DeleteNetworkRestrictionsUpsertOIDCConnector, DeleteOIDCConnector, CreateOIDCAuthRequestUpsertSAMLConnector, DeleteSAMLConnector, CreateSAMLAuthRequestUpsertGithubConnector, DeleteGithubConnector, CreateGithubAuthRequestCreateSAMLIdPServiceProvider, UpdateSAMLIdPServiceProvider, DeleteSAMLIdPServiceProvider, DeleteAllSAMLIdPServiceProvidersCreateAccessRequest, DeleteAccessRequest, SetAccessRequestState, SubmitAccessReviewUpsertAccessList, UpsertAccessListWithMembers, DeleteAccessList, AccessRequestPromoteUpsertAccessListMember, DeleteAccessListMember, DeleteAllAccessListMembersForAccessListCreateAccessListReview, DeleteAccessListReviewGetSuggestedAccessListsUpsertTokenV2, CreateTokenV2, GenerateToken, DeleteTokendeleteStaticTokens, setStaticTokensUpsertLoginRule, CreateLoginRule, DeleteLoginRuleUpsertCertAuthority, DeleteCertAuthorityrotateCertAuthority, rotateExternalCertAuthorityGenerateHostCerts, GenerateHostCertGenerateUserCertscreateWebSession, deleteWebSessionCreateBot, DeleteBotNote: http endpoints in the list above are noted separately due to the additional work associated with these endpoints.
Here are some notable exclusions from the list which may be future admin action candidates:
Here is a list of actions which are exempt from being admin actions now or in the future:
CreateAccessRequest, DeleteAccessRequestCreateAuthenticateChallengeChangePassword, CreateResetPasswordTokenAddMFADeviceSync, DeleteMFADeviceSyncDefaultImplicitRole:
SubmitUsageEventThis list is too long to thoroughly dig into all of the details and exceptions in this RFD alone. Instead, we will add MFA to the listed (and unlisted) admin actions one at a time, grouping similar endpoints into separate Github PRs.
Within each PR, we can ensure that every usage of that endpoint is updated in a
backwards compatible way across all Teleport clients (tsh, tctl, Teleport
Connect, Teleport Web UI, Plugins and plugin guides).
MFA for admin actions will required on any cluster where Webauthn is the
preferred MFA method. This includes clusters with cluster_auth_preference.second_factor
set to on, optional, or webauthn where cluster_auth_preference.webauthn
is also set.
Built-in roles will not require MFA to complete admin actions. For example:
Auth, Proxy, Node, and other service roles.Admin role used by tctl directly on an Auth server.Bot role used by MachineID to generate certificates.In order to support automated use cases such as the Teleport Terraform Provider or Access Request Plugins, we need to provide a way for non-interactive identities to bypass MFA for admin actions.
First, we will narrow the scope of what constitutes a non-interactive identity.
A non-interactive identity is a set of certificates generated with impersonation
by either the Bot or Admin built in role, which is done with MachineID or
tctl auth sign on the Auth server respectively.
If an API client's certificates have the impersonator extension set to a
user with the Bot or Admin role, then MFA will not be attempted nor
required for admin actions.
Impersonated certificates generated by a user will still require MFA for admin actions. We currently use this type of impersonation for our API and plugin guides, so each of these guides will need to be updated to use MachineID.
MFA verification will be required to carry out various administrative actions. This will be enforced by the Auth API Server for the specific endpoints which are considered administrative actions.
Each Admin Action API request will follow this flow:
rpc CreateAuthenticateChallenge.MFAAuthenticateResponse to the Auth Server as part of the
API request.MFAAuthenticateResponse in the Auth Server to
authorize the request (in addition to normal identity-based authorization).Steps 1-3 are already possible with Teleport currently and used for various MFA features. Steps 4 and 5 will require some changes to the Auth API client and server respectively.
For admin actions, the Auth server will validate MFA for each request using the
MFAAuthenticateResponse passed in the request metadata.
If the request fails MFA verification, an access denied error will be returned to the client.
// ErrAPIMFARequired is returned by AccessChecker when an API request
// requires an MFA check.
var ErrAdminActionMFARequired = trace.AccessDenied("administrative action requires MFA")
There are a few different ways that the Auth client can pass MFA verification with the Auth server, each with their own pros and cons:
MFAAuthenticateResponse argument to each administrative API endpoint.The Auth server can consume/verify the challenge response in each request and treat the request as MFA verified.
Pros:
GenerateUserSingleUseCerts, login endpoints, etc.).Cons:
MFAAuthenticateResponse
message is included in the proto specification. In order to maintain backwards
compatibility, each request that we change to an admin action will take a full
major version before we can actually require MFA for that action.MFAAuthenticateResponse as client request metadata.This approach is similar to passing a bearer-token in HTTP requests. Note that it will augment the normal certificate auth flow, not replace it. Additionally, the MFA Challenge Response will be passed to the server within the context of the TLS handshake, so it is secure.
The client can uniformly pass the MFAAuthenticateResponse with the gRPC client call
option PerRPCCredentials. The Auth server can then grab the MFAAuthenticateResponse
from the request metadata, consume/verify the challenge response, and treat the request
as MFA verified. POC.
Pros:
GenerateUserSingleUseCerts could be replaced by simply checking for
MFA verification in the request metadata of GenerateUserCerts.Cons:
This approach is similar to Per-session MFA. The client will need to issue a
GenerateUserSingleUseCerts request to get MFA verified TLS certificates before
making an administrative request.
Pros:
Cons:
Option 1 and 2 both guarantee that a user's MFA verification applies to just one admin action in the fewest number of API requests, solidifying it as a preferable solution over option 3 for both security and implementation complexity.
Between option 1 and 2, option 1 is more explicit and simple in how and where MFA will be required. This would make the feature easier to use for both internal and external developers. However, it requires significant API changes and has some backwards compatibility drawbacks.
We will implement option 2 for its simplicity and limited drawbacks. This will allow us to quickly implement the feature and apply it to all relevant admin actions in Teleport 14.
In the future, we can consider coming back to implement option 1, as they are not mutually exclusive.
tsh clientsCurrently tsh is the only client with universal MFA prompt logic. We will
need to implement similar logic in tctl, the Web UI, and Teleport Connect.
tctl can reuse the same logic used in tsh, making it the easiest change.
However, we will also need to start creating a signed tctl.app in order to
support Touch ID in tctl.
For the Web UI and Teleport Connect, MFA prompt logic is handled on a case by case basis. We will develop reusable logic and modals for these Apps to prompt for MFA when necessary.
Before making an admin action request, Teleport clients can check the server's
cluster_auth_preference.second_factor settings with a ping request. If MFA is
required for the set second_factor, the client will first make a
CreateAuthenticateChallenge request, solve the returned challenge, and attach
it to the admin action request.
If a user has no MFA device registered, CreateAuthenticateChallenge will fail.
In this case, the client will make the request without the MFA challenge response,
in case we are handling a special case (e.g. Built-in role, Bot or Admin
impersonation).
Additionally, if the client doesn't know whether a request requires MFA or not,
it will first attempt the request without it. If the server responds with
ErrAdminActionMFARequired, the client will attempt to retry the request with
MFA.
Since the MFA verification will be passed through the gRPC metadata, there are no proto changes required.
Some requests which we would like to make admin actions are still used through
the HTTP API rather than the gRPC API, such as POST UpsertUser. Part of this
work will require converting these requests to gRPC, which will also move us
closer to fully deprecating the HTTP API.
The UX of this feature will be very similar to Per-session MFA for tsh, tctl,
and the WebUI, and Teleport Connect.
When a user performs an admin action, they will be prompted to tap their MFA key. Each admin action will require a single unique tap or OTP code.
$ tctl rm roles/access
Tap any security key
# success
With tctl edit or the WebUI, it is possible to edit existing resources in a
text editor. In this case, MFA will be prompted before proceeding to the text
editor to prevent data loss from a failed MFA challenge.
$ tctl edit roles/access
Tap any security key
# edit role in Vim
# success
The bulk of this RFD is focused on security and will result in a net positive to our security outlook.
Here are a few key points to review:
optional, on, webauthn, otp).Admin role used when executing tctl directly on an Auth Server.create permissions on the role, user, and token could
use their privileges to generate impersonated certificates that do not
require MFA for admin actions.In order to maintain backwards compatibility with old clients (tsh, tctl,
Teleport Connect), MFA will not be strictly required for admin actions until
Teleport 15.
| Teleport 13 | Teleport 14 | Teleport 15 | |
|---|---|---|---|
| Server | Does not require MFA | Does not require MFA | Requires MFA |
| Client | Does not provide MFA | Provides MFA | Provides MFA |
Additionally, Teleport 14+ clients will be able to provide MFA for admin actions whether or not the client has prior knowledge of the request requiring MFA. This means that additional endpoints can be changed into admin actions without any consequences.
The WebUI will not support providing MFA for admin actions until Teleport 15. This means that administrators will need to upgrade their Proxy services to Teleport 15 alongside their Auth services to avoid getting admin actions denied. This must not cause any upgrading issues.
Clients will not attempt to provide MFA for HTTP endpoints. This means that http endpoints converted to gRPC admin action endpoints should not be made to require MFA until a full major version cycle has passed.
Audit events will be added to each admin action. Many admin actions already
have their own audit events, such as role.created event. Other admin actions
are missing audit events, like node.created. Any admin action missing an
audit event will have one added.
These events will only be emitted when the action is taken by a user. This prevents audit spam from built in services performing their normal duties. For example, a node upserting itself with a heartbeat will not be recorded, but if a user edits a node directly, it will be.
In addition to the individual audit events emitted, we will emit an admin action mfa authentication event. This event will also hold the metadata of its corresponding admin action event to tie the two events together.
// UserCreate is emitted when the user is created or updated (upsert).
message AdminActionMFAAuthentication {
Metadata metadata = 1;
UserMetadata user = 2;
// request_metadata of the corresponding admin action event
Metadata request_metadata = 3;
Status status = 4;
MFADeviceMetadata mfa_device = 4;
}
If MFA verification fails for an admin action, then this event will be emitted with an error in its status, while the corresponding admin action event, in most cases, will not be emitted.
We will add a new admin action mfa PostHog event. This event will be derived from the audit event above.
message AdminActionMFAAuthenticationEvent {
// The name of the admin action, derived from the audit event's request_metadata.type field.
string admin_action_request_name = 1;
// anonymized
string user_name = 2;
bool success = 3;
}
The implementation of this feature will include automated unit tests to ensure that MFA is required for admin actions across applicable server configurations.
Hardware Key Support can also be used for this use case. When setting
require_session_mfa: hardware_key_touch for a role or cluster, YubiKey tap is
required for every private key operation, which applies to essentially every
action you can take in Teleport.
However, Hardware Key support is still somewhat limited due to the limitations of PIV. Most notably, Hardware Key support is not supported on the Web UI, which is essential for this feature.
The WebUI and Teleport Connect do not currently have a universal TOTP MFA prompt, making it difficult to universally support TOTP for admin actions.
If in the future TOTP prompts are added for these applications, we can consider
widening this feature to also cover all clusters where cluster_auth_preference.second_factor
is not set to off, rather than the more limited scope described in
Server configuration. However, this most likely won't
be a priority as we are actually looking to deprecate TOTP.