Back to skill

Security audit

mijia-py-api

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed Mijia smart-home controller, but users should treat it carefully because it can control physical devices and uses local account authentication.

Install only if you are comfortable letting an agent query and control your Mijia smart-home account. Prefer a virtual environment with pinned dependency versions, avoid running setup checks in logged or shared terminals, and require explicit confirmation before any scene or device state change.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (2)

T08 · Insecure Dependencies

Warning
Location
requirements.txt:4
Finding

Unpinned Third-Party Dependencies Allow Unreviewed Package Updates

Content
View full analysis
=3.0.0 pillow pycryptodome qrcode requests tzlocal ``` Related installation instruction: ```text pip install mijiaAPI ``` ### Technical Analysis The dependency specification permits installation of package versions that were not reviewed with this Skill. In particular, `mijiaAPI>=3.0.0` accepts any future release, while the other dependencies have no version constraints. None of the packages are protected by cryptographic hashes. Consequently, the code installed and imported by the Skill can change without any modification to the audited project. This creates a supply-chain risk if an upstream release is compromised, an unsafe future release is published, or package resolution is redirected to an untrusted index. The issue is especially relevant because `mijiaAPI` receives access to authenticated smart-home functions and associated local authentication material. The documentation states that version `3.0.5` is expected, but `requirements.txt` does not enforce that version. ### Attack Path 1. An attacker compromises an allowed dependency release, its publisher account, or a package index used by the victim. 2. The attacker publishes a malicious version satisfying the unconstrained requirement. 3. A user follows the documented `pip install mijiaAPI` or `pip install -r requirements.txt` instruction. 4. Package resolution selects the malicious or otherwise unreviewed release. 5. Malicious installation hooks or imported package code execute with the privileges of the user running pip or the Skill. 6. The dependency can access local files available to that user, including Mijia authentication data, and can issue device-control or network operations. ### Impact Assessment Successful exploitat ...[truncated 655 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
scripts/setup_env.py:35
Finding

Authentication File Is Fully Parsed and Account Identifier Is Written to Logs

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (20)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The documented purpose is smart-home control, but the skill also performs local environment inspection, references a concrete auth file path, and includes setup/diagnostic actions not clearly disclosed as part of normal operation. That mismatch is dangerous because agents or users may approve a home-control skill without realizing it can access local credential material or run local diagnostic commands beyond the requested device action.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill exposes shell-capable operational behavior without declaring an explicit tool scope or permission boundary. In an agent environment, this increases the chance that the skill can invoke local commands unexpectedly, reducing reviewability and allowing broader execution than users or hosts may anticipate.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill lacks a prominent general warning that it can execute commands affecting physical devices and scenes in the user's environment. In a smart-home context, insufficient warning is especially risky because actions may have safety, security, and privacy consequences, including unlocking, powering devices, or running automations unexpectedly.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The auto-trigger phrases are broad enough to match ordinary conversation about home status and devices, which can cause the skill to activate in contexts where the user did not intend device-control automation. For a skill that can affect physical devices and scenes, over-broad triggering raises the risk of unintended actions, privacy exposure through status queries, or accidental scene execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
77% confidence
Finding

The instructions state 'Require verbal confirmation' in a bilingual SOP centered on Chinese-language interaction, but they do not offer the user a choice of language or locale for confirmations. This can amount to a language/locale policy issue because the skill may implicitly force a specific interaction language without explicit opt-in.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/control_device.py (reported line 26)May include surrounding context.

python
def run_mijia(*args):
    """运行 mijiaAPI CLI 并返回输出 / Run mijiaAPI CLI and return output"""
    result = subprocess.run(
        [sys.executable, "-m", "mijiaAPI", *args],
        capture_output=True, text=True, timeout=15
    )

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/list_devices.py (reported line 19)May include surrounding context.

python
def run_mijia(*args):
    """运行 mijiaAPI CLI 并返回输出 / Run mijiaAPI CLI and return output"""
    result = subprocess.run(
        [sys.executable, "-m", "mijiaAPI", *args],
        capture_output=True, text=True, timeout=30
    )

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/setup_env.py (reported line 28)May include surrounding context.

python
all_ok = True
for pkg in REQUIRED:
    try:
        __import__(pkg)
        print(f"  ✅ {pkg} — 已安装 / installed", flush=True)
    except ImportError:
        print(f"  ❌ {pkg} — 未安装 / not installed", flush=True)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The script reads the local authentication file and prints the Mijia userId to stdout. While not a secret on the level of a token or password, it is still account-identifying information that may be exposed in terminal history, logs, CI output, screenshots, or support captures without clear user consent.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/setup_env.py (reported line 55)May include surrounding context.

python
# 4. 检查 mijiaAPI CLI 可用性
try:
    import subprocess
    r = subprocess.run([sys.executable, "-m", "mijiaAPI", "--version"],
                       capture_output=True, text=True, timeout=10)
    if r.returncode == 0:
        print(f"  ✅ mijiaAPI CLI 可用 / CLI available", flush=True)

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency 'mijiaAPI>=3.0.0' is only lower-bounded, not pinned, so any newer release may be installed without prior review. Because this appears to be the core package used to interact with smart-home devices, unexpected upstream changes or a compromised release could directly affect device control, data access, or authentication flows.

Content

Scanner excerpt · requirements.txt (reported line 4)May include surrounding context.

text
# Python 依赖 / Python Dependencies
# 安装命令 / Install: pip install -r requirements.txt

mijiaAPI>=3.0.0
pillow
pycryptodome
qrcode

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

The dependency 'pillow' is unpinned, so builds may resolve to different versions over time, including versions with known security flaws or breaking changes. In a smart-home control skill, image/QR processing libraries can handle untrusted data paths, making supply-chain drift and accidental installation of a vulnerable release a real risk.

Content

Scanner excerpt · requirements.txt (reported line 5)May include surrounding context.

text
# 安装命令 / Install: pip install -r requirements.txt

mijiaAPI>=3.0.0
pillow
pycryptodome
qrcode
requests

Unverifiable Dependency: pillow has 16 known advisory(ies) (CVE-2016-2533 (Pillow buffer overflow in ImagingPcdDecode); CVE-2023-50447 (Arbitrary Code Execution in Pillow); CVE-2021-27922 (Pillow Uncontrolled Resource Consumption) +13 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The manifest does not pin a Pillow version, and Pillow has multiple known advisories across past releases. Without a fixed version, it is impossible to verify whether deployments are using a patched release, which is especially relevant if the skill generates or parses images/QR-related content.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency 'pycryptodome' is unpinned, which makes the installed cryptography implementation nondeterministic across environments. Because this package is security-sensitive and used for cryptographic operations, inadvertently installing an affected version could expose the skill to known flaws or weaken protection of secrets.

Content

Scanner excerpt · requirements.txt (reported line 6)May include surrounding context.

text
mijiaAPI>=3.0.0
pillow
pycryptodome
qrcode
requests
tzlocal

Unverifiable Dependency: pycryptodome has 4 known advisory(ies) (CVE-2018-15560 (PyCryptodome integer overflow vulnerability); CVE-2023-52323 (PyCryptodome and pycryptodomex side-channel leakage for OAEP decryption); CVE-2018-15560 (PyCryptodome before 3.6.6 has an integer overflow in the data_len variable in AE) +1 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The manifest does not pin a PyCryptodome version even though several historical advisories exist for the package. Because cryptographic libraries are central to confidentiality and integrity, an unverifiable version state creates unacceptable uncertainty about whether known weaknesses are present.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
93% confidence
Finding

The dependency 'qrcode' is unpinned, allowing future installs to pull different releases without review. Even if the package itself is not currently highlighted here with advisories, lack of pinning increases supply-chain and stability risk for the application.

Content

Scanner excerpt · requirements.txt (reported line 7)May include surrounding context.

text
mijiaAPI>=3.0.0
pillow
pycryptodome
qrcode
requests
tzlocal

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

The dependency 'requests' is unpinned, so deployments may unexpectedly use a vulnerable or behaviorally different HTTP client version. Since this skill likely communicates with external APIs to control home devices, an affected requests release could increase exposure to credential leakage, TLS issues, or request-handling vulnerabilities.

Content

Scanner excerpt · requirements.txt (reported line 8)May include surrounding context.

text
pillow
pycryptodome
qrcode
requests
tzlocal

Unverifiable Dependency: requests has 16 known advisory(ies) (CVE-2014-1830 (Exposure of Sensitive Information to an Unauthorized Actor in Requests); CVE-2024-47081 (Requests vulnerable to .netrc credentials leak via malicious URLs); CVE-2024-35195 (Requests `Session` object does not verify requests after making first request wi) +13 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
96% confidence
Finding

The manifest does not pin a Requests version, and the package has multiple known advisories in older releases. In a networked smart-home controller, using an unverifiable HTTP client version raises the risk of credential exposure or unsafe request behavior if a vulnerable release is installed.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
91% confidence
Finding

The dependency 'tzlocal' is unpinned, which can lead to nondeterministic installs and unreviewed code changes entering production. While timezone handling is not typically high-risk by itself, unpinned dependencies still expand supply-chain risk and can cause reliability or security regressions.

Content

Scanner excerpt · requirements.txt (reported line 9)May include surrounding context.

text
pycryptodome
qrcode
requests
tzlocal

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The script hard-codes all user-facing text in a Chinese/English bilingual format and does not offer a language or locale selection. Under the stated policy, forcing a specific language or locale presentation without user opt-in can be a natural-language policy issue.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.