T09 · Insecure Skill Coding Practices
- Location
bin/agentsource.py:116- Finding
Predictable and Insufficiently Protected Temporary Files Expose Sensitive Prospect Data
- 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 ``` The same pattern is used for error files: ```python path = make_temp_path(f"{command}_error") path.write_text(json.dumps(data, indent=2)) ``` ### Technical Analysis The CLI writes imported CSV rows, fetched companies, prospect contact information, enrichment results, and event data directly to the shared `/tmp` directory. Filenames contain only a timestamp with one-second resolution and a known command name. The implementation does not: - Generate a cryptographically random filename. - Atomically reserve the destination before writing. - Explicitly set result-file permissions to `0600`. - Use a private temporary directory with permissions such as `0700`. - Remove result files after use. Consequently, file permissions depend on the invoking process's umask. With a common `022` umask, newly created files may be readable by other local users. Predictable names also permit collisions between invocations of the same command during the same second. Depending on operating-system temporary-file protections, pre-creation or link-based interference may also be possible. The README states that these files are cleaned up automatically by the operating system, but that does not provide timely confidentiality guarantees and does not prevent exposure while the files exist. ### Attack Path 1. An attacker with access to another local account monitors `/tmp` for names matching `agentsource_*_fetch.jso ...[truncated 1153 chars]- Remediation
View remediation
