bitwarden / clients

Bitwarden client apps (web, browser extension, desktop, and cli).
https://bitwarden.com
Other
8.66k stars 1.14k forks source link

CLI version 2024.6.0 session key unlock randomly fails #9762

Open heaio9v2 opened 1 week ago

heaio9v2 commented 1 week ago

Steps To Reproduce

I can reproduce using the following within PowerShell:

  1. Login to the vault using email address, master password, and two-step (TOTP) and store session in variable.
  2. Search for a record in the vault using the session variable.

Sample code:

$emailAddress = "valid@email.address"
$masterpassword = "validMasterPassword"
$search = "google.com"
# Will be prompted for TOTP code at login
$sessionKey = &"bw.exe" login $emailAddress $masterPassword --raw
# Repeat the next line a couple of times. Randomly within 10 attempts or so I receive "Vault is locked." error. Running the command again might result in the vault unlocking as expected until it doesn't.
&"bw.exe" --session $sessionKey --nointeraction list items --search $search

Expected Result

Vault stays unlocked when valid session key is presented.

Actual Result

Vault does not unlock consistently when a valid session key is provided to the CLI.

Screenshots or Videos

No response

Additional Context

PowerShell version 7.4.2

Operating System

Windows

Operating System Version

11 (10.0.26100)

Shell

PowerShell

Build Version

2024.6.0

Issue Tracking Info

maekawatoshiki commented 6 days ago

Same here on macOS

heaio9v2 commented 4 days ago

As a stop gap, I've had to create a retry loop within my code to detect when the vault fails to unlock. After one to two retries it will unlock as expected and the code will proceed fine for a seemingly random time.