T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/tuya_controller.py:434
- Finding
- Tuya Local Device Keys Are Exposed Through Process Arguments and Command Output## Vulnerability Details **File Location**: `scripts/tuya_controller.py:434-452, 535-546`; documented usage in `SKILL.md:165-183` **Vulnerability Type**: Plaintext exposure of device-control credentials **Risk Level**: High ### Vulnerable Code ```python if args.output_format == 'json': enriched = {} for gw_id, info in devices.items(): entry = dict(info) if gw_id in cloud_map: entry['name'] = cloud_map[gw_id].get('name') entry['local_key'] = cloud_map[gw_id].get('local_key') enriched[gw_id] = entry print(json.dumps(enriched, indent=2)) return print(f"\nFound {len(devices)} local device(s):\n") for gw_id, info in devices.items(): name = cloud_map.get(gw_id, {}).get('name', gw_id) local_key = cloud_map.get(gw_id, {}).get('local_key', '') ip = info.get('ip', '?') ver = info.get('version', '?') print(f" {name}") print(f" ID: {gw_id} IP: {ip} version: {ver}" + (f" local_key: {local_key}" if local_key else "")) ``` ```python p = sub.add_parser("read_local", help="Read device status directly over LAN") p.add_argument("device_id") p.add_argument("ip") p.add_argument("local_key") p.add_argument("--version", type=float, default=3.3, help="Protocol version (default: 3.3)") p.add_argument("--output_format", choices=["json", "text"], default="json") p.set_defaults(func=cmd_read_local) p = sub.add_parser("control_local", help="Control a device directly over LAN") p.add_argument("device_id") p.add_argument("ip") p.add_argument("local_key") p.add_argument("commands", help='JSON array, e.g. \'[{"dp":1,"value":true}]\' or \'[{"code":"switch_1","value":true}]\'') p.add_argument("--version", type=float, default=3.3, help="Protocol version (default: 3.3)") p.set_defaults(func=cmd_control_local) ``` ### Technical Analysis A Tuya `local_key` is a device-control credential used to authenticat ...[truncated 1601 chars]
- Remediation
- ## Remediation Suggestions - Never include `local_key` values in standard text or JSON output. - Make enriched scan output return only non-sensitive fields such as name, device ID, IP address, and protocol version. - Obtain local keys from a protected environment variable, operating-system credential store, permission-restricted configuration file, or interactive hidden input. - Avoid placing secrets in positional or optional command-line arguments. - If credential export is indispensable, place it behind a separate explicit operation, display a strong warning, and write to a file created with owner-only permissions rather than stdout. - Redact known sensitive fields from logs, exceptions, Agent responses, and diagnostics. - Rotate any local keys that may already have appeared in shared logs or transcripts.
