Back to skill

Security audit

B站搜账号下作品集

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed Bilibili lookup helper that calls the RedFox API with a user-provided UID and API key, with some link-safety and trigger-word caveats but no evidence of malicious behavior.

Install only if you trust RedFoxHub with your REDFOX_API_KEY and Bilibili lookup requests. Treat generated video links as external links and verify they point to Bilibili before opening, especially if results look unusual. Pagination requests should be made only in the context of a current Bilibili lookup.

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/fetch_bili_user_works.py:75
Finding

Unvalidated API-Controlled URLs Rendered as Clickable Links

Content
View full analysis

Vulnerability Details

File Location: scripts/fetch_bili_user_works.py:75-82
Related Sink: references/core_workflow.md:87
Vulnerability Type: Improper validation of externally controlled URLs
Risk Level: Medium

Vulnerable Code

python
def build_video_url(item: dict) -> str:
    """优先使用 url 字段;若为空则用 bvId 拼接标准 B站链接"""
    url = item.get("url") or ""
    if url:
        return url
    bv_id = item.get("bvId") or ""
    if bv_id:
        return f"https://www.bilibili.com/video/{bv_id}"
    return ""

The workflow subsequently requires work_url to be rendered directly as a Markdown link:

markdown
**标题规则:** `[标题](work_url)`;超过 30 字截断并加 `...`

Technical Analysis

The url value originates from the external RedFox API response. build_video_url() accepts that value without parsing it, enforcing HTTPS, or restricting it to trusted Bilibili domains. The returned value becomes work_url, which the workflow directs the agent to place into a clickable Markdown link.

Consequently, trust placed in the Skill's output extends to an arbitrary URL selected by the remote API. If the API service, upstream data source, transport endpoint, or relevant response-generation component is compromised, an attacker can inject a phishing or tracking URL. Client behavior may also make non-HTTP schemes hazardous.

The safe fallback based on bvId does not mitigate this issue because it is only used when the API-provided url is empty.

Attack Path

  1. An attacker gains the ability to influence a RedFox API response, such as through compromise of the service or poisoning of its upstream data.
  2. The attacker places an arbitrary URL in an item's url field.
  3. The script receives the response and passes the URL through build_video_url() unchanged.
  4. The URL is returned in the JSON output as work_url.
  5. Following the documented workflow, the agent embeds work_url into a clickable video-title link.
  6. A user trusts the agent-gene ...[truncated 756 chars]
Remediation
View remediation

Remediation Suggestions

  1. Parse every API-provided URL with urllib.parse.urlparse.
  2. Require the scheme to be exactly https.
  3. Allowlist expected Bilibili hosts, such as www.bilibili.com, and reject deceptive suffix or user-information forms.
  4. Prefer constructing canonical URLs locally from a validated bvId rather than trusting the API's complete URL.
  5. Validate bvId against the expected identifier format before interpolation.
  6. If neither a trusted URL nor a valid identifier is available, return an empty URL and render the title as plain text.
  7. Apply equivalent validation to other externally supplied URLs, including cover and avatar URLs, before displaying or fetching them.
  8. Add tests for malicious inputs such as javascript: schemes, HTTP URLs, unrelated domains, user-information host confusion, and malformed identifiers.

A hardened implementation should follow this pattern:

python
import re
from urllib.parse import urlparse

TRUSTED_VIDEO_HOSTS = {"www.bilibili.com"}
BV_ID_RE = re.compile(r"^BV[0-9A-Za-z]+$")

def build_video_url(item: dict) -> str:
    url = str(item.get("url") or "").strip()
    if url:
        parsed = urlparse(url)
        if (
            parsed.scheme == "https"
            and parsed.hostname in TRUSTED_VIDEO_HOSTS
            and parsed.username is None
            and parsed.password is None
        ):
            return url

    bv_id = str(item.get("bvId") or "").strip()
    if BV_ID_RE.fullmatch(bv_id):
        return f"https://www.bilibili.com/video/{bv_id}"

    return ""
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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
Findings (10)

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · README.en.md (reported line 1)May include surrounding context.

md
# Core Workflow

## Step 1:理解用户意图,提取UID

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · README.md (reported line 1)May include surrounding context.

md
# Core Workflow

## Step 1:理解用户意图,提取UID

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 1)May include surrounding context.

md
# Core Workflow

## Step 1:理解用户意图,提取UID

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/core_workflow.md (reported line 1)May include surrounding context.

md
# Core Workflow

## Step 1:理解用户意图,提取UID

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Line L46 says users can 'Simply describe what you need in natural language—no commands to memorize,' which makes invocation criteria overly broad for a markdown skill description. Although examples are provided later, the file does not clearly bound what phrasing will or will not activate the skill, increasing the risk of unintended invocation from ordinary requests.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The pagination triggers 'Next page' and 'Show me more' are extremely generic conversational phrases that can easily appear in unrelated user interactions. If the hosting agent routes on these phrases without stronger state validation, the skill may activate unexpectedly, causing unintended external requests or leaking prior query context across turns.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The README teaches the agent to treat very broad natural-language phrases like “下一页” and “还有更多吗” as control triggers for pagination. In an agent setting, overly generic triggers can be activated unintentionally by normal conversation or attacker-crafted text, causing the skill to continue making external requests or changing state without sufficiently explicit user intent.

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 instructions and required user-facing messages are entirely specified in Chinese, including exact output text, but the file does not indicate that the skill is region-specific or that users may choose another language. This creates a natural-language policy concern because it imposes a locale/language without opt-in.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The workflow treats broad conversational phrases like “下一页” and “更多” as control commands for pagination, which can cause unintended tool invocations when a user mentions those phrases in ordinary discussion. In an agent setting, ambiguous command triggers are dangerous because they let benign natural-language input steer stateful actions without clear confirmation, especially when cursor state is reused automatically.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
87% confidence
Finding

The comments and code explicitly state that stdout and stderr are forcibly wrapped to use UTF-8, overriding the runtime's default terminal encoding. This is a locale/encoding policy choice made unconditionally, with no user option or documented regional justification.

Content

No source excerpt is available for this finding.