T09 · Insecure Skill Coding Practices
- Location
deep-research-report.py:189- Finding
Completed research results persist in temporary stream files
- Content
View full analysis
Vulnerability Details
File Location:
deep-research-report.py, lines 189–197 and 424–453
Vulnerability Type: Sensitive data retained in temporary files
Risk Level: MediumVulnerable Code
python def create_temp_stream_file() -> Optional[str]: """Create a writable temp file path for stream payload, if possible.""" tmp_dir = tempfile.gettempdir() if not os.access(tmp_dir, os.W_OK): return None fd, path = tempfile.mkstemp(prefix="unifuncs-deep-research-", suffix=".stream", dir=tmp_dir) os.close(fd) return pathpython if args.stream: temp_path = resolve_stream_file_path(args.stream_file) if not temp_path: raise UniFuncsDeepResearchError("No writable stream file available for streaming mode.") if args.background_worker: stream_chat(payload, api_key, 24 * 60 * 60, temp_path) return start_background_worker(args, temp_path) started_at = time.monotonic() while time.monotonic() - started_at < args.timeout: if is_stream_done(temp_path): break time.sleep(0.5) output = extract_text_from_stream_file(temp_path) if not is_stream_done(temp_path): command = ( f'python3 "{os.path.abspath(__file__)}" --read-stream-file --stream-file "{temp_path}"' ) notice_lines = [ "", "", f"[Unfinished] No complete response within {args.timeout}s; returning received partial content.", "[Background] Streaming continues in the background.", f"[Stream File] {temp_path}", "[Read Later] Run this command to read received content:", command, ] output += "\n".join(notice_lines) print(output)Technical Analysis
Streaming responses are written to a file created in the system temporary directory. Although `tempfile.m ...[truncated 1812 chars]
- Remediation
View remediation
Remediation Suggestions
- Track whether the stream file was automatically created or explicitly supplied by the user.
- Delete automatically created files after a completed response has been rendered.
- Perform cleanup in a
finallyblock so files are also handled on parsing failures, network errors, and interruption. - Retain an automatically created file only while an unfinished background request genuinely requires it.
- Preserve user-specified
--stream-filepaths only when documented as an explicit retention request. - Apply an explicit restrictive mode such as
0o600when opening any user-specified stream file. - Document the storage location, retention period, cleanup behavior, and sensitivity of stream files.
- Consider storing only extracted report text rather than the complete raw event stream if raw chunks are unnecessary.
A suitable lifecycle is: create a restricted temporary file, stream into it, render the result, and securely remove it immediately when completion is confirmed.
