T05 · Unauthorized Access and Privilege Escalation
- Location
src/tools/context_gatherer.py:82- Finding
Undisclosed Collection of Shell History and AI-Agent Session Data
- Content
View full analysis
Dict: """Shell history""" history_file = Path.home() / ".bash_history" commands = [] if history_file.exists(): try: with open(history_file, errors='ignore') as f: commands = [l.strip() for l in f.readlines()[-10:] if l.strip()] except Exception: pass return { 'last_commands': commands, 'user': os.getenv('USER', 'unknown'), 'shell': os.getenv('SHELL', '/bin/bash'), } ``` ```python def gather_gemini_cli_context() -> Optional[Dict]: """Gather the active Gemini CLI session context if available""" try: from ..config import Config config = Config() chats_dir = Path(config.get('gemini_chats_dir')) if not chats_dir.exists(): return None session_files = glob.glob(str(chats_dir / "session-*.json")) if not session_files: return None latest_file = max(session_files, key=os.path.getmtime) with open(latest_file, 'r', encoding='utf-8') as f: data = json.load(f) messages = data.get('messages', []) user_messages = [ m for m in messages if m.get('type') == 'user' ] recent_prompts = [] for msg in user_messages[-2:]: content = msg.get('content', []) if isinstance(content, list) and len(content) > 0: text = content[0].get('text', '') if text: ...[truncated 3513 chars]- Remediation
View remediation
