Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Admin MFA required check #51618

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

Joerger
Copy link
Contributor

@Joerger Joerger commented Jan 29, 2025

The MFA required check for admin actions would take into account whether the IsMFARequired (or CreateAuthenticationChallenge) request itself was admin-mfa-verified. This could potentially cause two problems:

  1. The mfa response is reusable, but we are checking if mfa is required for an endpoint that disallows reuse. CreateAuthenticationChallenge will call IsMFARequired and incorrectly think that it is already MFA verified.
  2. The mfa response is not reusable, so IsMFARequired or CreateAuthenticationChallenge consumes the MFA response and returns that MFA is not required.

This PR changes IsMFARequired now just checks if Admin Action MFA is strictly not required - Whether because it's not enforced (totp allowed), disabled (TELEPORT_UNSTABLE_DISABLE_MFA_ADMIN_ACTIONS), or the identity asking is a built role.

There are no bugs presently caused by this issue, but it is needed for some UX improvements like #46891.

@zmb3
Copy link
Collaborator

zmb3 commented Jan 29, 2025

Should we lock the behavior in with test coverage?

@Joerger Joerger added the no-changelog Indicates that a PR does not require a changelog entry label Jan 29, 2025
@Joerger Joerger force-pushed the joerger/fix-admin-action-is-mfa-required-check branch from f0d717f to 665c09b Compare January 29, 2025 21:31
@@ -9545,15 +9545,15 @@ func TestIsMFARequired_AdminAction(t *testing.T) {
name: "mfa verified",
adminActionAuthState: authz.AdminActionAuthMFAVerified,
expectResp: &proto.IsMFARequiredResponse{
Required: false,
MFARequired: proto.MFARequired_MFA_REQUIRED_NO,
Required: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's worth testing these using CreateAuthenticationChallenge instead? I've read the PR description a few times now but I confess I'm still a bit confused by it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateAuthenticateChallenge calls authWithRoles.IsMFARequired directly, so I think it's ok. I reorganized the PR description, hopefully the relation makes more sense now.

@Joerger Joerger requested a review from codingllama February 2, 2025 22:43
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from zmb3 February 3, 2025 15:30
@Joerger Joerger added this pull request to the merge queue Feb 4, 2025
Merged via the queue into master with commit e37d699 Feb 4, 2025
42 checks passed
@Joerger Joerger deleted the joerger/fix-admin-action-is-mfa-required-check branch February 4, 2025 17:35
@public-teleport-github-review-bot

@Joerger See the table below for backport results.

Branch Result
branch/v15 Failed
branch/v16 Failed
branch/v17 Create PR

@Joerger
Copy link
Contributor Author

Joerger commented Feb 4, 2025

Since we aren't backporting #46891, I'll skip this backport as well.

carloscastrojumo pushed a commit to carloscastrojumo/teleport that referenced this pull request Feb 19, 2025
* Fix admin mfa required check.

* Fix test.

* Add client fallback mechanism by removing pre-existing mfa context from admin action mfa ceremony.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants