T09 · Insecure Skill Coding Practices
- Location
scripts/literature_collector.py:383- Finding
Overbroad Environment and Credential Exposure to an External Zotero Tool
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill mostly does what it says, but it automatically sends reports externally and loads broad shell credentials without enough user control or disclosure.
Install only if you are comfortable with automatic writes to local report locations, ClawLib, Zotero, the knowledge graph, and an ambient Matrix messaging channel. Before regular use, disable or gate Matrix sending, avoid sourcing ~/.zshrc for secrets, restrict Zotero credentials to the minimum needed, and change arXiv API calls to HTTPS.
scripts/literature_collector.py:383Overbroad Environment and Credential Exposure to an External Zotero Tool
scripts/literature_collector.py:1262Automatic Transmission of the Full Report to an Unspecified Matrix Destination
scripts/literature_collector.py:246Plaintext HTTP Used for arXiv API Retrieval
Remote article metadata is incorporated into fact and then handed to an external script, creating a real tainted-data-to-code-boundary flow. Even without shell=True, this is dangerous because downstream tooling may log, parse, render, or execute on that content, enabling second-order injection and pollution of trusted knowledge-graph records from untrusted internet sources.
fact += f" | URL: {url}"
# 调用 kg.py add
result = subprocess.run(
["python3", KG_SCRIPT, "add",
"--entity", entity,
"--fact", fact,
The documented behavior extends beyond the declared purpose by performing additional outbound or side-effecting actions, including extra local copies and reported messaging behavior noted by analysis. Description-behavior mismatches are dangerous because users may authorize a benign-seeming reporting skill without realizing it also distributes content elsewhere, which can leak data, create unauthorized persistence, or trigger unintended communications.
Copying the full process environment and then augmenting it via a login shell effectively harvests all available environment secrets, not just the specific credentials needed. In an agent-skill context, this is more dangerous because the skill also invokes other subprocesses and external services, increasing the chance that unrelated secrets are exposed, inherited, or misused.
def _source_zshrc():
"""从 ~/.zshrc 加载环境变量,返回更新后的 env dict"""
env = os.environ.copy()
try:
result = subprocess.run(
["bash", "-l", "-c", "env"],
The script automatically sends the generated report to Matrix, an external messaging channel not clearly necessary for local report generation. This creates an undisclosed exfiltration path for collected and summarized data and widens the skill's operational scope beyond collection, summarization, and local organization.
The skill documents capabilities that imply network access, shell execution, filesystem read/write, and environment access, but it declares no explicit tool scope or permission boundaries. This is dangerous because a user or orchestrator cannot easily distinguish intended literature-fetching behavior from broader host access, increasing the chance of over-privileged execution and misuse if the skill or its companion scripts are modified or abused.
The description explicitly states '中文格式报告输出', making Chinese output a default requirement. Because the file does not offer a language choice or explain a necessary region-specific constraint, this is a natural-language locale policy violation under the stated rules.
The skill advertises automatic synchronization to multiple external systems, including Zotero and a knowledge graph, without a prominent warning or consent gate for those side effects. This is dangerous because generated reports and metadata may be propagated outside the local workspace automatically, causing unintended disclosure, difficult-to-reverse writes, and broader data distribution than the user expected.
Automatically loading credentials from ~/.zshrc expands the trust boundary from the skill into a user's general shell configuration, which may contain unrelated secrets and shell logic. This is risky because it encourages broad secret exposure and can accidentally ingest or rely on sensitive environment data unrelated to Zotero, especially when combined with shell-capable execution.
The file is written as a normative standard in Chinese and describes the classification system without indicating that other languages are supported or that Chinese is optional. Under the stated policy, forcing a specific language without user opt-in is a natural-language locale violation.
The workflow specifies that summaries must be generated in a Chinese format ("100-250 字中文格式总结"). This is a natural-language locale constraint presented as mandatory behavior, and the document does not offer the user a language choice or explain a justified region-specific requirement.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"""从 bioRxiv 获取摘要"""
try:
# bioRxiv API
api_url = f"https://api.biorxiv.org/details/{doi}"
response = requests.get(api_url, timeout=15)
response.raise_for_status()
data = response.json()
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"""从 bioRxiv 获取摘要"""
try:
# bioRxiv API
api_url = f"https://api.biorxiv.org/details/{doi}"
response = requests.get(api_url, timeout=15)
response.raise_for_status()
data = response.json()
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"""从 bioRxiv 获取摘要"""
try:
# bioRxiv API
api_url = f"https://api.biorxiv.org/details/{doi}"
response = requests.get(api_url, timeout=15)
response.raise_for_status()
data = response.json()
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"""从 bioRxiv 获取摘要"""
try:
# bioRxiv API
api_url = f"https://api.biorxiv.org/details/{doi}"
response = requests.get(api_url, timeout=15)
response.raise_for_status()
data = response.json()
The docstring states that summaries are generated '始终使用中文格式' and the implementation is built around converting output into Chinese-formatted summaries. This is a language policy issue because it forces a specific language without offering user choice or documenting a justified locale restriction.
The skill loads a broad shell-derived environment and harvests credentials/API settings unrelated to minimal literature collection. This increases exposure of sensitive tokens and expands the capability scope of the skill, especially since the imported environment is then reused for subprocesses and network-connected integrations.
The code launches a full login shell (bash -l -c env) to import environment variables from the user's shell startup files. This executes arbitrary commands embedded in .bash_profile, .profile, or related login-shell initialization, which broadens the trust boundary from this script to all shell config code and can unintentionally trigger attacker-controlled code if those files are modified.
"""从 ~/.zshrc 加载环境变量,返回更新后的 env dict"""
env = os.environ.copy()
try:
result = subprocess.run(
["bash", "-l", "-c", "env"],
capture_output=True, text=True, timeout=10
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
if ZOTERO_GROUP_ID:
env["ZOTERO_GROUP_ID"] = ZOTERO_GROUP_ID
result = subprocess.run(
["python3", ZOTERO_SCRIPT, "collections", "--json"],
capture_output=True, text=True, timeout=30, env=env
)
The script passes article-derived network content (fact, built from title/authors/journal/url fetched remotely) into another executable script via command-line arguments. Although subprocess.run is used without a shell, this still crosses a trust boundary: if kg.py interprets argument values unsafely, malicious article metadata can trigger downstream command/markup injection, data corruption, or persistence in the knowledge graph.
fact += f" | URL: {url}"
# 调用 kg.py add
result = subprocess.run(
["python3", KG_SCRIPT, "add",
"--entity", entity,
"--fact", fact,
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
query = quote(f"((cat:q-bio OR cat:cs.AI OR cat:cs.LG) AND (machine learning OR deep learning OR bioinformatics OR metagenomics)) AND {submitted_date_filter}")
url = f"http://export.arxiv.org/api/query?search_query={query}&start=0&max_results={max_results}&sortBy=submittedDate&sortOrder=descending"
response = requests.get(url, timeout=30)
response.raise_for_status()
root = ET.fromstring(response.text)
The script writes and overwrites files in workspace directories, including a latest.md file and copied report artifacts, without confirmation or dry-run safeguards. In this skill context the paths are fixed rather than attacker-controlled, so the issue is more about unsafe side effects and accidental data loss than arbitrary file write exploitation.
The skill transmits collected article data to Matrix automatically without an explicit prompt or just-in-time disclosure. While the data is mostly public literature content, the generated editorial summary and selection may still reflect user interests or internal workflow, making silent external transmission a real privacy and policy concern.