Back to skill

Security audit

A股台账工作流 · 选股跟踪·持仓管理·财报核验·复盘(8步投研流程)

Security checks for vulnerabilities and agentic risk

Overview

This research skill needs review because insecure connections can expose Feishu credentials and its watchdog monitors unrelated tasks.

Have certificate verification restored and restrict the watchdog to explicitly selected investment jobs before enabling integrations. Verify Feishu and email destinations, review the separate writer and mailer helpers, and limit private information sent to other AI providers. Back up ledgers, retain editable reports, avoid the /tmp/demo deletion example, and independently check financial calculations. Scanner coverage was partial; the flagged document and executable data flows were investigated, but external helpers and live service behavior remain unverified.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
.
Finding

Disabled TLS verification exposes Feishu credentials and authenticated operations

Content
View full analysis

Impact

An interceptor can capture the watchdog's application secret and obtain access tokens while that credential remains valid, or capture existing tenant access tokens from the other helpers. Stolen tokens permit operations within the application's granted Feishu permissions. Interception also permits forged folder listings and alert responses; with --apply, forged listing data can influence deletion targets.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Output HandlingUnvalidated Output Injection, Cross-Context Output, Unbounded Output
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (72)

Tainted flow: 'r' from os.environ.get (line 41, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
99% confidence
Finding

Sending a bearer token to the intended Feishu API is legitimate, but this request uses a context that disables certificate and hostname verification. A network attacker can impersonate Feishu, capture the token, and manipulate file listings used to select documents for deletion when --apply is enabled.

Content

Scanner excerpt · scripts/dedup_feishu.py (reported line 43)May include surrounding context.

python
def api(method, path):
    r = urllib.request.Request("https://open.feishu.cn/open-apis" + path,
                               headers={"Authorization": f"Bearer {T}"}, method=method)
    return json.load(urllib.request.urlopen(r, timeout=40, context=CTX))


def lst(ftok):

Tainted flow: 'req' from os.environ.get (line 122, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/sync_ledgers_to_feishu.py (reported line 127)May include surrounding context.

python
data=json.dumps({"app_id": app_id,
                             "app_secret": app_secret}).encode(),
            headers={"Content-Type": "application/json"}, method="POST")
        r = json.load(urllib.request.urlopen(req, timeout=25))
        if r.get("code") != 0:
            raise ValueError(f"code={r.get('code')} msg={r.get('msg')}")
        return r["tenant_access_token"]

Tainted flow: 'req' from os.environ.get (line 140, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/sync_ledgers_to_feishu.py (reported line 145)May include surrounding context.

python
headers={"Authorization": f"Bearer {T}",
                 "Content-Type": "application/json; charset=utf-8"}, method=method)
    try:
        r = json.load(urllib.request.urlopen(req, timeout=40))
    except urllib.error.HTTPError as e:
        return {"code": -1, "msg": f"HTTP {e.code}: {e.read().decode()[:200]}"}
    except Exception as exc:

Tainted flow: 'cmd' from urllib.request.urlopen (line 161, network input) → subprocess.run (code execution)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

External input (network, user) flows to a code execution sink. This enables remote code execution or command injection.

Content

Scanner excerpt · scripts/sync_ledgers_to_feishu.py (reported line 164)May include surrounding context.

python
cmd = ["python3", WRITER, str(src), "--doc", doc_token]
    if real_table:
        cmd.append("--real-table")
    r = subprocess.run(cmd, capture_output=True, text=True, timeout=900)
    tail = (r.stdout or r.stderr).strip().splitlines()
    return r.returncode == 0, (tail[-1] if tail else "")

Tainted flow: 'req' from os.environ.get (line 665, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
99% confidence
Finding

The claimed credential-exfiltration flow is not supported: this request sends stock codes to a market-data service. However, the request uses a context with hostname and certificate verification disabled, allowing a network attacker to forge code-to-name responses that are then cached and trusted by financial-record validation.

Content

Scanner excerpt · scripts/validate_ledgers.py (reported line 669)May include surrounding context.

python
"https://qt.gtimg.cn/q=" + q,
                headers={"User-Agent": "Mozilla/5.0",
                         "Referer": "https://gu.qq.com/"})
            raw = urllib.request.urlopen(
                req, timeout=12, context=ctx).read().decode("gbk", "replace")
        except Exception:
            continue

Tainted flow: 'r' from os.environ.get (line 224, credential/environment) → urllib.request.urlopen (network output)

Critical
Category
Data Flow
Confidence
99% confidence
Finding

Sending alerts to Feishu is expected functionality, but the shared SSL context explicitly disables certificate and hostname verification. A network intermediary could impersonate Feishu, capture the application secret during token acquisition or the bearer token during message submission, and intercept or manipulate watchdog alerts.

Content

Scanner excerpt · scripts/watchdog.py (reported line 228)May include surrounding context.

python
"https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=chat_id",
        data=json.dumps(payload, ensure_ascii=False).encode(),
        headers={"Authorization": f"Bearer {tok}", "Content-Type": "application/json; charset=utf-8"})
    resp = json.loads(urllib.request.urlopen(r, timeout=25, context=CTX).read())
    return resp

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The supplied chunk performs software packaging and public release automation, not the declared investment-research workflow. Although it could serve as a maintainer utility for that workflow, uploading a repository bundle to an external registry is a distinct, externally consequential capability absent from the description. The chunk does not demonstrate malicious intent or financial-data access; the mismatch is its undeclared publishing behavior.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

Ledger tracking is within the declared workflow, but exporting ledger content to Feishu and modifying cloud documents adds a material external-data-transfer capability beyond the stated description. This behavior is conditional on configured folders and credentials, and the destination is configuration-controlled rather than hardcoded to an unknown recipient. The script also guards direct synchronization against files in the holdings directory. Those safeguards limit the scope of uploads but do not make the cloud synchronization capability declared.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

Rendering and printing results are ordinary supporting behavior for the declared workflow. Sending those results by email introduces an external communication capability not disclosed in the description or declared permissions. The snippet does not reveal recipients, message contents, or the email function's implementation, so it does not establish malicious exfiltration.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The reported monitoring scope includes unrelated enabled Hermes jobs and can transmit their names, paths, errors, and scheduling details to Feishu. If accurate, this crosses the investment workflow's data boundary and can disclose unrelated operational information; the implementation is not included here for direct verification.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

The reports are related to the declared research workflow, but the supplied script primarily performs external cloud synchronization rather than research or local tracking. Sending local report contents to Feishu is a material data-transfer capability absent from the description and declared permissions. The configuration requirement and narrow privacy-pattern checks limit execution but do not disclose or eliminate that capability. The imported guard and API helpers are not supplied, so their additional restrictions cannot be established.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
90% confidence
Finding

Notification archiving can support the declared monitoring workflow, but external publication and remote document modification are consequential capabilities not represented in the supplied description. The code explicitly creates Feishu documents and passes content to a writer subprocess for upload. It includes safeguards that reject position-related tasks and certain sensitive financial patterns, and it attempts to extract only the final response from conversation logs. These safeguards limit exposure but do not eliminate the undeclared cloud-transfer capability. The referenced IM and email channels appear only in documentation; this chunk does not implement them.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
MCP Tool Poisoning
Confidence
86% confidence
Finding

Deduplication is related to ledger maintenance, but this script adds a consequential capability beyond ordinary tracking: deleting remote documents in Feishu. The description does not disclose cloud-document cleanup or deletion. Dry-run mode and the local index constrain execution, but do not eliminate that capability. Disabling TLS verification is an additional security concern, although it is not independently the basis for the purpose mismatch. The implementation of the imported token helper is not supplied and cannot be assessed.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
98% confidence
Finding

The full command genuinely performs unconditional recursive deletion of /tmp/demo, potentially removing unrelated user data. This is unsafe example setup rather than evidence of malicious tool-parameter injection.

Content

Scanner excerpt · examples/sample_direction/README.md (reported line 29)May include surrounding context.

验证(隔离运行,不碰你的真实数据)

bash
rm -rf /tmp/demo && mkdir -p /tmp/demo
cp -r examples/sample_direction/* /tmp/demo/
STOCK_DATA_DIR=/tmp/demo python3 scripts/validate_ledgers.py

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · examples/sample_direction/README.md (reported line 29)May include surrounding context.

验证(隔离运行,不碰你的真实数据)

bash
rm -rf /tmp/demo && mkdir -p /tmp/demo
cp -r examples/sample_direction/* /tmp/demo/
STOCK_DATA_DIR=/tmp/demo python3 scripts/validate_ledgers.py

A1 can pass without the required positive cash-flow year-over-year growth.

High
Category
Excessive Agency
Confidence
99% confidence
Finding

The cash-flow check explicitly accepts cf_yoy=None, although A1 requires positive cash-flow growth. Missing evidence can therefore produce an ALERT instead of NEED_DATA, weakening a financial screening safeguard; this script does not itself execute trades.

Content

No source excerpt is available for this finding.

Unvalidated Output Injection

High
Category
Output Handling
Confidence
95% confidence
Finding

Model output is used without validation or sanitization. Unvalidated output injected into downstream contexts (SQL, shell, HTML) enables injection attacks and arbitrary code execution.

Content

Scanner excerpt · scripts/profit_guard.py (reported line 1081)May include surrounding context.

python
or r.get("status") == "data_failed")
        if not names:
            names = "、".join(r.get("name", "") for r in result.get("results", [])) or "持仓"
        subprocess.run(["python3", MAILER, "--subject",
                        f"持仓盈利保护 {result.get('slot')} · {result.get('run_at','')[:10]} · {names} · {head}",
                        "--body-file", f],
                       capture_output=True, text=True, timeout=120)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/sync_ledgers_to_feishu.py (reported line 93)May include surrounding context.

python
"""飞书 tenant_access_token。

    🔴 凭证取不到 = 「没配置飞书」,**跳过而不报错**(原实现在这里 sys.exit 报故障,
       对没配飞书的使用者是假故障)。优先环境变量,其次 .env 文件。
    """
    app_id = os.environ.get("FEISHU_APP_ID", "").strip()
    app_secret = os.environ.get("FEISHU_APP_SECRET", "").strip()

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/sync_ledgers_to_feishu.py (reported line 98)May include surrounding context.

python
app_id = os.environ.get("FEISHU_APP_ID", "").strip()
    app_secret = os.environ.get("FEISHU_APP_SECRET", "").strip()
    if not (app_id and app_secret):
        candidates = ([pathlib.Path(_H + "/.env")] if _H else []) + \
                     [pathlib.Path(_D + "/.env")]
        for envf in candidates:
            if not envf.is_file():

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/sync_ledgers_to_feishu.py (reported line 99)May include surrounding context.

python
app_secret = os.environ.get("FEISHU_APP_SECRET", "").strip()
    if not (app_id and app_secret):
        candidates = ([pathlib.Path(_H + "/.env")] if _H else []) + \
                     [pathlib.Path(_D + "/.env")]
        for envf in candidates:
            if not envf.is_file():
                continue

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/watchdog.py (reported line 49)May include surrounding context.

python
TZ = timezone(timedelta(hours=8))
JOBS = pathlib.Path(_H + "/cron/jobs.json")
ENV = pathlib.Path(_H + "/.env")
STATE = pathlib.Path(_D + "/.watchdog_state.json")
CHAT = os.environ.get("FEISHU_CHAT_ID", "")     # 告警投递目标(未配置则只打印到 stdout)

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · tests/test_smoke.py (reported line 12)May include surrounding context.

python
def run(script: str, data_dir: Path) -> subprocess.CompletedProcess:
    env = os.environ.copy()
    env["STOCK_DATA_DIR"] = str(data_dir)
    env.pop("HERMES_HOME", None)
    return subprocess.run(

Env Variable Harvesting

High
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.

Content

Scanner excerpt · tests/test_smoke.py (reported line 48)May include surrounding context.

python
def test_init_is_idempotent_and_preserves_user_file(tmp_path):
    data_dir = tmp_path / "stock-data"
    env = os.environ.copy()
    env["STOCK_DATA_DIR"] = str(data_dir)
    script = ROOT / "init.sh"

MCP server referenced without pinned version: 'npx skills'.

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding

The installation example invokes an unpinned npm package through npx, potentially fetching and executing a changing release with the user's privileges. This is a supply-chain exposure, although the scanner incorrectly describes the CLI as an MCP server.

Content

No source excerpt is available for this finding.

MCP server referenced without pinned version: 'npx skills'.

Medium
Category
MCP Rug Pull
Confidence
90% confidence
Finding

This repeated installation command also allows npx to resolve a mutable package release and execute it locally. The risk is dependency substitution or compromise, not an unpinned MCP server.

Content

No source excerpt is available for this finding.