T09 · Insecure Skill Coding Practices
- Location
scripts/smart.py:25- Finding
Authentication Credentials Can Be Transmitted to Untrusted Configured Endpoints
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a real smart-home controller, but it needs review because it can operate physical devices and handles long-lived smart-home credentials with weak safeguards.
Review this before installing if the account tokens can control important devices such as locks, heaters, outlets, cameras, or appliances. Use a narrowly scoped Home Assistant account, restrict the config file to owner-only access, prefer trusted local/official HTTPS endpoints, rotate credentials if endpoint settings were ever untrusted, and avoid broad fuzzy commands until the skill adds exact matching, confirmation, and platform-specific routing.
scripts/smart.py:25Authentication Credentials Can Be Transmitted to Untrusted Configured Endpoints
scripts/smart.py:13Ambiguous Device Resolution and Unconditional Cross-Platform Fallback Can Operate Unintended Devices
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
## Getting Home Assistant Token
1. Open Home Assistant → Profile (bottom left)
2. Scroll to "Long-Lived Access Tokens"
3. Click "Create Token" and name it (e.g., "Clawdbot")
4. Copy the token immediately (it is only displayed once)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
## Getting Home Assistant Token
1. Open Home Assistant → Profile (bottom left)
2. Scroll to "Long-Lived Access Tokens"
3. Click "Create Token" and name it (e.g., "Clawdbot")
4. Copy the token immediately (it is only displayed once)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Solution: Check the HA_URL and ensure Home Assistant is running and accessible.
### Error: 401 Unauthorized (HA)
Solution: The token has expired or is invalid. Generate a new Long-Lived Access Token.
### Device Not Responding
Solutions:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
Solution: Check the HA_URL and ensure Home Assistant is running and accessible.
### Error: 401 Unauthorized (HA)
Solution: The token has expired or is invalid. Generate a new Long-Lived Access Token.
### Device Not Responding
Solutions:
The duplicated finding points to the same behavior: persistent storage of access tokens and API secrets in a local config file. Long-lived secrets stored unencrypted increase the blast radius of host compromise and make accidental disclosure through backups, screenshots, or file sharing more likely.
设置
Option 1: Config File (Recommended)
选项1:配置文件(推荐)
Create ~/.config/universal-smarthome/config.json:
创建~/.config/universal-smarthome/config.json:
{
The duplicated finding points to the same behavior: persistent storage of access tokens and API secrets in a local config file. Long-lived secrets stored unencrypted increase the blast radius of host compromise and make accidental disclosure through backups, screenshots, or file sharing more likely.
设置
Option 1: Config File (Recommended)
选项1:配置文件(推荐)
Create ~/.config/universal-smarthome/config.json:
创建~/.config/universal-smarthome/config.json:
{
The skill explicitly supports fuzzy device-name matching for power-control actions, but the documentation does not warn users that ambiguous requests like "打开灯" may affect the wrong device. In a smart-home context, unintended control of lights, appliances, or other connected devices can create safety, privacy, or property risks even without malicious code.
The script is explicitly capable of controlling smart-home devices through both Home Assistant and Tuya cloud APIs, which creates real-world impact beyond ordinary data processing. In the provided context there is no authentication, authorization, confirmation, or scope restriction around dangerous actions, so anyone able to invoke the script with valid config can trigger device state changes across local and cloud-connected systems.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
headers = {"Authorization": f"Bearer {ha['token']}"}
try:
r = requests.post(url, headers=headers, json={"entity_id": entity_id}, timeout=5)
return r.status_code == 200
except: return False
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
headers = {"Authorization": f"Bearer {ha['token']}"}
try:
r = requests.post(url, headers=headers, json={"entity_id": entity_id}, timeout=5)
return r.status_code == 200
except: return False
The Tuya control path sends device commands to a third-party cloud service without any user-facing warning, approval step, or transparency about external transmission. In a smart-home context, undisclosed cloud control is security-relevant because it can affect physical devices and expose operational metadata to an external platform.
Several printed status and error messages are only presented in Chinese, with no option for users to select another language or locale. This is a natural-language policy concern because it forces a specific language without documented justification or opt-in.
The documentation describes direct control of real smart-home appliances but does not prominently warn about the physical-world consequences of turning devices on or off. In a home-automation context, ambiguous or mistaken commands can affect locks, heaters, ovens, lights, or other devices, creating safety, privacy, or property risks.
The recommended setup stores Home Assistant and Tuya credentials persistently in a local config file under the user's home directory. While common, persistent plaintext credential storage increases exposure if the host is compromised, backups are leaked, file permissions are weak, or other local users can read the file.
Option 1: Config File (Recommended) Create ~/.config/universal-smarthome/config.json:
{
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
## Common Issues & Solutions
### Error: Missing Configuration File
Solution: Create the file ~/.config/universal-smarthome/config.json
### Error: 1004: Invalid Signature
Solution: Check your Tuya access_id and access_secret. Ensure the endpoint matches your region (cn/com/us/eu).
The file presents the skill name and operational examples primarily in Chinese, including user utterances such as "打开客厅灯" and "打开灯", but it does not state that the skill is region-specific or provide language-choice guidance. Under the policy, forcing a specific language without opt-in can be a natural-language policy issue.
The inline comment says the real implementation would fetch devices from Home Assistant and Tuya and write them into CACHE_FILE, but the actual branch merely prints a success message. This is more than an omission because the user-visible output asserts synchronization happened when no such action occurs in this file.