T09 · Insecure Skill Coding Practices
- Location
scripts/resume_parser.py:89- Finding
Resume Personally Identifiable Information Stored in a Predictable Plaintext File
- Content
View full analysis
Vulnerability Details
File Location:
scripts/resume_parser.py, lines 89-102
Vulnerability Type: Predictable plaintext storage of sensitive resume data
Risk Level: MediumVulnerable Code
python return { "raw_text": text, "file_type": file_ext, "file_path": file_path } if __name__ == "__main__": if len(sys.argv) != 2: print("用法: python resume_parser.py <简历文件路径>") sys.exit(1) result = parse_resume(sys.argv[1]) # 输出到文件避免编码问题 import json output_path = "resume_parsed_result.json" with open(output_path, "w", encoding="utf-8") as f: json.dump(result, f, ensure_ascii=False, indent=2)Technical Analysis
The parser stores the complete extracted resume text and original source path in an unencrypted JSON file named
resume_parsed_result.jsonin the current working directory. Resume content commonly includes sensitive personally identifiable information such as names, telephone numbers, email addresses, home addresses, employment history, and education records.The output file has a fixed, predictable name. The code does not explicitly apply restrictive file permissions, verify that the destination is not a symbolic link, create the file atomically, or remove it after processing. Its effective permissions therefore depend on the process umask and surrounding filesystem configuration.
Opening the path with mode
walso follows an existing symbolic link. In a shared or attacker-controlled working directory, another local user could pre-createresume_parsed_result.jsonas a symbolic link to a file writable by the victim. The parser would then truncate and replace that destination with JSON data.Attack Path
- An attacker obtains read or write access to the directory from which the parser will be executed.
- For confidentiality loss, the attacker waits for the parser to create
resume_parsed_result.jsonwit ...[truncated 1052 chars]
- Remediation
View remediation
Remediation Suggestions
- Avoid persistent storage by default. Return the parsed result through standard output or keep it in memory when possible.
- Require callers to provide an explicit output destination instead of using a fixed filename in the current directory.
- Create output files atomically and with owner-only permissions, such as mode
0600. - Refuse to write through symbolic links. Use secure creation flags such as
O_CREAT | O_EXCL | O_NOFOLLOWwhere supported. - If replacement is required, write to a securely created temporary file in the destination directory and atomically rename it.
- Omit
file_pathunless it is operationally necessary, or store only a sanitized filename. - Add a documented retention policy and securely delete temporary parsing results when they are no longer required.
- Warn users that extracted resume data contains sensitive personal information and should not be placed in shared directories.
