T09 · Insecure Skill Coding Practices
- Location
run-tool.sh:42- Finding
Arbitrary Python Code Execution Through CLI Argument Interpolation
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill largely matches its Feishu document-review purpose, but it can immediately edit/delete live documents and has an unsafe CLI wrapper that can execute crafted input as Python code.
Install only if you are comfortable giving this skill Feishu document/comment read-write access. Use a test document first, grant the Feishu app access only to documents you intend it to edit, avoid the run-tool.sh wrapper until it is fixed, and require human review before any update, deletion, reply, or resolve action.
run-tool.sh:42Arbitrary Python Code Execution Through CLI Argument Interpolation
requirements.txt:1Unpinned Dependencies Permit Unreviewed Supply-Chain Changes
This mismatch is security-relevant because the documented purpose understates materially destructive and privilege-sensitive behaviors, including deletion, comment resolution, insertion, and credentialed API access. When a skill presents itself as generic read/write review tooling but also performs state changes beyond that description, users and orchestrators may authorize it without understanding the full blast radius.
This mismatch is security-relevant because the documented purpose understates materially destructive and privilege-sensitive behaviors, including deletion, comment resolution, insertion, and credentialed API access. When a skill presents itself as generic read/write review tooling but also performs state changes beyond that description, users and orchestrators may authorize it without understanding the full blast radius.
This mismatch is security-relevant because the documented purpose understates materially destructive and privilege-sensitive behaviors, including deletion, comment resolution, insertion, and credentialed API access. When a skill presents itself as generic read/write review tooling but also performs state changes beyond that description, users and orchestrators may authorize it without understanding the full blast radius.
This mismatch is security-relevant because the documented purpose understates materially destructive and privilege-sensitive behaviors, including deletion, comment resolution, insertion, and credentialed API access. When a skill presents itself as generic read/write review tooling but also performs state changes beyond that description, users and orchestrators may authorize it without understanding the full blast radius.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
from dotenv import load_dotenv
project_root = Path(__file__).resolve().parents[1]
load_dotenv(dotenv_path=project_root / ".env")
FEISHU_APP_ID = os.getenv("FEISHU_APP_ID")
FEISHU_APP_SECRET = os.getenv("FEISHU_APP_SECRET")
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
raise ValueError(
"❌ 未找到飞书 App ID 或 Secret!\n"
"请您先前往飞书开放平台 (https://open.feishu.cn/app/) 创建一个企业自建应用。\n"
"创建后,将获取到的 App ID 和 App Secret 填入 .env 文件或作为环境变量传入。"
)
def get_tenant_access_token(self):
The presence of a tool-accessible deletion primitive that clears arbitrary document blocks creates a strong parameter-abuse risk: any caller able to influence document_id and block_id can destroy content. In an agent skill, this is more dangerous because user prompts or upstream tool orchestration may be manipulated into invoking destructive actions on unintended targets.
"""
删除块内容(通过清空内容实现)
注意:飞书 docx API 没有直接的 DELETE /blocks/{block_id} 接口。
实际做法是用 PATCH 更新块,将内容设置为空字符串。
Args:
Model output is used without validation or sanitization. Unvalidated output injected into downstream contexts (SQL, shell, HTML) enables injection attacks and arbitrary code execution.
try:
response = requests.post(url, headers=self._get_headers(), json=payload)
print(f"Insert blocks status: {response.status_code}")
print(f"Insert blocks response: {response.text[:500]}")
response.raise_for_status()
return response.json()
Logging response.text[:500] prints untrusted remote server content directly to logs/console. If the response includes sensitive metadata, document fragments, tokens in error messages, or terminal control characters, this can leak data or enable log/terminal manipulation in downstream environments.
try:
response = requests.post(url, headers=self._get_headers(), json=payload)
print(f"Insert blocks status: {response.status_code}")
print(f"Insert blocks response: {response.text[:500]}")
response.raise_for_status()
return response.json()
except Exception as e:
The document advertises capabilities to update block text and reply to comments, but does not clearly warn users that these are live write operations affecting real Feishu documents. Without an explicit warning about side effects, users or downstream agents may treat these actions like harmless reads, leading to accidental content modification, unauthorized comment responses, or destructive edits in shared documents.
The integration guide says users can simply describe a task in conversation and the agent will automatically call tools, but it does not define clear activation boundaries, confirmation requirements, or limits on when write-capable actions may run. In a skill that can edit documents and reply to comments, this broad trigger model increases the chance of unintended tool execution, prompt-induced actions from document content, or user requests being interpreted as authorization to perform irreversible changes.
The README advertises full-document Markdown export for agent context but does not warn that this may expose the entire document, including sensitive business content, to the host model or any connected LLM. In this skill's context, exporting full documents is more dangerous because the tool is specifically designed to feed document contents into an AI workflow, increasing the chance of unnecessary data disclosure beyond the minimally needed paragraph.
The README explicitly promotes remote document modification and comment reply capability, but it does not clearly warn users that an agent can change live Feishu content. In an agent-skill context, this creates a real safety risk because users may enable the skill without appreciating that model mistakes, prompt injection from document comments, or mis-targeted operations can overwrite production documents.
The skill advertises and documents network/API access plus use of environment-based credentials, but the manifest shown in SKILL.md does not declare any explicit tool scope such as permissions or allowed-tools. That creates a transparency and least-privilege problem: an agent or reviewer cannot easily tell what capabilities are intended, and overly broad runtime access could enable unintended external actions against Feishu documents.
The documentation encourages automated document reads, writes, and deletions using app credentials without warning about privacy exposure, irreversible edits, or review requirements. In a document-review skill, this context increases danger because sensitive business content may be exported, altered, or resolved automatically under an agent's control.
The CLI examples directly show destructive operations that can delete selected text or clear entire blocks, but they do not warn that these actions alter live documents and may be irreversible. This is dangerous because users or agents may copy-paste commands into production documents without understanding the scope of deletion.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
response = requests.patch(url, headers=headers, json={"is_solved": True})
response = requests.put(url, headers=headers, json={"is_solved": True}) # 返回 404
## 常见问题
The script can delete whole blocks or remove selected text and then automatically reply to and resolve the comment with no confirmation, preview, authorization gate, or dry-run step. In a document-editing skill, this creates a real integrity risk: a mistaken comment/block match, bad automation decision, or maliciously crafted invocation could silently alter or destroy document content and mark the issue as completed.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
}
}
reply_response = requests.post(reply_url, headers=headers, json=reply_payload, params=params)
reply_result = reply_response.json()
if reply_result.get('code') == 0:
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
}
}
reply_response = requests.post(reply_url, headers=headers, json=reply_payload, params=params)
reply_result = reply_response.json()
if reply_result.get('code') == 0:
The function performs state-changing remote actions by posting a reply and then resolving the comment automatically, with no confirmation gate, dry-run mode, or authorization check at the point of action. In an agent skill context, this is dangerous because an upstream prompt, wrong document token/comment ID, or automation mistake can cause unintended writes to user documents and silently mark feedback as completed.
The script exposes write-capable operations (update_block and reply_comment) that directly modify remote Feishu documents and comments without any confirmation, dry-run mode, or explicit safety interlock. In an agent setting, this increases the risk of unintended or prompt-induced changes being committed immediately to user data, especially because the tool is specifically designed for both reading and writing live documents.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
"app_secret": self.app_secret
}
try:
response = requests.post(url, json=payload)
response.raise_for_status()
data = response.json()
if data.get("code") != 0:
State-changing methods such as block updates and effective deletion are executed immediately against the remote document with no built-in confirmation, dry-run, or user warning. In an agent setting, this increases the chance of accidental or manipulated destructive edits to live documents.
The skill exposes a destructive content-removal capability via delete_block, implemented as a remote PATCH that clears a document block. The declared skill purpose is document review read/write/reply, so hidden deletion broadens the authority surface and can be abused to remove content without the user's clear expectation.