Skip to content

Fix agent not enforcing MFA device lock after in-band MFA. - #69653

Draft
cthach wants to merge 1 commit into
masterfrom
cthach/enforce-in-band-lock
Draft

Fix agent not enforcing MFA device lock after in-band MFA.#69653
cthach wants to merge 1 commit into
masterfrom
cthach/enforce-in-band-lock

Conversation

@cthach

@cthach cthach commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Part 2 of bug fix for https://github.com/gravitational/core/issues/146.

After successful in-band MFA during SSH session establishment, the Agent will append the MFA device used to satisfy the MFA challenge as a lock target to decisionpb.SSHAccessPermit.LockTargets.

This works because lock enforcement happens further downstream in AcquireSessionContext and NewServerContext; the former being lock enforcement for new connections and latter for established connections.

Alternatives considered

  1. Pass the MFADevice through ssh.Permissions.Extensions or ssh.Permissions.ExtraData. Rejected because the SSH access permit is authoritative on lock targets and side stepping that would be confusing and error prone.
  2. Create a new field MFADevice on the IdentityContext. Rejected because it was has broader implications and because it conflicts with IdentityContext.UnmappedIdentity.MFAVerified.

Future work

  1. Add missing test coverage for locks to TestSSHOnMultipleNodes. Current coverage added in this PR should suffice, but adding integration coverage will give us confidence the whole system is working E2E, especially the trusted cluster scenario. It should be a matter of creating a lock, waiting for the lock to propagate, attempting to connect and asserting on the error.

Manual Test Plan

Test Environment

Teleport instance built with make full-ent running on my Mac. My clients are built from Teleport v18.

Test Cases

  • SSH to node with per-session MFA should succeed
  • SSH to node with per-session MFA and device lock should reject the new session
  • SSH to node with per-session MFA, no device lock initially, and enable device lock after session established, should terminate the established session

@cthach cthach self-assigned this Aug 13, 2026
@cthach cthach added mfa Issues related to Multi Factor Authentication no-changelog Indicates that a PR does not require a changelog entry labels Aug 13, 2026
@cthach

cthach commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: c82aa74d96

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Signed-off-by: Chris Thach <chris.thach@goteleport.com>
@cthach
cthach force-pushed the cthach/enforce-in-band-lock branch from c82aa74 to 882ae35 Compare August 13, 2026 23:39
@cthach

cthach commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

TODO: Migrate this PR to our new repo. Will open it for review then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mfa Issues related to Multi Factor Authentication no-changelog Indicates that a PR does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant