Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Improve placeholder handling for 2FA secrets in registry service

LarsenCundricdd8a63ce41b6
diff --git a/browser_use/tools/registry/service.py b/browser_use/tools/registry/service.py
index 846d2e239..77817cbf4 100644
--- a/browser_use/tools/registry/service.py
+++ b/browser_use/tools/registry/service.py
@@ -455,8 +455,8 @@ class Registry(Generic[Context]):
# check if the placeholder key, like x_password is in the output parameters of the LLM and replace it with the sensitive data
for placeholder in matches:
if placeholder in applicable_secrets:
- # generate a totp code if secret is a 2fa secret
- if 'bu_2fa_code' in placeholder:
+ # generate a totp code if secret is suffixed with bu_2fa_code
+ if placeholder.endswith('bu_2fa_code'):
totp = pyotp.TOTP(applicable_secrets[placeholder], digits=6)
replacement_value = totp.now()
else: