Back to skill

Security audit

Shopee-店铺捆绑优惠

Security checks for vulnerabilities and agentic risk

Overview

This Shopee promotion skill has a coherent core purpose, but it also handles login codes, API keys, payments, credential-bearing network calls, and persistent local outputs with weak scoping.

Install only if you are comfortable letting this skill manage live Shopee Bundle Deal promotions through LinkFox and potentially guide LinkFox account setup, SMS-code login, API-key storage, and paid plan purchase flows. Avoid using agent-mediated SMS login when possible, review payment and delete/end/update actions carefully, and do not set endpoint override environment variables unless you control and trust the destination.

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 (2)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/_shopee_bundle_deal_common.py:18
Finding

Credential Exfiltration Through Unrestricted Endpoint Overrides

Content
View full analysis

Vulnerability Details

File Location: scripts/_shopee_bundle_deal_common.py:18-20, 55-88; scripts/onboarding.py:69-85, 189-222, 402-421, 454-459
Vulnerability Type: Unvalidated credential-bearing endpoint configuration
Risk Level: High

Vulnerable Code

python
API_BASE_URL = os.environ.get("LINKFOX_TOOL_GATEWAY") or os.environ.get("SHOPEE_API_BASE_URL") or "https://tool-gateway.linkfox.com"
STORE_TOKENS_ENDPOINT = f"{API_BASE_URL.rstrip('/')}/shopee/storeTokens"
DEVELOPER_PROXY_ENDPOINT = f"{API_BASE_URL.rstrip('/')}/shopee/developerProxy"
python
def get_api_key() -> str:
    """
    Get the API key configured in the environment.
    """
    key = os.environ.get("LINKFOX_AGENT_API_KEY") or os.environ.get("LINKFOXAGENT_API_KEY")
    if not key:
        print(
            "API Key not configured",
            file=sys.stderr,
        )
        sys.exit(1)
    return key


def call_api(endpoint: str, params: dict) -> dict:
    api_key = get_api_key()
    data = json.dumps(params).encode("utf-8")
    req = Request(
        endpoint,
        data=data,
        headers={
            "Authorization": api_key,
            "Content-Type": "application/json",
            "User-Agent": "LinkFox-Skill/1.0",
            "SESSION_ID": os.environ.get("SESSION_ID", ""),
            "MESSAGE_ID": os.environ.get("MESSAGE_ID", ""),
            "MODE_ID": os.environ.get("MODE_ID", ""),
            "APP_NAME": os.environ.get("APP_NAME", ""),
        },
        method="POST",
    )
    try:
        with urlopen(req, timeout=150) as response:
            return json.loads(response.read().decode("utf-8"))
    except HTTPError as e:
        body = e.read().decode("utf-8") if e.fp else ""
        return {"error": f"HTTP {e.code}: {e.reason}", "details": body}
    except URLError as e:
        return {"error": f"Connection failed: {e.reason}"}

The onboard ...[truncated 6409 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin production requests to the documented HTTPS endpoints:
    • https://tool-gateway.linkfox.com
    • https://api.linkfox.com
    • https://agent-api.linkfox.com
  2. If endpoint overrides are required for testing, require an explicit development-only flag that is disabled by default.
  3. Parse every configured URL and enforce:
    • The https scheme.
    • An exact hostname allowlist.
    • Approved ports only.
    • No embedded username or password.
    • No fragments or unexpected path prefixes.
  4. Disable cross-origin redirects for requests containing credentials, or validate every redirect destination against the same allowlist.
  5. Reject loopback, link-local, private, and metadata-service destinations unless a deliberately isolated test mode is active.
  6. Separate credential-bearing clients from generic HTTP helpers so arbitrary URLs cannot be passed to authenticated request functions.
  7. Avoid transmitting session metadata headers unless each field is necessary and documented.
  8. Document all recipients and data categories involved in onboarding before requesting a phone number or SMS code.
  9. Add automated tests confirming that non-HTTPS and non-LinkFox destinations are rejected before any sensitive request is sent.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/_shopee_bundle_deal_common.py:217
Finding

Arbitrary Filesystem Write Through Unsanitized SESSION_ID

Content
View full analysis

Vulnerability Details

File Location: scripts/_shopee_bundle_deal_common.py:217-225, 275-310, 314-337; scripts/onboarding.py:153-159
Vulnerability Type: Path traversal and unrestricted output path
Risk Level: Medium

Vulnerable Code

python
def _lf_session_id(ts: float) -> str:
    env = os.environ.get("SESSION_ID")
    if env:
        return env.strip()
    if "_auto" not in _LF_SESSION_CACHE:
        _LF_SESSION_CACHE["_auto"] = (
            _lf_time.strftime("%H%M%S", _lf_time.localtime(ts)) + "-" + _lf_secrets.token_hex(3)
        )
    return _LF_SESSION_CACHE["_auto"]

The unchecked value becomes part of the output path:

python
def emit_result(result, slug=SLUG, inline=False):
    """Persist the complete response and summarize large responses."""
    serialized = json.dumps(result, ensure_ascii=False, indent=2)
    ts = _lf_time.time()
    date_str = _lf_time.strftime("%Y-%m-%d", _lf_time.localtime(ts))
    sid = _lf_session_id(ts)
    root = _lf_root()
    session_dir = os.path.join(root, date_str, sid)
    os.makedirs(session_dir, exist_ok=True)
    _lf_ensure_meta(root, session_dir, date_str, sid, ts)
    data_dir = os.path.join(session_dir, "data")
    os.makedirs(data_dir, exist_ok=True)
    out = os.path.join(data_dir, f"{slug}-{int(ts * 1_000_000)}.json")
    try:
        with open(out, "w", encoding="utf-8") as f:
            f.write(serialized)
        print(f"Saved full response: {out} ({len(serialized)} bytes)")
    except OSError as e:
        print(f"Failed to save to {out}: {e}", file=sys.stderr)
    _lf_update_meta(session_dir, skill=slug, file_rel=os.path.relpath(out, session_dir), ts=ts)
    if inline or len(serialized.encode("utf-8")) <= LF_SMALL_THRESHOLD:
        print(serialized)
    else:
        _lf_summarize(result)

Existing metadata may also be rewritten:

python
def _lf_update_meta(session_dir: str
...[truncated 3635 chars]
Remediation
View remediation

Remediation Suggestions

  1. Validate SESSION_ID against a strict allowlist, such as [A-Za-z0-9_-]{1,64}.
  2. Reject absolute paths, drive-qualified paths, path separators, null bytes, and . or .. components.
  3. Resolve the final session directory with Path.resolve() and verify it is a descendant of the resolved output root before creating directories or files.
  4. Apply the same validation in both the shared output module and the onboarding utility.
  5. Open files using safe creation semantics and restrictive permissions, preferably mode 0600.
  6. Reject symlinked session directories and output files. Where supported, use O_NOFOLLOW and directory-relative file operations.
  7. Do not fall back to a shared temporary directory for sensitive API responses. Fail safely if no private output directory is available.
  8. Add tests for absolute paths, traversal strings, Windows drive paths, UNC paths, mixed separators, symlinks, and oversized identifiers.
  9. Consider generating an internal session directory name and storing the external session identifier only as sanitized metadata.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (42)

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

Critical
Category
Data Flow
Confidence
92% confidence
Finding

The request destination and several outbound headers are derived from environment variables, including the API base URL and API key, then sent via urlopen. If an attacker can influence the environment, they can redirect requests to an attacker-controlled endpoint and exfiltrate credentials and session metadata, which is especially risky for a skill handling store authorization and Shopee API proxying.

Content

Scanner excerpt · scripts/_shopee_bundle_deal_common.py (reported line 88)May include surrounding context.

python
method="POST",
    )
    try:
        with urlopen(req, timeout=150) as response:
            return json.loads(response.read().decode("utf-8"))
    except HTTPError as e:
        body = e.read().decode("utf-8") if e.fp else ""

Tainted flow: 'url' from os.environ.get (line 235, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
95% confidence
Finding

The code builds request destinations from environment-controlled base URLs and then sends sensitive data, including phone numbers, SMS codes, access tokens, refresh tokens, and generated API keys, to those endpoints. In a skill environment, environment variables are deployment-controlled rather than user-controlled, but if misconfigured or maliciously overridden they can redirect credentials to attacker infrastructure, creating SSRF-style exfiltration and credential theft risk.

Content

Scanner excerpt · scripts/onboarding.py (reported line 196)May include surrounding context.

python
except RuntimeError as e:
        return {"_error": str(e)}
    try:
        r = requests.post(url, json=body or {}, headers=headers, timeout=timeout)
        return r.json()
    except Exception as e:
        body_text = ""

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

Critical
Category
Data Flow
Confidence
94% confidence
Finding

The gateway request path uses an environment-derived base URL and attaches the LinkFox API key in the Authorization header before calling urlopen. If that base URL is redirected to an attacker-controlled host, the skill will transmit bearer credentials and business actions such as account lookup, package listing, and order creation to an untrusted destination.

Content

Scanner excerpt · scripts/onboarding.py (reported line 246)May include surrounding context.

python
headers["Content-Type"] = "application/json"
        req = Request(url, method=method, data=body_bytes, headers=headers)
        try:
            with urlopen(req, timeout=30) as resp:
                return json.loads(resp.read().decode())
        except urllib.error.HTTPError as e:
            status = e.code

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

If the skill truly performs SMS login, token generation, account/team queries, subscription lookup, order creation, payment QR generation, and order-status polling, then it is operating far outside its stated Shopee promotion-management scope. That mismatch is highly dangerous because it could facilitate credential capture, account takeover, billing abuse, or covert monetization workflows under the cover of an unrelated ecommerce skill.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

If the skill truly performs SMS login, token generation, account/team queries, subscription lookup, order creation, payment QR generation, and order-status polling, then it is operating far outside its stated Shopee promotion-management scope. That mismatch is highly dangerous because it could facilitate credential capture, account takeover, billing abuse, or covert monetization workflows under the cover of an unrelated ecommerce skill.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

If the skill truly performs SMS login, token generation, account/team queries, subscription lookup, order creation, payment QR generation, and order-status polling, then it is operating far outside its stated Shopee promotion-management scope. That mismatch is highly dangerous because it could facilitate credential capture, account takeover, billing abuse, or covert monetization workflows under the cover of an unrelated ecommerce skill.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The file documents account onboarding, login, API key setup, and billing purchase flows that are unrelated to the stated Shopee Bundle Deal business function. This expands the skill's operational scope into credential handling and payment enablement, creating unnecessary attack surface and increasing the chance an agent will solicit secrets or guide users through risky account actions outside the intended task.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The documentation instructs the agent to facilitate phone-based registration/login and plan purchasing even though those capabilities are not justified by the skill's declared purpose. In context, this makes the skill more dangerous because it normalizes collection of sensitive authentication data and payment-related actions during an unrelated commerce-management workflow.

Content

No source excerpt is available for this finding.

YARA rule 'backdoor_persistence': Backdoor persistence with malicious payloads (shell commands, SSH key injection, hidden root users) [malware]

High
Category
YARA Match
Confidence
75% confidence
Finding

YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Content

Scanner excerpt · references/onboarding.md (reported line 14)May include surrounding context.

md
示 JSON 里的 phone/agreements
   - 收到验证码后:`python scripts/onboarding.py login <phone> <code>`
   - 拿到 `api_key` 后把下面三平台配置转发给用户,提示重启会话生效:
     - Windows PowerShell(永久):`setx LINKFOX_AGENT_API_KEY "<key>"`
     - macOS zsh:`echo 'export LINKFOX_AGENT_API_KEY="<key>"' >> ~/.zshrc && source ~/.zshrc`
     - Linux bash:`echo 'export LINKFOX_AGENT_API_KEY="<key>"' >> ~/.bashrc && source ~/.bashrc`
     - 变量名 `LINKFOX_AGENT_API_KEY`(主推)或 `LINKFOXAGENT_API_KEY`(老规范)任一即可

**billing 场景**:`errcode=402` 或消息含 `算力/余额/quota/insufficient/充值/套餐到期`。
- `python scripts/onboarding.py list-plans` → 有 AskUserQuestion 就弹菜单,否则输出编号清单让用户选
- 校验 `plan_id` ∈ 清单、支付方式 ∈ 该套餐 `available_methods`(通常 `wechat/alipay`)
- `python scripts/onboarding.py order <plan_id> <method>` → 展示优先级 PNG

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

This file implements LinkFox account onboarding, SMS login, API-key retrieval, subscription/package handling, and payment flows, none of which are necessary for a Shopee Bundle Deal management skill. Such scope mismatch is dangerous because it introduces unrelated credential collection and monetization capabilities that can surprise users and expand the attack surface far beyond the declared purpose.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill can create paid orders and generate payment QR codes, enabling direct commercial transactions from a package that is supposed to manage Shopee bundle deals. This is context-inappropriate and increases the risk of unauthorized charges, user confusion, and abuse if the skill is triggered unexpectedly or bundled into broader automation.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

These command handlers expose login, API-key generation, package listing, ordering, and payment-status features unrelated to Shopee promotion management. In context, this makes the skill more dangerous because users invoking a Shopee store-management tool would not reasonably expect credential onboarding and commerce operations against a different platform.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill declares capabilities implying environment access, filesystem writes, network calls, and shell execution, but does not scope or constrain them with an explicit permissions/allowed-tools declaration. In an agent setting, this increases the blast radius of misuse or prompt-triggered abuse because the agent may execute sensitive operations beyond the minimally necessary surface.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger condition is very broad, including activation even when the user does not explicitly mention bundle deals, which increases the chance of unintended invocation. In a skill capable of network calls, file writes, and promotion changes, overbroad routing can cause accidental data access or unintended destructive business actions.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill instructs the agent to always persist full API responses to session-linked local files, which may include store identifiers, promotion details, operator metadata, or other sensitive business data. Default bulk persistence increases the risk of data leakage, over-retention, cross-task exposure, and unauthorized local access, especially when tied to predictable session-based paths.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill exposes destructive promotion-management operations such as end/delete/update without a clear warning or confirmation requirement. In this context, accidental invocation could terminate active promotions or alter store merchandising, causing financial loss or operational disruption.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/api.md (reported line 49)May include surrounding context.


curl 示例

bash
curl -X POST https://tool-gateway.linkfox.com/shopee/developerProxy \

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This documentation exposes a destructive API action that deletes a bundle deal but provides no warning, confirmation requirement, rollback note, or operator safety guidance. In an agent skill context, omission of safeguards increases the chance that an LLM-driven workflow or user will trigger irreversible promotional data loss unintentionally, especially because the skill is designed to act on authorized live Shopee stores.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The documentation exposes an operation that can terminate a live promotional campaign early but does not warn about the business impact, irreversibility, or the need for explicit user confirmation. In an agentic context, this increases the chance of accidental destructive actions against an authorized Shopee store, especially because the skill is designed to act through a developer proxy once store authorization is already in place.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill file is written primarily in Chinese, including headings, field descriptions, and usage guidance, with no indication that the user can choose another language or that the skill is intentionally limited to a Chinese-speaking audience. This creates a natural-language locale policy concern because the documentation effectively imposes a specific language without opt-in or justification.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill explicitly tells the operator to ask for a user's phone number and then process a verification code for automated login, but provides no privacy notice, verification of identity, or secure handling constraints. OTPs and phone numbers are highly sensitive authentication factors, and collecting them through an agent can enable account takeover or unauthorized account creation if misused or intercepted.

Content

No source excerpt is available for this finding.

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/_shopee_bundle_deal_common.py (reported line 37)May include surrounding context.

python
print(f"DEPENDENCY_MISSING: {json.dumps(payload, ensure_ascii=False)}", file=sys.stderr)
        sys.exit(DEPENDENCY_EXIT_CODE)
    try:
        result = subprocess.run(
            [sys.executable, str(checker)],
            capture_output=True,
            text=True,

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The code forwards SESSION_ID, MESSAGE_ID, MODE_ID, and APP_NAME in outbound requests without any visible need-to-know filtering in this file. Even if sent to a legitimate gateway, propagating extra metadata can enable tracking, correlation, or leakage to downstream systems beyond what is necessary for Bundle Deal operations.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The helper creates a cross-session storage tree, session metadata, and a global index file under several filesystem locations. This introduces unnecessary accumulation and correlation of user/session activity beyond the stated Bundle Deal forwarding purpose, increasing privacy risk and the blast radius of any local filesystem access.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

emit_result() serializes and writes full API responses to local disk, which can include store tokens, merchant identifiers, promotion details, or other sensitive business data returned by the proxy/helper calls. This expands the skill from transient API forwarding into durable local data retention, increasing exposure through local compromise, accidental sharing, or later misuse.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.