T09 · Insecure Skill Coding Practices
- Location
batch_id.py:51- Finding
Predictable Shared Temporary File Can Expose ID Card Data Across Requests
- Content
View full analysis
Vulnerability Details
File Location:
batch_id.py, lines 51–59
Vulnerability Type: Predictable and shared temporary file containing sensitive personal data
Risk Level: HighVulnerable Code
python file_path = "/tmp/身份证提取结果.txt" with open(file_path, "w", encoding="utf-8") as f: f.write(final_file_text) # 5. Return the file to OpenClaw # The OpenClaw file-return protocol normally requires a file path or Base64 data return { "result": f"✅ Successfully extracted information from {len(all_content)} ID cards. Please see the attachment.", "files": [file_path] }Technical Analysis
Every invocation writes highly sensitive ID card information to the same predictable path under
/tmp. There is no request-specific filename, exclusive file creation, synchronization, restrictive permission assignment, or cleanup.In a reused or concurrent runtime, multiple invocations can access and overwrite the same file. The returned response identifies only the shared path, so the platform may read it after another invocation has replaced its contents. This creates a time-of-check/time-of-use race that can cause one user's file response to contain another user's identity information.
The output contains names, sex, and national identification numbers. Leaving the file behind also increases the period during which later processes or invocations may access stale personal data. The effective default permissions depend on the process umask and are not explicitly restricted by the Skill.
Attack Path
- A victim invokes the Skill with one or more ID card images.
- The victim's OCR results are written to
/tmp/身份证提取结果.txt. - Before the platform consumes the returned file, an attacker triggers another invocation, or the attacker's invocation is interleaved with the victim's invocation.
- Both invocations write to the same path without locking or exclusive creation.
- Depending on executi ...[truncated 767 chars]
- Remediation
View remediation
Remediation Suggestions
- Create a unique private file for each invocation using
tempfile.NamedTemporaryFile,tempfile.mkstemp, or a request-specific directory generated withtempfile.mkdtemp. - Ensure the file is created atomically with permissions limited to the owner, preferably mode
0600. - Never derive the temporary filename from user-controlled input.
- Ensure the platform consumes the file before deletion, then remove it in a
finallyblock or through a documented post-delivery cleanup mechanism. - Where supported, return the generated content as an in-memory byte stream or Base64 payload instead of writing sensitive information to disk.
- Add concurrency tests that run multiple invocations simultaneously and verify that each response contains only its own records.
- Minimize retention of OCR results and document the handling lifecycle for identity data.
- Create a unique private file for each invocation using
