Security Blog

Can Claude Code use my 2FA codes without seeing the secret?

#45

November 22, 2026 · By Mila

← All posts

Yes. Keep the authenticator secret in a vault, and let the agent ask for the code, never the secret. `clavitor-cli totp "GitHub"` works out the current six digits on the agent's machine and prints only those. The vault holds the secret encrypted and never sees it.

The rest of this page is why that matters, how to set it up, and the one choice you make for each account.

Why the phone stopped working

Two-factor sign-in was built around a person with a phone. The site asks for a code, you open your authenticator app, you type six digits.

Then the one signing in became a script. Claude Code deploys, opens a dashboard, checks a console that sits behind 2FA. At step four it stops and waits for you to find your phone.

So people do the quick thing. They paste the secret, the long string behind the QR code, into a config file or a prompt, and let the agent make codes itself.

That string is not a code. It's the thing that makes every code, for as long as the account lives. Whoever holds it has your second factor until you reset it. In an agent's hands it can end up in a log, a transcript, or a reply to a prompt injection that asks for "your setup, for debugging".

The pattern: ask for the code, not the secret

A code lasts thirty seconds. A secret lasts until you change it. So the agent should get the first and never the second.

With Clavitor that's one command:

$ code=$(clavitor-cli totp "GitHub")

What happens:

  1. The CLI fetches the GitHub entry from the vault, encrypted.
  2. It decrypts the one-time-password field with the agent's own key, on the agent's machine.
  3. It works out the current code and prints it on one line, nothing else.

Capture the code inside the command that needs it, as above. Don't run totp on its own: then the code lands in the agent's output, which is its transcript.

It reads a plain secret (six digits, thirty seconds) or a full otpauth:// link, and follows that link's own settings: 6 to 8 digits, SHA-1, SHA-256 or SHA-512.

Setting it up for Claude Code

  1. In your vault, open Clients, then + New client. Name it "Claude Code" and pick the entries it may use.
  2. On the machine where Claude Code runs, paste the enrollment blob, type the enrollment key at the prompt, and install the skill:
$ clavitor-cli init '<blob>'
Enrollment key:
$ clavitor-cli skill install

The skill teaches Claude Code how to use the vault: one entry at a time, by name, and values captured where they're used instead of printed.

The one choice: which codes may an agent read?

A new authenticator secret in Clavitor is yours alone. It's saved under Identity Encryption, which only your hardware key opens. Ask an agent to use it and it gets a refusal (CV-2048) that names the field.

That's the right default. Your bank, your email, your company's admin console: no agent needs those codes.

For the accounts where an agent should get through sign-in on its own, open the entry in your vault page and click the small L3 badge next to the field. Confirm, and that one field moves to Credential Encryption. The badge reads L2, and clavitor-cli totp works for it. Your unlocked vault page already holds the key, so there's no extra tap. Changed your mind? Click L2, confirm, and only your key opens it again.

So it's per account, and it's your call each time.

What this doesn't solve

A code is still a working code for thirty seconds.

  • An agent that's been talked into something can still sign in with the access you gave it. It just can't walk away with the secret.
  • Once an agent can make its own codes, that 2FA no longer proves a person was there. Fine for a deploy account. Think twice where "a human approved this" is the point.
  • Someone with administrator access to the agent's machine can use whatever the agent can use.

That's why the access around it matters:

  • Scope. The agent only reaches the entries you gave its client.
  • Read limits. Each code is one read of the entry, counted toward the client's limits.
  • A record. Every code request is one read of the entry, and it is recorded in your audit log.

The short version

Don't give an agent your authenticator secret. Give it a way to ask for the current code, for the accounts you choose, and keep a line in the log for every time it does.

See how agent access works or read the totp docs.