Skip to content

[Security Patch] Fix RCE vulnerability, secure API key storage, and resolve UI threading bugs#3

Open
Guettaf-hossam wants to merge 3 commits into
FatihMakes:mainfrom
Guettaf-hossam:main
Open

[Security Patch] Fix RCE vulnerability, secure API key storage, and resolve UI threading bugs#3
Guettaf-hossam wants to merge 3 commits into
FatihMakes:mainfrom
Guettaf-hossam:main

Conversation

@Guettaf-hossam
Copy link
Copy Markdown

Overview

This Pull Request addresses the critical security and structural vulnerabilities reported in #2. It hardens the system against potential prompt injection attacks, secures user secrets, and stabilizes the Tkinter UI.

Key Changes

1. Secrets Management (.env Migration)

  • Replaced the insecure config/api_keys.json plaintext storage with a secure .env implementation using python-dotenv.
  • Added .gitignore to ensure .env and __pycache__ are never committed.
  • Refactored _get_api_key() in main.py to use os.getenv() and removed the redundant file-read bug.

2. Human-in-the-Loop (HITL) Sandbox for Dangerous Tools

  • Implemented a _confirm() helper using tkinter.messagebox.askyesno (with a terminal input() fallback).
  • Gated all destructive and OS-level commands. Tools like cmd_control, code_helper (run/build/edit), and file_controller (delete/move/write) will now pause and explicitly ask for user permission before executing.
  • If the user clicks "No", the tool safely returns "Action blocked by user." to the LLM, neutralizing any prompt injection RCE attempts.

3. Tkinter Thread-Safety Fix

  • Bug fixed: ui.py was being modified directly from background asyncio/threading loops (e.g., write_log and speaking states), which causes Tkinter to freeze or crash.
  • Solution: Introduced a thread-safe queue.Queue(). Background threads now only enqueue state changes, and a new _poll_queue() method running on the main thread (via root.after()) safely updates the UI.

Note for the Maintainer:

Upon merging this, users will be prompted to re-enter their Gemini API key on their first launch to generate the new .env file. Read-only actions (like listing files or reading code) remain autonomous and un-gated for a smooth experience.

Please let me know if you need any adjustments to these changes!

@jas-kha
Copy link
Copy Markdown

jas-kha commented Apr 9, 2026

Resolve conflicts

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants