T09 · Insecure Skill Coding Practices
- Location
scripts/accounting.py:148- Finding
Undocumented Local JSON File Read Can Transmit File Contents to a Remote Service
- Content
View full analysis
= 3: try: raw = sys.argv[2] # Handle single-quoted JSON from shell if raw.startswith("'") and raw.endswith("'"): raw = raw[1:-1] req = json.loads(raw) except json.JSONDecodeError as e: # Try reading from file if JSON parsing fails try: with open(sys.argv[2], 'r', encoding='utf-8') as f: req = json.load(f) except: print(f"JSON parse error: {e}", file=sys.stderr) sys.exit(1) ``` File input is not documented in the Skill interface. Consequently, a command argument that appears to be invalid JSON can cause the script to read any JSON file accessible to the process. The resulting object can subsequently be transmitted to the fixed remote service through the `add` or `query` operations: ```python def cmd_add(base, token, req): if not req.get("ledgerName"): return {"error": "missing_param", "message": "ledgerName is required"} if not req.get("amount") or req["amount"] <= 0: return {"error": "invalid_param", "message": "amount must be > 0"} if not req.get("transactionType"): return {"error": "missing_param", "message": "transactionType is required (SHOURU/ZHICHU/YINGSHOU/YINGFU)"} tt = req["transactionType"].upper() if tt in ("YINGSHOU", "YINGFU") and not req.get("dueDate"): return {"error": "missing_param", "message": f"dueDate is required when transactionType={tt}"} return unwrap(request_post(base, token, "/agent/accounting/add", req)) def cmd_query(base, token ...[truncated 2085 chars]- Remediation
View remediation
