T09 · Insecure Skill Coding Practices
- Location
payaclaw_helper.py:200- Finding
Predictable Plaintext Output File Permits Symlink-Based File Overwrite
- Content
View full analysis
Vulnerability Details
File Location:
payaclaw_helper.py, lines 200-203
Vulnerability Type: Predictable file creation, symlink following, and unexpected plaintext persistence
Risk Level: MediumVulnerable Code:
python output_file = f"payaclaw_output_{datetime.now().strftime('%Y%m%d_%H%M%S')}.txt" with open(output_file, 'w', encoding='utf-8') as f: f.write(result) print(f"\n💾 结果已保存到: {output_file}")Technical Analysis
Every command automatically saves the generated result to a plaintext file in the current working directory. The filename is derived solely from the current timestamp with one-second precision, making it predictable.
The file is opened in
wmode without exclusive creation or protection against symbolic links. If a file already exists at the predicted path, it is truncated. If the path is a symbolic link, Python follows that link and writes to its target. An attacker with write access to the working directory can therefore prepare the expected output path as a symbolic link to another file writable by the victim process.The saved result can contain user-supplied task descriptions, contextual information, or submission content. This also causes potentially sensitive information to be persisted in plaintext automatically. The documented usage in
SKILL.mddoes not disclose this file-write side effect.Attack Path
- The attacker obtains write access to a directory in which a victim will run the helper.
- The attacker predicts the timestamp-based filename for the expected execution second, such as
payaclaw_output_20260916_120000.txt. - The attacker creates that path as a symbolic link to a file writable by the victim process.
- The victim invokes any supported command from that directory.
- The helper opens the predictable path in
wmode, follows the symbolic link, and truncates or replaces the linked target with generated output.
Exploitation require ...[truncated 808 chars]
- Remediation
View remediation
Remediation Suggestions
- Make file persistence opt-in through an explicit
--outputoption instead of automatically writing every result. - Document the file-write behavior, destination, overwrite policy, and sensitivity implications in
SKILL.md. - When creating a new output file, use exclusive creation mode (
x) and fail safely if the path already exists. - Prefer a cryptographically unpredictable filename generated with Python's
tempfilemodule when automatic file creation is necessary. - Create output with restrictive permissions, such as owner read/write access only.
- Do not follow symbolic links. On supported systems, use an atomic low-level open operation with
O_CREAT | O_EXCL | O_NOFOLLOW, then wrap the resulting descriptor for text output. - Avoid attacker-controlled or shared working directories. Require a trusted output directory and validate its ownership and permissions before writing.
- Provide a standard-output-only mode so sensitive generated content does not remain on disk by default.
- Make file persistence opt-in through an explicit
