T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/fixer.py:74- Finding
Unrestricted Scanner-Supplied File Access and Modification
- Content
View full analysis
None: """Apply a single fix to a file.""" # Create backup if enabled if self.backup: backup_path = fix.file_path.with_suffix(fix.file_path.suffix + '.bak') shutil.copy2(fix.file_path, backup_path) # Read file content = fix.file_path.read_text(encoding='utf-8') lines = content.split('\n') # Replace lines new_lines = lines[:fix.line_start-1] new_lines.extend(fix.fixed_code.split('\n')) new_lines.extend(lines[fix.line_end:]) # Write back fix.file_path.write_text('\n'.join(new_lines), encoding='utf-8') ``` ### Technical Analysis The path contained in `vuln.file` is accepted directly from the external scanner result and converted to a `Path` without validation. The implementation does not resolve the path against `self.skill_path`, verify that it remains under the requested skill directory, reject absolute paths, or detect symlinks that escape the directory. Consequently, a malicious or compromised `audit` implementation can submit an absolute path such as `/home/user/.bashrc` or a traversal path such as `../../sensitive-file`. The fixer will read that file during fix generation and may subsequently create a backup and overwrite it during fix application. The required `audit` module is not included in this project, so its trustworthiness and validation behavior cannot be established from the audited source. ### Attack Path 1. An attacker influences the target being scanned or compromises/spoofs the imported `audit` module. 2. The scanner returns a vulnerability whose `file` field points outside the inte ...[truncated 881 chars]- Remediation
View remediation
