T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/agent_kb.py:481- Finding
Default Statistics Collection Scans Sensitive Local Agent Transcripts Without Explicit Opt-In
- Content
View full analysis
Vulnerability Details
File Location:
scripts/agent_kb.py:481-486, 1922-1967, 2102-2108;scripts/transcript_reads.py:411-474
Vulnerability Type: Privacy-invasive local transcript access
Risk Level: MediumVulnerable Code
python # Scans transcripts for this repo and backfills KB read events into the local event log. def backfill_kb_reads(root: Path, args: argparse.Namespace) -> tuple[TranscriptScan, int]: kb = kb_dir(root) claude_dir = None if args.no_backfill_claude else resolve_transcript_path(args.claude_dir) codex_dir = None if args.no_backfill_codex else resolve_transcript_path(args.codex_dir) scan = scan_transcripts_incremental(root, kb, claude_dir, codex_dir) added = append_kb_read_events(kb, scan.reads) return scan, addedpython def command_stats(args: argparse.Namespace) -> int: root = repo_root(args) kb = kb_dir(root) if not kb.exists(): print("ERROR: missing .agent-kb/") return 1 scan: TranscriptScan | None = None added = 0 backfill_error = None if not args.no_backfill: try: scan, added = backfill_kb_reads(root, args) except Exception as err: backfill_error = str(err) scan, added = None, 0python stats_parser = subparsers.add_parser( "stats", help="Summarize CLI usage, KB reads, and KB file churn." ) stats_parser.add_argument("--root", default=".", help="Repository root to manage.") stats_parser.add_argument("--top", type=int, default=5, help="Show at most this many rows per section (default 5).") stats_parser.add_argument("--no-backfill", action="store_true", help="Do not scan local transcripts before rendering stats.") stats_parser.add_argument("--claude-dir", default="~/.claude/projects", help="Claude Code projects transcript directory.") stats_parser.add_argument("--codex-dir", default="~/.codex/sessions", help="Codex sessions transcript directory.") stats_parser.add_argument("- ...[truncated 3872 chars]- Remediation
View remediation
Remediation Suggestions
- Disable transcript scanning by default. Replace
--no-backfillwith an explicit--backfillor--scan-transcriptsopt-in option. - Before the first scan, clearly disclose which directories will be traversed, which fields will be extracted, and where derived records will be retained.
- Require explicit confirmation before scanning default home-directory locations, especially when running through an AI agent.
- Constrain scans to transcript directories and sessions demonstrably associated with the selected repository. Avoid using the generic
.agent-kbsubstring alone as a repository ownership signal. - Validate custom transcript directories and reject unexpectedly broad locations such as the user's home directory or filesystem root unless an additional override is supplied.
- Minimize retained data. Prefer aggregate counters over persistent session identifiers, timestamps, command details, or absolute paths.
- Add a retention policy and a command that deletes transcript-derived events and the backfill cache.
- Apply restrictive permissions to
.agent-kb/.log/, such as owner-only access where supported. - Preserve
--no-backfill-claudeand--no-backfill-codexcontrols, but make both sources disabled until explicitly selected. - Update
SKILL.mdto explain the privacy implications and provide a transcript-free statistics example.
- Disable transcript scanning by default. Replace
