T09 · Insecure Skill Coding Practices
- Location
scripts/capabilities/execute/service.py:8- Finding
Product Mutations Can Bypass the Required Pre-Check and User Confirmation Workflow
- Content
View full analysis
dict: """ Execute the actual modification. Must only be called after before_check succeeds and the user confirms. """ if not item_id: raise ParamError("Product ID (item_id) cannot be empty") if not spi_code: raise ParamError("Operation code (spi_code) cannot be empty") if not spi_params: raise ParamError("Operation parameters (spi_params) cannot be empty") data = api_post( f"/api/{TOOL_CODE_EXECUTE}/1.0.0", { "item_id": item_id, "spi_code": spi_code, "spi_params": spi_params, }, timeout=30, ) if not isinstance(data, dict): raise ServiceError("Invalid response format; try again later") return data ``` The command entry point invokes this function directly: ```python parser.add_argument('--item_id', type=str, required=True, help='Product ID') parser.add_argument('--spi_code', type=str, required=True, help='Operation code') parser.add_argument('--spi_params', type=str, required=True, help='Operation parameters as JSON') args = parser.parse_args() try: spi_params = json.loads(args.spi_params) except json.JSONDecodeError as e: print_error(ValueError(f"spi_params is not valid JSON: {e}")) return try: result = execute_action(args.item_id, args.spi_code, spi_params) ``` ### Technical Analysis The Skill documentation requires every write operation to follow this sequence: 1. Call `before_check`. 2. Verify that the proposed operation is permitted. 3. Display the proposed mutation or agreement to the user. 4. Obtain explicit user confirmation. 5. ...[truncated 2167 chars]- Remediation
View remediation
