T09 · Insecure Skill Coding Practices
- Location
scripts/research.py:20- Finding
Generated reports may be sent to a hard-coded Feishu recipient
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This stock-research skill is mostly purpose-aligned, but it can automatically send reports to Feishu using a hard-coded default recipient and includes a realistic secret-like credential in its documentation.
Review before installing. Remove the hard-coded Feishu recipient, make Feishu delivery opt-in with an explicitly configured recipient, rotate or remove the published secret-like value, pin dependencies, and run the skill in an isolated non-root environment with output paths restricted to the workspace.
scripts/research.py:20Generated reports may be sent to a hard-coded Feishu recipient
SKILL.md:37Credential-like Feishu application secret is published in documentation
requirements.txt:1Dependencies are not reproducibly pinned or integrity verified
Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.
def get_feishu_token():
import requests
url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
r = requests.post(url, json={"app_id": FEISHU_APP_ID, "app_secret": FEISHU_APP_SECRET}, timeout=10)
return r.json().get("tenant_access_token", "")
# ============ 数据获取 ============
The script transmits the generated research summary and a recipient open_id to Feishu as an automatic side effect, which expands the skill from local analysis into outbound messaging. In this skill context, that is risky because user-requested stock research does not imply consent to send analysis results to a hardcoded or environment-controlled third-party recipient.
"""推送飞书"""
import requests
url = "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id"
r = requests.post(url,
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
json={"receive_id": USER_OPEN_ID, "msg_type": "text", "content": json.dumps({"text": msg})},
timeout=10)
The documentation includes a real-looking Feishu App Secret example, which may be mistaken for an actual credential and copied into deployments, logs, or prompts. Even if it is only an example, publishing credential-shaped secrets normalizes unsafe handling and can lead to accidental exposure or misuse of real secrets.
Referenced artifact was not completely inspected
python3 scripts/research.py <股票代码>
The skill documentation describes capabilities that access environment variables, write files, and make network requests, but it does not declare any explicit tool scope or permission boundaries. This increases the risk of over-privileged execution and makes it harder to enforce least privilege, especially because the skill also sends results externally and reads credentials from the environment.
The trigger conditions include broad natural-language phrases like analyzing a stock or researching a company, which can cause the skill to activate unintentionally in normal conversation. In this skill's context, accidental invocation is more dangerous because activation may initiate network collection, file output, and Feishu transmission without a clearly confirmed user intent for those actions.
The skill description discusses report generation and Feishu push behavior but does not clearly warn that analysis results may be transmitted to an external service. This creates a privacy and data-handling risk because users may not realize their requests, generated reports, or potentially sensitive research context will be sent off-platform.
The docstring states the output is a JSON research report for downstream summarization, but the code also transmits the summary to Feishu. This undocumented external sharing is dangerous because it obscures data egress from reviewers and users, reducing informed consent and making sensitive-output handling harder to assess.
The module docstring describes the skill entirely as an A-share financial research script in Chinese and specifies Chinese-language inputs/outputs, with no indication that users may choose another language. This is a natural-language locale policy issue because the file presents a fixed language experience without opt-in or a documented justification for the constraint.
The skill is presented as a financial research tool, but it also includes an undeclared outbound notification capability to Feishu. This mismatch matters because users and operators may authorize the skill expecting analysis only, while the code can disseminate report content externally.
LOG_FILE is taken directly from an environment variable and used for append writes without path validation. If an attacker can influence the runtime environment, they may redirect logs to sensitive or unexpected filesystem locations, potentially overwriting files, polluting system paths, or exposing data through unsafe log placement.
ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
line = f"[{ts}] {msg}"
print(line)
with open(LOG_FILE, "a", encoding="utf-8") as f:
f.write(line + "\n")
# ============ 飞书Token ============
Outbound Feishu messaging is not necessary to perform stock research and introduces avoidable data egress. In the context of an analysis skill, this increases risk because report contents can be sent to an external service without being essential to the core function.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
def get_feishu_token():
import requests
url = "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal"
r = requests.post(url, json={"app_id": FEISHU_APP_ID, "app_secret": FEISHU_APP_SECRET}, timeout=10)
return r.json().get("tenant_access_token", "")
# ============ 数据获取 ============
OUTPUT_FILE is environment-controlled and used directly for file creation/writing, allowing arbitrary file write within the privileges of the process. In an agent environment, that can be abused to clobber other workspace files, overwrite configuration, or place sensitive report data into attacker-chosen locations.
def save_json(code, data):
"""保存JSON"""
with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
json.dump({
"code": code,
"timestamp": datetime.now().isoformat(),
This external transmission sends generated report content to Feishu, creating third-party data egress beyond the core analysis function. In a stock-research skill, such automatic transmission is more dangerous because users may supply proprietary watchlists or analysis targets without expecting external redistribution.
"""推送飞书"""
import requests
url = "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id"
r = requests.post(url,
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
json={"receive_id": USER_OPEN_ID, "msg_type": "text", "content": json.dumps({"text": msg})},
timeout=10)
The dependency is specified with a lower bound only, which allows future unreviewed versions to be installed and makes builds non-reproducible. In a financial-research skill that may fetch external market data, this increases supply-chain risk because behavior and security posture can change across installations.
akshare>=1.10.0
requests>=2.28.0
pandas>=1.5.0
numpy>=1.23.0
Using requests>=2.28.0 permits installation of many different versions, including potentially vulnerable or behavior-changing releases, and prevents reproducible environments. Because this skill likely performs network access for stock research, an unsafe or unexpected requests version can increase exposure to known HTTP/client-side issues.
akshare>=1.10.0
requests>=2.28.0
pandas>=1.5.0
numpy>=1.23.0
The manifest references requests without an exact version, so it is impossible to verify from this file whether deployment will use a release affected by known advisories. In a skill that likely makes outbound HTTP requests, lack of version certainty increases the chance of silently inheriting a vulnerable client library.
The pandas dependency is unpinned, so deployments may resolve to different versions over time, including versions with security or deserialization-related issues. This is mainly a supply-chain and reproducibility weakness rather than an immediate exploit by itself.
akshare>=1.10.0
requests>=2.28.0
pandas>=1.5.0
numpy>=1.23.0
Because pandas is not pinned, the file does not demonstrate whether the installed version avoids known advisories. The risk in this skill context is limited but real: data-processing libraries can become attack surfaces when handling untrusted files or serialized content.
An unpinned numpy requirement allows arbitrary newer versions within dependency resolution, which can introduce known vulnerabilities, ABI issues, or unexpected runtime behavior. While not directly exploitable on its own, it weakens build integrity and complicates assurance of the deployed package set.
akshare>=1.10.0
requests>=2.28.0
pandas>=1.5.0
numpy>=1.23.0
The unpinned numpy dependency makes it unverifiable whether an affected version with known advisories could be installed. Although numpy is commonly used for computation rather than direct network exposure, vulnerable versions can still affect integrity or availability depending on how the library is used.
The stated purpose is on-demand A-share financial research and scoring. The implementation persists output JSON and appends logs to workspace paths, which are side effects beyond the user-facing description of analysis behavior, even though they may be useful operationally.