T09 · Insecure Skill Coding Practices
- Location
scripts/cloud_cli.py:12- Finding
Unrestricted Local File Reading and Transmission to a Network Service
- Content
View full analysis
str: """CLI argument: read an existing file path, or otherwise treat it as raw text.""" raw = (value or "").strip() if not raw: return "" path = Path(raw) if path.is_file(): return path.read_text(encoding="utf-8") return raw ``` The resulting file content is added directly to the request payload: ```python if args.sales_data: payload["sales_data"] = read_text_arg(args.sales_data) if args.current_stock: payload["current_stock"] = read_text_arg(args.current_stock) if args.inventory_data: payload["inventory_data"] = read_text_arg(args.inventory_data) ``` The complete payload is then transmitted: ```python root = base_url or os.getenv("TOKENAPI_BASE_URL", "") url = skill_run_url(root, skill_id) try: resp = _post_json(url, api_key=key, body=payload, timeout=timeout) ``` ### Technical Analysis The file-argument helper interprets every existing path as a text file without enforcing: - An approved workspace or input directory - Expected file extensions or content types - CSV schema validation - File-size limits - Rejection of path traversal or sensitive operating-system locations - Explicit user confirmation before upload Consequently, the process can read any UTF-8-compatible file accessible to its operating-system account. The inventory workflow only requires access to seller-selected sales and inventory files, so unrestricted access to unrelated local files exceeds the minimum privilege necessary for the declared functionality. The loaded content is inserted into fields such as `sales_data`, `current_stock`, or `inventory_data` and transmitted to the configured API. A ...[truncated 1711 chars]- Remediation
View remediation
