gravitational / teleport

The easiest, and most secure way to access and protect all of your infrastructure.
https://goteleport.com
GNU Affero General Public License v3.0
17.59k stars 1.76k forks source link

UX Bug: Terraform is extremely hard to use when MFA for admin action is enforced #39744

Closed hugoShaka closed 4 months ago

hugoShaka commented 7 months ago

MFA for admin action blocks the local execution of Terraform code and forces the administrators to use machineID locally. This both degrades the Terraform experience and reduces the security.

Expected behaviour:

Current behaviour:

Why local Terraform execution matters

Why the local machine ID workaround is a security downgrade

The users deploying Terraform code locally are administrators. They are the high-privilege target we want to protect with "MFA for admin".

Setting up a local MachineID bot generates long-lived renewable credentials on their machine. Those credentials can be exfiltrated and MachineID's exfiltrartion mechanism only works when the bot is running (which is very infrequent as we are using it in oneshot mode).

We wanted to reduce the risk of admin account takeover, but forced users to create more sensitive long-lived credentials, increasing the risk of admin account exfiltration. Those credentials are also not subject to "MFA for admin" by definition.

Workaround:

Bug details:

hugoShaka commented 7 months ago

With @Joerger we discussed the following approaches:

Use the user's local ~/.tsh profile and MFA

This approach removes the use of impersonation, Terraform would run as the user. The user would get prompted for MFA when running Terraform.

This approach offers a simple setup flow (no additional user, role, bot, just use your rights) and a strong security posture (MFA for admin security properties are preserved).

This approach requires the user to have the appropriate rights. This was already the case indirectly with the previous impersonation approach. This means users potentially have higher standing privileges by default, although most users applying Terraform code are very likely already editors/

Use impersonated certificates + user MFA

This approach is a port of the current impersonation approach, but with "MFA for admin" support. This implies:

Allow the user to sign certs bypassing from "MFA for admin"

This would make the old approach functional again. However, this would remove most security benefits brought by "MFA for Admin"

Allow Terraform to run MachineID natively

This would partially address the UX issue. The user would pass a bot token to Terraform, and Terraform would do the MachineID dance to get Bot certs, without the need for tbot.

This improves the UX locally, but also in the CI: you can pass to Terraform a GHA token and let it get the certs automatically.

However this doesn't address the security aspect of having long-lived/renewable admin certificates not subject to MFA on every admin laptop.