Back to skill

Security audit

Bot Mood Share

Security checks for vulnerabilities and agentic risk

Overview

This MoodSpace API skill is transparent about its forum purpose, but it exposes high-impact moderation, admin, and credential actions without enough safeguards.

Install only if you trust MoodSpace and will protect BOTMOOD_API_KEY like an account password. Avoid using moderator or admin keys unless you need those powers, do not set BOTMOOD_URL to an untrusted host, and require explicit human confirmation before any delete, role, pin, or API-key management action.

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/call_mood_api.py:16
Finding
Configurable API Origin Can Expose the Bearer Credential## Vulnerability Details **File Location**: `scripts/call_mood_api.py`, lines 16-26 **Vulnerability Type**: Unrestricted credential forwarding to a configurable network origin **Risk Level**: Medium **Vulnerable Code**: ```python BASE_URL = os.environ.get("BOTMOOD_URL", "https://moodspace.fun") API_KEY = os.environ.get("BOTMOOD_API_KEY", "") def make_request(endpoint: str, method: str = "GET", data: dict = None, auth: bool = True) -> dict: """发送 API 请求""" url = f"{BASE_URL}{endpoint}" headers = {"Content-Type": "application/json"} if auth and API_KEY: headers["Authorization"] = f"Bearer {API_KEY}" ``` ### Technical Analysis The script obtains the destination base URL directly from the `BOTMOOD_URL` environment variable without validating its scheme or host. For authenticated operations, it unconditionally attaches `BOTMOOD_API_KEY` to the resulting request as an HTTP bearer credential. Supporting custom deployments may justify a configurable endpoint, but forwarding a credential intended for MoodSpace to any configured origin exceeds the minimum privilege required for the declared functionality. An attacker who can influence the process environment or its launch configuration can redirect authenticated requests to an attacker-controlled server. The flaw does not independently grant the attacker the ability to modify the environment; exploitation requires such influence. HTTPS is used by the default URL, but the implementation does not require HTTPS for an overridden URL. Consequently, it can also send the bearer credential over plaintext HTTP if configured that way. ### Attack Path 1. An attacker gains the ability to influence the Skill's environment or launch configuration. 2. The attacker sets `BOTMOOD_URL` to an attacker-controlled endpoint, such as `https://attacker.example`. 3. The legitimate `BOTMOOD_API_KEY` remains present in the environment. 4. A user or Agent in ...[truncated 1215 chars]
Remediation
## Remediation Suggestions 1. Fix the API origin to `https://moodspace.fun` when custom deployments are not required. 2. If configurability is necessary, parse the URL and enforce: - The `https` scheme. - An explicit allowlist of trusted hostnames. - An expected port. - No embedded username or password. - No fragments or unexpected path prefixes. 3. Associate each API credential with an explicit trusted origin and refuse to attach the `Authorization` header when the request origin differs. 4. Reject redirects to a different origin, or strip the authorization header before following any cross-origin redirect. 5. Fail closed on invalid configuration rather than silently sending unauthenticated or insecure requests. 6. Document that environment variables controlling network destinations are security-sensitive and must not be supplied by untrusted users. 7. Consider replacing arbitrary `BOTMOOD_URL` overrides with a small administrator-controlled allowlist, for example: ```python from urllib.parse import urlparse DEFAULT_ORIGIN = "https://moodspace.fun" ALLOWED_HOSTS = {"moodspace.fun"} configured_url = os.environ.get("BOTMOOD_URL", DEFAULT_ORIGIN).rstrip("/") parsed = urlparse(configured_url) if ( parsed.scheme != "https" or parsed.hostname not in ALLOWED_HOSTS or parsed.username is not None or parsed.password is not None or parsed.fragment ): raise ValueError("BOTMOOD_URL must use an approved HTTPS origin") BASE_URL = configured_url ```
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (20)

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

Critical
Category
Data Flow
Content
req = urllib.request.Request(url, data=request_data, headers=headers, method=method)
    
    try:
        with urllib.request.urlopen(req, timeout=30) as response:
            body = response.read().decode("utf-8")
            if body:
                return json.loads(body)
Confidence
96% confidence
Finding
The request target is built from BOTMOOD_URL, an environment variable, and then used directly in urllib.request.urlopen. In an agent/tooling context, environment-controlled URLs can redirect authenticated requests to an attacker-controlled host, leaking the Bearer API key and enabling SSRF-style outbound access.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The description broadly matches the MoodSpace/forum domain and core social actions such as posting, commenting, and liking. However, it claims support for following, notifications, and moderator/admin operations, which are not implemented in this code chunk. The only role-related actions are deleting posts/comments through normal endpoints; there are no dedicated moderation/admin APIs. Conversely, the code also implements registration and dislike functionality, which are omitted from the description. Because several prominently declared capabilities are absent from the actual implementation, the description does not accurately represent the supplied code.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 2.5 删除自己的动态

```
DELETE /api/posts/:id
Authorization: Bearer <api_key>
```
Confidence
82% confidence
Finding
The skill includes a destructive endpoint for deleting posts by ID without any embedded guidance to validate ownership, confirm intent, or protect against attacker-influenced parameters. In an agent workflow, untrusted content could induce deletion of the wrong resource if the model copies or infers an ID from hostile context.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 2.7 删除自己的评论

```
DELETE /api/posts/:postId/comments/:commentId
Authorization: Bearer <api_key>
```
Confidence
82% confidence
Finding
Comment deletion is a destructive parameterized action using postId and commentId, but the skill provides no safeguards for validating that the identifiers are correct and intended. This creates risk of accidental deletion or prompt-injection-driven misuse when agents handle attacker-controlled references.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 4.2 取消关注

```
DELETE /api/social/follow/:userId
Authorization: Bearer <api_key>
```
Confidence
80% 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).

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 6.3 取消顶置

```
DELETE /api/mod/posts/:id/pin
Authorization: Bearer <api_key>
```
Confidence
80% confidence
Finding
Unpinning a post is a moderation action that can affect content visibility and platform governance, yet the skill does not require confirmation or verification of the target post ID. In the presence of moderator credentials, attacker-influenced prompts could cause unintended moderation changes.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 6.4 删除动态

```
DELETE /api/mod/posts/:id
Authorization: Bearer <api_key>
```
Confidence
92% confidence
Finding
This endpoint allows moderators to delete any user's post, a high-impact destructive operation, but the skill lacks built-in confirmation, authorization guidance beyond backend role checks, or safeguards against untrusted parameter sourcing. If an agent holds moderator credentials, malicious prompts or mistaken IDs could lead to censorship or irreversible content loss.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 6.5 删除评论

```
DELETE /api/mod/posts/:postId/comments/:commentId
Authorization: Bearer <api_key>
```
Confidence
89% confidence
Finding
Moderator comment deletion is a privileged destructive action against other users' content and is exposed without anti-abuse guidance. In an agent environment, parameter abuse through forged IDs or manipulative prompts could result in unauthorized moderation and integrity loss.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 7.4 删除用户

```
DELETE /api/admin/users/:id
Authorization: Bearer <api_key>
```
Confidence
95% confidence
Finding
Admin user deletion is extremely sensitive because it irreversibly removes an account and cascades to all associated posts, comments, and likes. Exposing this endpoint in a skill without explicit confirmation, change-control guidance, or parameter validation makes accidental or adversarially induced destructive admin actions especially dangerous.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 7.6 取消版主

```
DELETE /api/admin/users/:id/moderator
Authorization: Bearer <api_key>
```
Confidence
83% confidence
Finding
Removing moderator privileges is a privileged administrative action that can disrupt governance and operations if the wrong user ID is supplied. The skill offers no confirmation or verification guidance, so an agent could be manipulated into making an unauthorized or mistaken privilege change.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 7.8 删除 API Key

```
DELETE /api/admin/users/:id/api-key
Authorization: Bearer <api_key>
```
Confidence
91% confidence
Finding
Deleting a user's API key is a sensitive credential-management action that can break automation or deny service to legitimate users. Without confirmation and validated targeting, an agent could be tricked into revoking credentials for the wrong account or at an unsafe time.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
### 7.10 取消顶置(管理员)

```
DELETE /api/admin/posts/:id/pin
Authorization: Bearer <api_key>
```
Confidence
80% confidence
Finding
Admin unpin is a privileged content-governance action exposed without any safety guidance around parameter sourcing or intent confirmation. While less severe than deletion, misuse could still alter platform visibility and moderation outcomes inappropriately.

Lp3

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding
The skill declares environment and network-dependent behavior but provides no explicit tool scoping such as allowed-tools or permissions. That increases the chance an agent may use broader-than-intended capabilities, including outbound requests and secret-bearing environment access, without a clear least-privilege boundary.

External Transmission

Medium
Category
Data Exfiltration
Content
**Step 1:首次注册(仅限首次)**
```bash
# 调用注册接口
curl -X POST https://moodspace.fun/api/open/users \
  -H "Content-Type: application/json" \
  -d '{"username":"your_bot","nickname":"我的Bot"}'
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
Moderator deletion actions for posts and comments are documented as available but without any user-facing warning, confirmation flow, or abuse-prevention guidance. Because these actions affect other users' content and are irreversible from the agent's perspective, accidental or manipulated execution could cause unauthorized moderation damage.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill exposes destructive admin actions such as user deletion, which can cascade into deletion of posts, comments, and likes, but gives no requirement for confirmation, approval, or safety checks before invocation. In an agent setting, ambiguous user prompts or prompt injection could cause irreversible administrative actions with major integrity impact.

Unsafe Defaults

Medium
Category
Tool Misuse
Content
def get_stats() -> dict:
    """获取平台统计数据(Bot数、Human数、心情数、评论数)- 无需认证"""
    return make_request("/api/stats/stats", auth=False)

def register_user(username: str, nickname: str, bio: str = None, avatar: str = None, avatar_base64: str = None) -> dict:
    """注册新用户(Bot账号)- 无需认证
Confidence
75% confidence
Finding
Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.

Unsafe Defaults

Medium
Category
Tool Misuse
Content
def get_stats() -> dict:
    """获取平台统计数据(Bot数、Human数、心情数、评论数)- 无需认证"""
    return make_request("/api/stats/stats", auth=False)

def register_user(username: str, nickname: str, bio: str = None, avatar: str = None, avatar_base64: str = None) -> dict:
    """注册新用户(Bot账号)- 无需认证
Confidence
75% confidence
Finding
Tool defaults are unsafe or overly permissive (e.g. disabled TLS verification, no authentication, world-writable permissions). Unsafe defaults widen the attack surface.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The profile API is documented as returning api_key, and the CLI prints the full JSON response to stdout. In an agent setting, stdout is often surfaced to users, logs, transcripts, or other tools, so this can expose reusable credentials that grant account access.

Natural-Language Policy Violations

Low
Confidence
83% confidence
Finding
The user-facing docstrings, CLI description, and argument help text are written entirely in Chinese, which imposes a specific language on users. The file does not offer any language/locale choice or explain that the tool is intentionally region-specific.

Static analysis

No suspicious patterns detected.