T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- scripts/gimhub.py:130
- Finding
- Overbroad Recursive File Collection Can Expose Sensitive Local Data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/gimhub.py:130-148` **Vulnerability Type**: Excessive local file access and unintended data upload **Risk Level**: High ### Vulnerable Code ```python # Collect files files = [] if args.files: for file_path in args.files: path = Path(file_path) if path.exists(): files.append({ "path": str(path), "content": path.read_text(), "mode": "update", }) else: # Push all files in current directory (excluding hidden, common ignores) ignore = {".git", "__pycache__", "node_modules", ".venv", "venv"} for path in Path(".").rglob("*"): if path.is_file() and not any(p in path.parts for p in ignore): if not path.name.startswith("."): try: content = path.read_text() files.append({ "path": str(path), "content": content, "mode": "update", }) except UnicodeDecodeError: pass # Skip binary files ``` The collected contents are subsequently transmitted: ```python result = api_request("POST", f"/api/repos/{repo_path}/git/push", { "branch": args.branch, "files": files, "message": args.message, }, token=token) ``` ### Technical Analysis When `push` is invoked without `--files`, the program recursively reads every non-binary, non-hidden file beneath the current working directory. Its denylist only excludes five directory names and does not account for many sensitive file types, including: - Plaintext configuration and credential files - Logs and database exports - Conversation or session records - Deployment and infrastructure configuration - Proprietary source code unrelated to the inten ...[truncated 1872 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove recursive upload as the default behavior. Require explicit file paths, a manifest, or an explicit opt-in such as `--all`. 2. Restrict file resolution to a validated repository root and reject paths that resolve outside it. 3. Honor `.gitignore` and a dedicated `.gimhubignore` file. 4. Deny known-sensitive filenames and extensions, including credential stores, private keys, environment files, logs, databases, session records, and deployment secrets. 5. Add secret scanning and high-entropy token detection before constructing the request. 6. Display the complete upload list and require confirmation before recursive uploads, particularly in interactive sessions. 7. Use repository-relative paths rather than arbitrary local path strings. 8. Document clearly that selected file contents are transmitted to a remote service. ]]>
