T09 · Insecure Skill Coding Practices
- Location
device_image_analysis.py:272- Finding
Path Traversal Through Unvalidated Device Identifier
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill appears to perform its stated Dahua camera snapshot and AI analysis function, but it handles surveillance images and cloud credentials with several under-scoped safety issues users should review before installing.
Review before installing. Use this only for cameras and scenes you are authorized to capture and send to Dahua Cloud. Use least-privilege Dahua credentials, do not print or share DAHUA_CLOUD_SK, rotate the key if it was exposed in logs or screenshots, and avoid persistent plaintext shell startup storage. Run the skill from a restricted working directory or dedicated account, treat captured_images as sensitive, and prefer fixes that validate device IDs, restrict downloaded URLs, reduce logging, add retention controls, and pin dependencies.
device_image_analysis.py:272Path Traversal Through Unvalidated Device Identifier
device_image_analysis.py:229Server-Side Request Forgery Through Unvalidated Snapshot URL
device_image_analysis.py:418Sensitive Snapshot URLs, Prompts, and Analysis Results Exposed in Logs
README.md:192Documentation Instructs Users to Print the Dahua Secret Key
requirements.txt:1Unbounded Dependency Version Prevents Reproducible Installation
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
# Print request info
print(f' Request Payload: {json.dumps(payload_img, ensure_ascii=False)}')
response = requests.post(
f'{base_url.rstrip("/")}{API_AI_ANALYSIS}',
headers=headers_img,
json=payload_img,
The README instructs users to append cloud credentials directly into ~/.bashrc, creating long-lived plaintext secret persistence on disk and automatic loading into future shells. In the context of a skill that accesses surveillance-device imagery and cloud APIs, credential compromise could enable unauthorized device access, image capture, or downstream cloud API abuse.
安全警告*: 将凭证写入 ~/.bashrc 会将敏感信息以明文形式持久化存储在磁盘上。建议:
- 优先使用临时环境变量(方式 3)进行测试
- 如需永久设置,确保
~/.bashrc文件权限为 600 (chmod 600 ~/.bashrc)- 定期轮换凭证
- 不要在共享系统或多用户环境中使用此方法
添加到启动文件:
echo "export DAHUA_CLOUD_PRODUCT_ID='你的 AppID'" >> ~/.bashrc
echo "export DAHUA_CLOUD_AK='你的 AccessKey'" >> ~/.bashrc
echo "export DAHUA_CLOUD_SK='你的 SecretKey'" >> ~/.bashrc
source ~/.bashrc
验证是否生效:
echo $DAHUA_CLOUD_PRODUCT_ID
echo $DAHUA_CLOUD_AK
echo $DAHUA_CLOUD_SK
┌─────────────┐
│ 1. 获取 Cloud Token │
│ (AppAccessToken) │
└──────┬──────┘
▼
┌─────────────┐
│ 2. 设备抓图
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
current_time = int(time.time())
if not self.access_token or current_time > self.token_expiry:
if not self.get_app_access_token():
return {'success': False, 'message': 'Failed to get access token'}
step_label = "[Step 2-Retry]" if is_retry else "\n[Step 2]"
print(f"{step_label} Capturing snapshot")
The FAQ tells users to print credential-bearing environment variables, including the secret key, directly to the terminal. While this is framed as troubleshooting, it can expose secrets to shoulder surfing, screen recording, terminal logging, CI logs, or support screenshots, making credential compromise more likely.
This section explicitly recommends listing all Dahua-related environment variables and printing AK/SK values during testing. In the context of an IoT/cloud integration skill, these credentials likely grant access to cloud APIs or device data, so exposing them during diagnostics can lead to unauthorized access if terminals, logs, or shared sessions are observed.
The README explicitly describes capturing images from IoT surveillance devices and sending them to a cloud AI analysis API, but it does not clearly warn users about privacy, consent, data handling, retention, or cross-boundary transfer risks. In a surveillance/image-analysis skill, this omission is materially important because users may process personal or sensitive visual data without understanding legal or organizational obligations.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
> ⚠️ **安全警告**: 将凭证写入 `~/.bashrc` 会将敏感信息以明文形式持久化存储在磁盘上。建议:
> - 优先使用临时环境变量(方式 3)进行测试
> - 如需永久设置,确保 `~/.bashrc` 文件权限为 600 (`chmod 600 ~/.bashrc`)
> - 定期轮换凭证
> - 不要在共享系统或多用户环境中使用此方法
The skill documents and requires sensitive environment variables and clearly performs outbound network operations, but it does not declare an explicit tool scope such as permissions or allowed-tools. This creates a capability transparency gap: an agent or user may invoke the skill without understanding that it can access secrets and send data externally, increasing the risk of unintended credential use or exfiltration.
The skill description, setup steps, examples, and operational guidance are presented only in Chinese, which effectively forces a specific language for users. Under the policy, language constraints should either be optional for the user or clearly documented as a justified locale-specific limitation.
The skill sends the captured image URL and user prompt to Dahua cloud AI services without an explicit privacy warning or consent flow. In the context of monitoring images, that can expose sensitive visual data and operational details to third-party processing in a way users may not expect.
The skill saves surveillance snapshots to local disk under captured_images/<device_id>/ without any retention controls, encryption, or explicit disclosure in the described behavior. These images may contain sensitive physical-security or personal data, so local persistence increases exposure through later unauthorized access, backup propagation, or accidental sharing.
The code writes captured camera images to disk without warning the user beforehand. Because the skill handles surveillance imagery, silent persistence can violate user expectations, internal policy, or privacy requirements, and increases the chance that sensitive images remain accessible after the analysis task is complete.
Nearly all user-facing instructions, prompts, examples, and returned-content examples are presented only in Chinese, which effectively imposes a language requirement. The document does not state that the skill is China-region-specific or offer users an English or selectable language option.
The manifest describes recognizable scenarios such as people, vehicles, helmets, masks, smoke, fire, falls, and intrusion detection. The implementation simply forwards any user-supplied prompt to the cloud AI imageAnalysis endpoint, making the skill behavior more open-ended than the advertised task-specific analysis scope.
The dependency is specified as requests>=2.31.0, which allows any newer release to be installed without ensuring reproducibility or review. In a security-sensitive skill that interacts with IoT devices and cloud services, this can lead to unexpected upgrades, supply-chain risk, or accidental inclusion of vulnerable/breaking versions.
requests>=2.31.0
Because requests is not pinned, it is impossible to verify from this manifest whether deployment will use a version affected by known advisories. Given this skill processes images from IoT/security devices and may communicate with remote services, using an indeterminate version of a library with multiple historical CVEs increases supply-chain uncertainty and could expose credentials, network traffic, or service behavior if a vulnerable release is resolved.
No suspicious patterns detected.