T09 · Insecure Skill Coding Practices
- Location
bin/agentsource.py:117- Finding
Predictable and Non-Private Temporary Files Allow Data Disclosure and Symlink Overwrite
- Content
View full analysis
pathlib.Path: ts = int(time.time()) return TEMP_DIR / f"agentsource_{ts}_{command}.json" def write_result(command: str, data: dict) -> pathlib.Path: path = make_temp_path(command) path.write_text(json.dumps(data, indent=2, default=str)) print(str(path)) return path def write_error(command: str, error_msg: str, error_code: str = None, http_status: int = None) -> pathlib.Path: data = { "success": False, "error": error_msg, "error_code": error_code, "http_status": http_status, "command": command, "timestamp": int(time.time()), } path = make_temp_path(f"{command}_error") path.write_text(json.dumps(data, indent=2)) print(str(path)) return path ``` ### Technical Analysis Temporary filenames consist only of the current second and a known command name. They are therefore predictable and can collide when multiple commands of the same type run during the same second. `Path.write_text()` does not provide exclusive file creation and follows an existing symbolic link. An attacker with access to the shared `/tmp` directory can pre-create the predicted path as a symbolic link to another file writable by the victim. When the CLI writes its result, it follows that link and overwrites the target. The code also does not explicitly set mode `0600`. File permissions consequently depend on the process umask and commonly become `0644`, allowing other local users to read them. These files may contain complete uploaded CSV rows, prospect names, professional or personal email addresses, direct or mobile phone numbers, LinkedIn profiles, and business intelligence. ### Attack Path 1. A local ...[truncated 1027 chars]- Remediation
View remediation
