T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/extract-raw-inputs.py:84
- Finding
- Overbroad Collection and Persistent Retention of Private Session Transcripts<![CDATA[ ## Vulnerability Details **File Location**: `scripts/extract-raw-inputs.py:84-145`; `scripts/extract-daily-digest.py:269-302` **Vulnerability Type**: Overbroad access to private conversation history **Risk Level**: Medium ### Complete Vulnerable Code From `scripts/extract-raw-inputs.py:84-145`: ```python def main(): target_date = parse_args() events = [] session_files = glob.glob(os.path.join(SESSIONS_DIR, "*.jsonl")) for sf in session_files: basename = os.path.basename(sf) if ".lock" in basename or ".deleted" in basename or ".reset" in basename: continue try: with open(sf, "r", encoding="utf-8") as f: for line in f: line = line.strip() if not line: continue try: obj = json.loads(line) except json.JSONDecodeError: continue if obj.get("type") != "message": continue msg = obj.get("message", {}) if msg.get("role") != "user": continue ts_str = obj.get("timestamp", "") if not ts_str: continue try: ts = datetime.fromisoformat(ts_str.replace("Z", "+00:00")) ts_local = ts.astimezone(TZ) except (ValueError, TypeError): continue if ts_local.date() != target_date: continue user_text = extract_user_text(msg.get("content", "")) if user_text and len(user_text) > 2: # Filter cron/heartbeat/system/session-startup messages skip_patterns = [ "HEARTBEAT", "heartbeat", "[cron:", ...[truncated 4600 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require explicit opt-in before reading any session transcript. 2. Accept an explicit list of session IDs or transcript paths rather than enumerating every `*.jsonl` file. 3. Default to the active review session and require separate consent to include other conversations. 4. Add configurable exclusions for sensitive sessions, message categories, and content patterns. 5. Minimize retained data by storing summaries rather than verbatim messages whenever possible. 6. Implement a documented retention period and automatic deletion of expired daily digests. 7. Create output files with restrictive permissions, such as mode `0600`, and verify that parent directories are not accessible to unrelated users. 8. Avoid printing raw transcripts to shared temporary files or logs. 9. Document exactly which conversations are accessed and provide a preview before collection. 10. Record access provenance so users can identify which sessions contributed to a digest. ]]>
