Back to skill

Security audit

Dahua Cloud Open IoT Basic General Kit

Security checks for vulnerabilities and agentic risk

Overview

This appears to be a real Dahua cloud device-management skill, but it needs Review because it can change or delete devices and may expose secrets through default logging and CLI usage.

Install only if you are comfortable giving the skill Dahua cloud credentials that can administer your devices. Use least-privilege credentials, avoid passing real passwords or SecretKeys on the command line, disable verbose logging for real devices, and treat delete, SD-card format, WiFi, callback, and password operations as production-impacting actions.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/dahua_iot_client.py:372
Finding

Default request logging exposes reversible device passwords and plaintext Wi-Fi credentials

Content
View full analysis
Dict[str, Any]: try: headers = self._build_headers() url = self.config['api_base_url'] + endpoint self._log(f"[API] POST {endpoint}") self._log(f"[DATA] {json.dumps(data, ensure_ascii=False)}") response = self.session.post(url, headers=headers, json=data, timeout=timeout) result = response.json() resp_preview = json.dumps(result, ensure_ascii=False) self._log(f"[RESP] {resp_preview[:200]}{'...' if len(resp_preview) > 200 else ''}") return result ``` ```python def control_device_wifi( self, device_id: str, ssid: str, bssid: Optional[str] = None, password: Optional[str] = None, link_enable: Optional[bool] = None, channel_sn: Optional[str] = None ) -> Dict[str, Any]: self._log(f"\n[WiFi] Controlling device wifi: {device_id}") data = {'deviceId': device_id, 'ssid': ssid} if bssid: data['bssid'] = bssid if password: data['password'] = password if link_enable is not None: data['linkEnable'] = link_enable if channel_sn: data['channelSn'] = channel_sn return self._request(API_CONTROL_DEVICE_WIFI, data) ``` ```python def modify_dev_code( self, device_id: str, ...[truncated 3412 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/dahua_iot_client.py:1369
Finding

Password encryption CLI prints the plaintext password and accepts secrets through command-line arguments

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/device_code_encrypt.py:21
Finding

Standalone AES helper can ignore the supplied SecretKey and derive encryption from a public constant

Content
View full analysis
bytes: """ 生成AES密钥 算法:Cut32(UpperCase(MD5-32位(UpperCase(sk)))) """ # 如果设备序列号为空,使用默认密钥 key_source = self.secret_access_key if self.device_id else self.DEFAULT_KEY # 计算MD5-32位 md5_hash = hashlib.md5(key_source.upper().encode('utf-8')).hexdigest().upper() # 截取前32位 aes_key = md5_hash[:32] return aes_key.encode('utf-8') ``` ```python def encrypt_aes256(self, device_password: str) -> str: # 生成AES密钥 aes_key = self._generate_aes_key() # 创建AES加密器(CBC模式) cipher = AES.new(aes_key, AES.MODE_CBC, self.IV) # PKCS7填充并加密 encrypted = cipher.encrypt(pad(device_password.encode('utf-8'), AES.block_size)) # Base64编码 encoded = base64.b64encode(encrypted).decode('utf-8') return encoded ``` ### Technical Analysis When `device_id` is absent, `_generate_aes_key()` ignores the supplied `secret_access_key` and instead derives the AES key from the publicly known string `DEFAULT_KEY`. Every invocation taking this path therefore uses the same reproducible key. The fixed IV makes encryption deterministic: identical passwords encrypted with the same derived key produce identical initial ciphertext patterns and, for the same complete plaintext, identical ciphertext. Because the fallback key and IV are both present in the source, an observer can reproduce the key and decrypt ciphertext produced thro ...[truncated 1235 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/sign_helper.py:127
Finding

Signing debug helpers print access tokens and authentication headers

Content
View full analysis
Dict[str, str]: timestamp = self.generate_timestamp() nonce = self.generate_nonce() str_auth_factor = self.access_key + app_access_token + timestamp + nonce sign = hmac.new( self.secret_access_key.encode('utf-8'), str_auth_factor.encode('utf-8'), hashlib.sha512 ).hexdigest().upper() headers = { 'Content-Type': 'application/json', 'Accept-Language': 'zh-CN', 'Version': 'v1', 'AccessKey': self.access_key, 'AppAccessToken': app_access_token, 'Timestamp': timestamp, 'Nonce': nonce, 'Sign': sign, 'X-TraceId-Header': self.generate_trace_id(), 'ProductID': self.product_id } if sign_type == 'simple': headers['Sign-Type'] = 'simple' return headers ``` ```python def print_auth_headers(self): """打印授权API请求头(用于调试)""" headers = self.sign_for_auth_api() print("授权API请求头:") print(json.dumps(headers, indent=2, ensure_ascii=False)) def print_business_headers(self, app_access_token: str): """打印业务API请求头(用于调试)""" headers = self.sign_for_business_api(app_access_token) print("业务API请求头:") print(json.dumps(headers, indent=2, ensure_ascii=False)) ``` ### Technical Analysis The debug methods print complete authentication header dictionaries. Business headers contain the AccessKey, AppAccessToken, timestamp, nonce, signature, and Product ID. Authentication headers similarly disclose identifying and signed authentication material. The AppAccessToken is sensitive even though the reviewed protocol also requires HMAC signatures generated with the SecretKey. A leaked token may assist a chained creden ...[truncated 1643 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (52)

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding

This is mostly aligned in domain and function: the script is clearly a Dahua Cloud IoT management client and does implement many of the described device-management capabilities. There is no evidence of unrelated or malicious behavior. However, the declared description overstates some aspects. In particular, while the SDK class contains many methods, the command-line interface only exposes a subset, so the statement that the single-file implementation 'supports CLI and SDK invocation' for the full described capability set is somewhat overstated. Also, the exact claim of '43 API interfaces' is not reliably verifiable from the supplied chunk as a precise delivered contract, and 'zero redundant configuration' is promotional rather than behaviorally grounded. So this is a mild description/behavior mismatch due to overclaiming, not because of hidden extra capabilities.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

声明描述的是一个功能完整的大华云IoT设备管理客户端,重点在于平台API集成和设备生命周期运维;而提供的代码片段仅实现“设备密码加密”,包括Base64编码和基于固定IV的AES-CBC加密封装。这不是对所宣称43个API接口的局部实现细节,而是完全不同的主功能模块。代码没有网络请求、认证流程、Token刷新、设备管理接口、回调处理或命令行参数解析,因此描述与实际行为存在明显且重大的不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

代码的实际主功能与描述存在明显偏差。描述宣称是功能完整的IoT设备管理客户端,而代码仅是scripts/sign_helper.py中的签名工具类,用于构造认证API和业务API的请求头,不执行任何真实的API请求,也不管理设备或处理IoT运维场景。虽然“API签名”可被视为该类客户端的一个支撑组件,但当前提供的代码片段本身不足以支撑所声明的主要用途,因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 203)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 206)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 209)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 212)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 215)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 218)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 601)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 611)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 773)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 776)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 779)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 782)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 783)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 854)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 857)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 860)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 1005)May include surrounding context.

md
python scripts/dahua_iot_client.py --help

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The document describes formatting a device SD card, which is an inherently destructive operation likely to erase stored recordings or other local data. There is no explicit warning in the markdown about data loss, irreversibility, or the need to back up content before use.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/dahua_iot_client.py (reported line 331)May include surrounding context.

python
def _build_headers(self) -> Dict[str, str]:
        """构建业务API请求头"""
        if not self._ensure_token():
            raise ValueError("Failed to get access token")
        
        timestamp = str(int(time.time() * 1000))
        nonce = str(uuid.uuid4())

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The credential setup instructions tell users to place product ID, access key, and secret key in environment variables, including persistent user-level storage on Windows, without warning about secret handling or local exposure risks. These secrets enable management of Dahua cloud devices, so poor storage guidance can lead to credential leakage through shell history, shared profiles, screenshots, support logs, or compromised user environments.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The quickstart includes a device deletion command as a normal example without any warning that it is destructive and may permanently deregister production devices. In an IoT device-management skill, users are likely to copy commands directly, so omission of safeguards materially increases the risk of accidental service disruption or loss of device connectivity.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The documentation says requests and responses are automatically printed, but provides no warning that logs may contain device identifiers, tokens, passwords, or other operationally sensitive data. In a cloud IoT administration client, verbose API logging can expose credentials and fleet metadata to consoles, CI logs, ticket attachments, or centralized log systems, making this especially dangerous in real deployments.

Content

No source excerpt is available for this finding.