T09 · Insecure Skill Coding Practices
- Location
scripts/strip.py:226- Finding
Manifest Output Can Silently Overwrite Arbitrary Writable Files
- Content
View full analysis
None: path.parent.mkdir(parents=True, exist_ok=True) path.write_text( json.dumps([asdict(report) for report in reports], indent=2), encoding="utf-8", ) ``` ```python manifest_path = None if args.manifest: manifest_path = Path(args.manifest) if not manifest_path.is_absolute(): if batch: manifest_path = output_root / manifest_path else: first_output = reports[0].output manifest_path = (Path(first_output).parent if first_output else src.parent) / manifest_path if not args.dry_run: write_manifest(manifest_path, reports) ``` ### Technical Analysis The value accepted by `--manifest` directly controls the destination passed to `Path.write_text()`. This method opens the destination for writing and truncates an existing file. The manifest-writing code does not perform any of the protections applied to image outputs: - It does not reject an existing destination unless overwrite permission was explicitly provided. - It does not prevent the manifest from targeting the input image or another user file. - It does not reject symbolic links. - It does not use exclusive file creation. - It accepts absolute paths and resolves relative paths into writable output locations. Consequently, any existing file writable by the process can be replaced with the generated JSON report. If the destination is a symbolic link, the write can follow that link and overwrite its target. This issue does not independently elevate privileges: the process must already have permission to write the selected target. However, it violates the documented expectation that destructive overwr ...[truncated 1323 chars]- Remediation
View remediation
