T05 · Unauthorized Access and Privilege Escalation
- Location
hook_handler.py:27- Finding
Unrestricted Hook-Controlled Local File Indexing
- Content
View full analysis
str: """Extract a file content summary (first 500 characters).""" try: # Skip binary files with open(filepath, 'rb') as f: chunk = f.read(500) if b'\x00' in chunk: return '' with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: content = f.read(500) return content.replace('\n', ' ').strip() except Exception: return '' ``` ### Technical Analysis The hook handler consumes event data from standard input and trusts the `file_path` supplied in `Write` and `Edit` events. It does not canonicalize the path, confirm that it belongs to an approved workspace, reject symbolic links, enforce an approved extension list, or deny sensitive filenames. `FileIndexer.add_file()` subsequently invokes `_extract_summary()`, which reads and stores the first 500 characters of any accessible file in the SQLite index. The stricter filtering applied by `scan_directory()` does not apply to files submitted through hook events. Consequently, an actor able to submit or forge hook input can cause the Skill to read files outside its intended workspace. Sensitive ...[truncated 1384 chars]- Remediation
View remediation
