T09 · Insecure Skill Coding Practices
- Location
scripts/run.sh:11- Finding
User-Controlled Report Title Enables Python Code Injection
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly matches its patent-reporting purpose, but it handles API keys and generated content in ways that create real review-worthy security risk.
Install only after reviewing and preferably fixing the credential flow, dependency installation, title sanitization, endpoint allowlisting, and HTML escaping. Use a dedicated low-privilege API key, avoid sharing credentials with other skills, and treat generated HTML reports as untrusted until escaping is corrected.
scripts/run.sh:11User-Controlled Report Title Enables Python Code Injection
scripts/config.py:12Configurable API Base URLs Can Exfiltrate Bearer Credentials
scripts/render_html.py:465Generated Reports Permit Stored HTML and JavaScript Injection
scripts/run.sh:27Unpinned Dependencies Are Downloaded and Executed at Runtime
Handling authentication tokens and credentials for external services without disclosing that behavior is security-relevant, especially when the claimed user-visible functionality is unrelated or incomplete. Undeclared credential processing expands the attack surface and may result in secret leakage, unintended retention, or trust abuse.
Handling authentication tokens and credentials for external services without disclosing that behavior is security-relevant, especially when the claimed user-visible functionality is unrelated or incomplete. Undeclared credential processing expands the attack surface and may result in secret leakage, unintended retention, or trust abuse.
Handling authentication tokens and credentials for external services without disclosing that behavior is security-relevant, especially when the claimed user-visible functionality is unrelated or incomplete. Undeclared credential processing expands the attack surface and may result in secret leakage, unintended retention, or trust abuse.
Handling authentication tokens and credentials for external services without disclosing that behavior is security-relevant, especially when the claimed user-visible functionality is unrelated or incomplete. Undeclared credential processing expands the attack surface and may result in secret leakage, unintended retention, or trust abuse.
The skill explicitly instructs the agent to solicit a user's API key via natural-language conversation and save it to a local .env file. This is dangerous because chat is not an appropriate secret-entry channel, plaintext local storage is easy to leak, and the credential may later be accessed by other tools, logs, or users on the same system.
Referenced artifact was not completely inspected
bash scripts/run.sh "<检索式>" "<报告标题>" [数量]
Referenced artifact was not completely inspected
bash scripts/run.sh "<检索式>" "<报告标题>" [数量]
Referenced artifact was not completely inspected
bash scripts/run.sh "<检索式>" "<报告标题>" [数量]
The skill enumerates and loads .env files from local paths including another skill's directory, which is a form of credential access beyond its own configuration scope. In an agent ecosystem, this is particularly dangerous because it enables unauthorized reuse of secrets across skills and can expose API keys to code that the user did not intend to trust with those credentials.
# 优先加载本目录的 .env,其次加载 patsnap_skill 的 .env(共享凭证)
_here = Path(__file__).parent
for _env in [_here / ".env", _here.parent / ".env", Path.home() / "Documents" / "patsnap_skill" / ".env", Path.home() / "Documents" / "patsnap_skill" / "scripts" / ".env"]:
if _env.exists():
load_dotenv(_env)
break
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
break
PATSNAP_BASE_URL = os.getenv("PATSNAP_BASE_URL", "https://connect.zhihuiya.com")
PATSNAP_API_KEY = os.getenv("PATSNAP_API_KEY", "") # 从 scripts/.env 读取,首次使用需配置
LITERATURE_API_KEY = os.getenv("LITERATURE_API_KEY", PATSNAP_API_KEY)
ARK_API_KEY = os.getenv("ARK_API_KEY", "")
ARK_BASE_URL = os.getenv("ARK_BASE_URL", "https://ark.cn-beijing.volces.com/api/v3")
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# 检测 API Key 是否已配置
if not _cfg.PATSNAP_API_KEY:
env_path = Path(__file__).parent / ".env"
print("[配置] 未检测到智慧芽 API Key。", file=sys.stderr)
print("[配置] 请前往 https://connect.zhihuiya.com 获取 API Key(格式:sk-xxx)", file=sys.stderr)
print(f"[配置] 然后将以下内容写入 {env_path}:", file=sys.stderr)
The skill document describes capabilities to read/write local files, access environment configuration, and call external services, but it does not declare any explicit tool scope or permission boundaries. In an agent setting, missing scope declarations increases the chance of overbroad tool access and makes it harder for users or the platform to reason about what the skill may do.
The description and operating instructions are presented exclusively in Chinese, including trigger conditions and user interaction text. This can violate language/locale policy when the skill forces a specific language without explicitly offering the user a choice or documenting a justified locale restriction.
The manifest presents a reporting skill, but the instructions also direct the agent to collect and persist the user's API key in a local .env file. That is a sensitive-data handling behavior not implied by the core description, and it increases the risk of credential exposure through local file access, backups, logs, or later reuse by other processes.
Conflicting instructions about using a local .env API key versus an external MCP authorization model create ambiguity about which trust boundary applies and where credentials should be stored. Ambiguous auth paths often lead to insecure fallback behavior, user confusion, and accidental exposure of secrets to the wrong component.
The report contains a large journal-literature section and AI-generated literature synthesis that goes beyond the declared function of patent-database competitor patent analysis. This scope expansion can cause unintended data retrieval, processing, and disclosure pathways, especially if users expect the skill to stay confined to patent results and internal competitive-intelligence constraints.
The literature summary is semantically off-target for a dump-truck competitor patent report, including unrelated topics such as elderly web assistance, public figures, and geophysics. This indicates poor query scoping or uncontrolled retrieval/aggregation behavior, which is dangerous because it can mislead decision-making, contaminate intelligence outputs, and mask whether the agent is using approved sources for its stated purpose.
The report goes beyond the declared scope of competitor patent analysis by pulling in broad journal literature and generating AI summaries over that material. This creates scope creep that can expose users to irrelevant or unvetted external content, increase hallucination risk, and potentially cause unauthorized data processing beyond what the skill description leads users to expect.
The document appears to expand a dump-truck patent query into loosely matching terms such as 'tipper', 'dump', and unrelated literature entries, which undermines query fidelity and can produce misleading competitor intelligence. In a business-analysis skill, this is dangerous because users may rely on contaminated results for strategic decisions while assuming the output accurately reflects the original patent search intent.
The code searches for and loads a .env file from a different skill directory under the user's home folder, effectively allowing this skill to consume credentials intended for another project. That creates cross-skill secret leakage and trust-boundary violation: if the other directory exists, this skill can silently inherit API keys without explicit user consent or isolation.
The file includes Chinese-language comments and defaults to China-specific service domains such as connect.zhihuiya.com and cn-beijing.volces.com, suggesting a fixed language/locale context. There is no visible user choice, opt-in, or documented justification that this skill is intended only for a Chinese-region deployment.
The file-level description and multiple API calls indicate the skill is designed to operate in Chinese only, and the code hard-codes lang: "cn" for fetched patent data. Because there is no user opt-in or language selection mechanism, this is a natural-language locale policy issue under the rule for forced language constraints.
The manifest description limits the skill to querying a patent database from a PatSnap search expression and generating a competitor patent analysis report. However, the code imports literature-retrieval and literature-AI-summary helpers and later appends a journal literature section to the report, expanding the behavior beyond patent analysis into broader literature analysis.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"collapse_type": "DOCDB",
"collapse_order": "LATEST",
}
resp = requests.post(url, json=payload, headers=_auth_headers(), timeout=30)
resp.raise_for_status()
return resp.json().get("data", {}).get("results", [])
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
def fetch_one(pid):
try:
resp = requests.get(url, params={"patent_id": pid, "lang": "cn"},
headers=_auth_headers(), timeout=20)
resp.raise_for_status()
item = resp.json().get("data") or {}