other
- Location
scripts/list_codex_sessions.py:293- Finding
Exposure of Sensitive Local Codex Session History
- Content
View full analysis
Vulnerability Details
File Location:
scripts/list_codex_sessions.py:10-13, 40-66, 130-143, 293-366, 456-467, 566-577
Vulnerability Type: Sensitive Local Session Data Access
Risk Level: MediumVulnerable Code
python CODEX_HOME = Path.home() / ".codex" INDEX_PATH = CODEX_HOME / "session_index.jsonl" ACTIVE_SESSIONS_DIR = CODEX_HOME / "sessions" ARCHIVED_SESSIONS_DIR = CODEX_HOME / "archived_sessions"python def load_history_titles() -> dict[str, str]: history_path = CODEX_HOME / "history.jsonl" titles: dict[str, str] = {} if not history_path.exists(): return titles with history_path.open() as handle: for raw_line in handle: raw_line = raw_line.strip() if not raw_line: continue try: row = json.loads(raw_line) except json.JSONDecodeError: continue session_id = row.get("session_id") text = row.get("text") if not isinstance(session_id, str) or not isinstance(text, str): continue if session_id in titles: continue normalized = normalize_user_message(text) if normalized: titles[session_id] = normalized return titlespython def iter_session_files(source: str) -> list[tuple[str, Path]]: files: list[tuple[str, Path]] = [] if source in {"all", "active"} and ACTIVE_SESSIONS_DIR.exists(): for path in ACTIVE_SESSIONS_DIR.rglob("*.jsonl"): files.append(("active", path)) if source in {"all", "archived"} and ARCHIVED_SESSIONS_DIR.exists(): for path in ARCHIVED_SESSIONS_DIR.glob("*.jsonl"): files.append(("archived", path)) return filespython with session_file.open() as handle: for raw_line in handle: raw_line = ...[truncated 4043 chars]- Remediation
View remediation
Remediation Suggestions
- Make metadata-only processing the default and avoid reading message bodies unless the user explicitly requests content inspection.
- Require an explicit option such as
--include-message-contentbefore extracting or displayingfirst_user_message. - Display a warning or confirmation prompt before returning conversation content in detailed or JSON output.
- Redact common secret patterns, including API keys, tokens, passwords, private keys, and authorization headers.
- Omit or abbreviate absolute
cwd,project_path, andsession_filevalues by default. - Add separate controls for sensitive fields so callers can request only the minimum necessary data.
- Document that detailed and JSON output may contain sensitive local conversation information and should not be written to public logs.
- Where interactive confirmation is impractical, require a deliberate environment variable or command-line acknowledgment before exposing message text.
