[BUG] - Sensitive API Key exposed in cleartext and potential UnboundLocalError in CLI initialization

Abierto
#159 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
cli, security

Línea de trabajo

Comienza en cli.py, en el bloque de inicialización global que gestiona el fallback de BROWSER_USE_API_KEY, e inspecciona cómo los comandos de Typer utilizan llm_instance y page_extraction_llm. Ejecuta la CLI cuando la clave esté ausente o sea no válida, prueba las respuestas y y n, y verifica que la entrada secreta esté oculta y que rechazar la solicitud produzca un resultado correcto sin errores de inicialización posteriores.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Description
During a static code review of cli.py, two critical issues were identified in the global initialization block handling the BROWSER_USE_API_KEY fallback:

  1. Cleartext Key Exposure (Security): The fallback mechanism uses the built-in input() function to collect the user's API key (os.environ['BROWSER_USE_API_KEY'] = input(...)). This echoes the sensitive API key in cleartext to the terminal, making it vulnerable to shoulder surfing and terminal history logging.

  2. Unbound Local Variable Risk (Stability): If the initial ChatBrowserUse instantiation fails and the user selects n at the prompt, the code executes a pass. Consequently, llm_instance and page_extraction_llm remain uninitialized. When downstream Typer commands attempt to access these global instances, the application will crash with a NameError or UnboundLocalError.

Steps to reproduce
Note: Identified via static program analysis. Theoretical reproduction steps below:

1.Run the CLI tool in an environment where BROWSER_USE_API_KEY is not set or invalid.

  1. At the prompt Set BROWSER_USE_API_KEY? (y/n):, type y.

  2. Paste an API key and observe that the key is printed to the screen in plain text (Security Issue).

  3. Alternatively, at the first prompt, type n.

  4. Attempt to run any CLI command that utilizes the LLM. Observe the application crashing due to undefined variables (Stability Issue).

Expected behavior

  1. The CLI should securely prompt for the API key by masking the input. Since typer is already a project dependency, typer.prompt("Enter your BROWSER_USE_API_KEY", hide_input=True) should be used instead of standard input().

  2. If the user declines to provide a key (inputs n), the script should either gracefully exit using typer.Exit() with a helpful warning, or initialize a safe fallback state to prevent unhandled exceptions downstream.

Actual behavior
The API key is visibly echoed on the screen during input, and the script silently continues execution with undefined core LLM variables if the user skips the fallback prompt.

Additional context
Using typer.prompt(..., hide_input=True) is the standard best practice for handling secrets in Typer-based CLI applications and requires minimal refactoring.

Lenguaje dominante
Python
Estrellas
4.3k
Forks
356
Merge medio
50 min
PR fusionados (30 d)
6

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de browser-use/workflow-use

Todos los issues de browser-use/workflow-use

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.