Back to skill

Security audit

stock-valuation

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent stock valuation lookup; its main risks are a disclosed shared API token and broad finance triggers.

Before installing, understand that stock codes you query are sent to tz.smxqx.tech and authenticated with either your STOCK_VALUATION_AUTH token or the bundled shared public token. Prefer using your own scoped token if required, and treat the valuation output as informational rather than investment advice.

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

Warning
Location
scripts/query_valuation.py:22
Finding

Hardcoded Shared API Authentication Token

Content
View full analysis

Vulnerability Details

File Location: scripts/query_valuation.py, lines 22–26
Vulnerability Type: Hardcoded reusable credential
Risk Level: Medium

Vulnerable Code

python
# Prefer the environment variable, but fall back to an embedded public token
AUTH_TOKEN = os.environ.get(
    "STOCK_VALUATION_AUTH",
    "b0a590b5-6371-4665-b041-0b97cc553f6d"
)

The token is subsequently sent in the authentication header at lines 121–125:

python
headers = {
    "Content-Type": "application/json",
    "v": API_VERSION,
    "auth": AUTH_TOKEN,
}

Technical Analysis

A reusable API authentication token is embedded directly in the distributed source code. When STOCK_VALUATION_AUTH is absent, the application silently authenticates requests with this shared token.

Because source packages are available to every Skill user, the credential cannot be treated as secret. An attacker does not need to execute the Skill or compromise its runtime environment; reading the source is sufficient to recover the token. The documented API endpoint and authentication header format also make direct reuse straightforward.

The documentation explicitly confirms that the fallback is intentional in SKILL.md, lines 84–86. Describing it as a public token does not eliminate the security risk if it authorizes API operations, consumes a shared quota, or identifies requests as originating from a trusted shared principal.

Attack Path

  1. Download or inspect the Skill package.
  2. Open scripts/query_valuation.py.
  3. Extract the hardcoded fallback token.
  4. Obtain the API endpoint from the same script or references/api_fields.md.
  5. Send direct POST requests to the endpoint with the recovered value in the auth header.
  6. Consume the shared quota, automate bulk requests, or otherwise abuse access granted to the shared API identity until the token is revoked or rate-limited.

Impact Assessment

The attacker gains the API access and quota associated with th ...[truncated 539 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the hardcoded fallback token from the source code.
  2. Require STOCK_VALUATION_AUTH to be supplied through a secure runtime secret mechanism.
  3. Fail safely with a clear configuration error when the environment variable is absent.
  4. Revoke and rotate the exposed token because it must be considered compromised after distribution.
  5. Issue separate, scoped credentials per user or installation rather than sharing one identity.
  6. Apply server-side least privilege, request quotas, rate limits, expiration, and credential revocation controls.
  7. Prevent credentials from entering source control by using secret scanning and pre-commit or CI checks.
  8. Avoid printing authentication values in errors or logs.

A safer configuration pattern is:

python
AUTH_TOKEN = os.environ.get("STOCK_VALUATION_AUTH")
if not AUTH_TOKEN:
    raise RuntimeError(
        "STOCK_VALUATION_AUTH must be configured before querying the API"
    )
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (11)

Tainted flow: 'req' from os.environ.get (line 126, 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/query_valuation.py (reported line 133)May include surrounding context.

python
method="POST",
    )
    try:
        with urllib.request.urlopen(req, timeout=TIMEOUT) as resp:
            raw = resp.read().decode("utf-8")
            return json.loads(raw)
    except urllib.error.HTTPError as e:

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 · README.md (reported line 20)May include surrounding context.

2. 配置环境变量(可选)

bash
cp .env.example .env
# 编辑 .env,填入你的 API Token(如不填则使用公共 Token)

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The trigger list contains generic finance phrases such as 'valuation', '市盈率', '市净率', '安全边际', '低估', and '高估' that are likely to appear in ordinary market discussion. This can cause unintended skill invocation and unnecessary transmission of user-provided stock-related text to the external network endpoint, creating privacy, routing, and prompt-confusion risks even though the skill is not directly code-executing.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script description and all user-facing messages are written in Chinese, which imposes a specific language on users without any opt-in or alternative locale support. Under the language/locale policy, this is a natural-language policy concern unless the locale restriction is explicitly justified.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script embeds a fallback API authentication token in source code, which exposes a reusable credential to anyone who can read the skill. Hardcoded secrets are easily copied, reused outside intended controls, and are difficult to rotate safely once distributed.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The README presents usage instructions, examples, and warnings entirely in Chinese, which effectively forces a specific language for users of the skill. The policy allows locale constraints only when they are optional or clearly justified; while the market scope is China/Hong Kong stocks, the file does not explicitly state that Chinese-only operation is a required regional constraint or offer alternatives.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The natural-language content of the skill is presented entirely in Chinese, including the description, trigger examples, and usage guidance, with no indication that the user can choose another language. This can amount to a language policy issue if the organization expects skills not to force a specific language without explicit opt-in or documented regional justification.

Content

No source excerpt is available for this finding.

Overly Broad Trigger

Low
Category
Trigger Abuse
Confidence
95% confidence
Finding

The single-word trigger '低估' is overly short and context-free, making accidental matches likely in normal financial conversations. In this skill, an unintended match could invoke external valuation queries and produce irrelevant responses or send surrounding stock discussion to the configured service without a clear user request.

Content

No source excerpt is available for this finding.

Overly Broad Trigger

Low
Category
Trigger Abuse
Confidence
95% confidence
Finding

The single-word trigger '高估' is similarly too broad and can match ordinary commentary rather than an intentional tool invocation. Because the skill has network permission to a remote host, even low-friction accidental activation increases the chance of unnecessary outbound requests and user confusion.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

This markdown file uses only Chinese for headings, field descriptions, and notes, which can constitute a language/locale policy issue when no user opt-in or justification is provided. The policy specifically calls for flagging content that forces a specific language without offering a choice.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

This code performs a network request to a third-party endpoint using the supplied stock code, but the runtime behavior does not visibly inform the user that their query will be transmitted off-system. For code files, external data transmission should have some form of user disclosure unless the warning is otherwise clearly provided.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.