T09 · Insecure Skill Coding Practices
- Location
scripts/cninfo_annual_reports/repository.py:183- Finding
Path Traversal Through an Unsanitized Remote Announcement Identifier
- Content
View full analysis
None: target_path.parent.mkdir(parents=True, exist_ok=True) temp_path = target_path.with_suffix(target_path.suffix + ".part") try: response = self._request(url, stream=True, action=f"download[{target_path.name}]") with response: response.raise_for_status() with temp_path.open("wb") as handle: for chunk in response.iter_content(chunk_size=1024 * 64): if chunk: handle.write(chunk) temp_path.replace(target_path) finally: if temp_path.exists(): temp_path.unlink(missing_ok=True) ``` ### Technical Analysis The `announcement_id` value originates from the remote CNInfo API and is stored without validation. For additional report variants, it is interpolated directly into a filename. No allowlist, path-separator rejection, canonicalization, or containment check is applied ...[truncated 1966 chars]- Remediation
View remediation
