T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/control4_cli.py:248
- Finding
- Overbroad Generic Method Invocation with Incomplete Safety Enforcement## Vulnerability Details **File Location**: `scripts/control4_cli.py:248-270`; related command-line configuration at `scripts/control4_cli.py:360-366` **Vulnerability Type**: Arbitrary public API method invocation through reflection **Risk Level**: High **Affected code:** ```python async def cmd_call(args: argparse.Namespace) -> int: director = await _login_and_director() obj = _entity_factory(args.entity, director, args.id) fn = getattr(obj, args.method, None) is_sensitive = any(k in args.method.lower() for k in SENSITIVE_METHOD_KEYWORDS) if is_sensitive and not args.allow_sensitive: raise RuntimeError( "Sensitive method blocked. Re-run with --allow-sensitive if intentional." ) if not callable(fn): raise RuntimeError(f"Method not found: {args.method}") call_args = json.loads(args.args_json) if args.args_json else [] call_kwargs = json.loads(args.kwargs_json) if args.kwargs_json else {} if not isinstance(call_args, list): raise RuntimeError("--args-json must decode to a JSON array") if not isinstance(call_kwargs, dict): raise RuntimeError("--kwargs-json must decode to a JSON object") result = fn(*call_args, **call_kwargs) if inspect.isawaitable(result): result = await result ``` Related command-line exposure: ```python sp = sub.add_parser("call", help="Call any exposed method on an entity") sp.add_argument("--entity", required=True, choices=["director", "light", "relay", "climate", "blind", "room", "fan", "security-panel", "contact-sensor"]) sp.add_argument("--id", type=int) sp.add_argument("--method", required=True) sp.add_argument("--args-json", help='JSON array, e.g. "[10,1000]"') sp.add_argument("--kwargs-json", help='JSON object, e.g. "{\"LEVEL\":20}"') sp.add_argument("--allow-sensitive", action="store_true", help="Allow sensitive methods (arm/disarm/open/close/etc)") ``` ...[truncated 2596 chars]
- Remediation
- ## Remediation Suggestions 1. Remove unrestricted reflective invocation from normal Skill operation. 2. Define explicit per-entity allowlists containing only the methods required for supported use cases. 3. Separate read-only methods from mutating methods and deny all unrecognized methods by default. 4. Disable director and security-panel mutations unless an administrator explicitly enables them in local configuration. 5. Require interactive confirmation for physical-security operations, including alarm changes, locks, gates, garages, doors, and sensitive relays. 6. Do not treat a command-line flag alone as sufficient authorization. Consider a separate privileged configuration file or execution mode with restrictive file permissions. 7. Validate argument count, types, ranges, and accepted values independently for every permitted method. 8. Record security-sensitive operations in an audit log without recording passwords or bearer tokens. 9. If generic method inspection is required, retain `methods` as a read-only diagnostic command while replacing `call` with narrowly scoped commands.
