Back to skill

Security audit

Knowfun

Security checks for vulnerabilities and agentic risk

Overview

The skill appears to be a real Knowfun.io API integration, but it asks for broader local and network authority than its purpose requires and has some under-disclosed security weaknesses.

Install only if you trust Knowfun.io and are comfortable sending prompts, URLs, and task metadata to its API under your API key. Prefer a version-pinned install, avoid sudo/manual global symlinks, store the API key in a safer secret mechanism when possible, and review commands before allowing an assistant or remote chat interface to create tasks that may consume credits.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/knowfun-cli.sh:55
Finding
Unescaped User Input Allows JSON Request Injection<![CDATA[ ## Vulnerability Details **File Location**: `scripts/knowfun-cli.sh`, lines 55-98 **Vulnerability Type**: Unescaped user input in a manually constructed JSON request **Risk Level**: Medium ### Vulnerable Code ```bash cmd_create() { local task_type="$1" shift local material="$*" if [ -z "$task_type" ] || [ -z "$material" ]; then print_error "Usage: knowfun-cli.sh create <course|poster|game|film> <text or url>" exit 1 fi # Generate unique request ID local request_id="req_$(date +%s)_$(uuidgen | head -c 8)" # Determine if material is URL or text local material_type="text" local material_field="text" if [[ "$material" =~ ^https?:// ]]; then material_type="url" material_field="url" fi print_info "Creating $task_type task..." print_info "Request ID: $request_id" local response=$(curl -s -w "\n%{http_code}" -X POST "$BASE_URL/api/openapi/v1/tasks" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d "{ \"requestId\": \"$request_id\", \"taskType\": \"$task_type\", \"material\": { \"$material_field\": \"$material\", \"type\": \"$material_type\" } }") ``` ### Technical Analysis The `task_type` and `material` values originate from command-line arguments and are inserted directly into a JSON document. They are not encoded with a JSON serializer or escaped for use inside JSON strings. Shell quoting prevents these values from becoming separate shell commands, so this is not direct shell-command injection. However, shell quoting does not make the expanded values safe JSON. An input containing double quotes, backslashes, control characters, or JSON delimiters can terminate the intended string and alter the structure of the request body. For example, a crafted material value could close the `text` property and attempt to introduc ...[truncated 1906 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Construct request bodies using a JSON serializer rather than string interpolation. For example: ```bash case "$task_type" in course|poster|game|film) ;; *) print_error "Unsupported task type" exit 1 ;; esac if [ "${#material}" -gt 2048 ]; then print_error "Content exceeds the 2048-character limit" exit 1 fi payload=$(jq -n \ --arg requestId "$request_id" \ --arg taskType "$task_type" \ --arg field "$material_field" \ --arg material "$material" \ --arg materialType "$material_type" \ '{ requestId: $requestId, taskType: $taskType, material: { ($field): $material, type: $materialType } }') response=$(curl --fail-with-body --silent --show-error \ -w "\n%{http_code}" \ -X POST "$BASE_URL/api/openapi/v1/tasks" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ --data-binary "$payload") ``` 2. Validate `task_type` against the exact supported allowlist: `course`, `poster`, `game`, and `film`. 3. Enforce the documented content-length restriction before sending the request. 4. Reject control characters where they are not needed. 5. Add tests covering quotes, backslashes, newlines, Unicode, JSON delimiters, and oversized input. 6. Ensure the remote API also rejects unknown fields and performs strict schema validation; client-side validation must not be the only control. ]]>

T05 · Unauthorized Access and Privilege Escalation

Note
Location
SKILL.md:7
Finding
Skill Declares Unnecessary Read and Write Permissions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, line 7 **Vulnerability Type**: Excessive Agent tool permissions **Risk Level**: Low ### Vulnerable Code ```yaml --- name: knowfun description: Generate educational content using Knowfun.io API - create courses, posters, games, and films with AI. Use when user wants to generate educational content, visual materials, or interactive experiences. argument-hint: "<command> [args]" disable-model-invocation: false user-invocable: true allowed-tools: "Bash(curl *), Read, Write" ``` ### Technical Analysis The Skill declares access to generic `Read` and `Write` tools in addition to `Bash(curl *)`. The documented and implemented functionality consists of creating API requests, checking tasks, and retrieving account information. The reviewed implementation does not require arbitrary workspace file reads or writes for those operations. Granting capabilities that are not necessary for the declared workflow violates the principle of least privilege. Although no malicious instructions directing the Agent to misuse these tools were found, excessive permissions increase the consequences of future prompt injection, compromised documentation, unsafe model behavior, or later changes to the Skill instructions. The `Bash(curl *)` permission is also broader than the implementation's intended network scope if the host interprets it as permission to invoke curl against arbitrary destinations. The executable script currently hardcodes `https://api.knowfun.io`, but the declarative permission itself is not restricted to that host. ### Attack Path A potential exploitation path requires an additional prompt-injection or instruction-confusion condition: 1. The Skill is loaded with `Read`, `Write`, and broad curl execution available. 2. Attacker-controlled task text, URL-derived content, or another untrusted instruction attempts to influence the Agent. 3. The Agent follows the malicious instruction while operating under ...[truncated 1183 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove filesystem capabilities that are not required: ```yaml allowed-tools: "Bash(curl *)" ``` 2. Prefer invoking only the packaged `knowfun` command rather than granting generic curl execution, if the Skill platform supports command-level restrictions. 3. If host-based network controls are available, restrict outbound requests to: - Scheme: `https` - Host: `api.knowfun.io` - Documented API paths only 4. Require explicit user approval before transmitting user-provided document content or other potentially sensitive material. 5. If future functionality genuinely requires local files, request narrowly scoped, read-only access to a user-selected file instead of generic `Read` and `Write`. 6. Keep filesystem access disabled by default and introduce it only for a specific operation with clear user confirmation. ]]>
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
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
Findings (164)

Credential Access

High
Category
Privilege Escalation
Content
git checkout -b feature/your-feature-name

# 4. Set up environment
cp .env.example .env
# Add your API key to .env

# 5. Test your changes
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
git checkout -b feature/your-feature-name

# 4. Set up environment
cp .env.example .env
# Add your API key to .env

# 5. Test your changes
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
# 4. Set up environment
cp .env.example .env
# Add your API key to .env

# 5. Test your changes
./scripts/test-api.sh
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
# 4. Set up environment
cp .env.example .env
# Add your API key to .env

# 5. Test your changes
./scripts/test-api.sh
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

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

High
Category
YARA Match
Content
y

1. 访问 https://www.knowfun.io/api-platform
2. 点击"创建 API Key"
3. 命名(例如:"开发密钥")
4. 复制密钥(以 `kf_` 开头)

### 2. 设置环境变量

```bash
# 临时(当前会话)
export KNOWFUN_API_KEY="kf_your_api_key_here"

# 永久 — zsh(macOS 默认)
echo 'export KNOWFUN_API_KEY="kf_your_api_key_here"' >> ~/.zshrc && source ~/.zshrc

# 永久 — bash
echo 'export KNOWFUN_API_KEY="kf_your_api_key_here"' >> ~/.bashrc && source ~/.bashrc
```

### 3. 测试安装

```bash
knowfun credits
```

---

## 📊 功能对比

| 功能 | Claude Code | Cursor | Cline | OpenClaw |
|------|:-----------:|:------:|:-----:|:--------:|
| 斜杠命令(`/knowfun`) | ✅ | ❌ | ❌ | ❌ |
| 自动技能调用 | ✅ | ❌ | ❌ | ✅ |
| CLI 工具(`knowfun`) | ✅ | ✅ | ✅ | ✅ |
| 自然语言请求 | ✅ | ✅ | ✅ | ✅ |
| 远程访问(Telegram 等) | ❌ | ❌ | ❌ | ✅ |
| npm 安装 | ✅ | ✅ | ✅ | ✅ |

---

## 🆘 故障排�
Confidence
75% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

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

High
Category
YARA Match
Content
y

1. 访问 https://www.knowfun.io/api-platform
2. 点击"创建 API Key"
3. 命名(例如:"开发密钥")
4. 复制密钥(以 `kf_` 开头)

### 2. 设置环境变量

```bash
# 临时(当前会话)
export KNOWFUN_API_KEY="kf_your_api_key_here"

# 永久 — zsh(macOS 默认)
echo 'export KNOWFUN_API_KEY="kf_your_api_key_here"' >> ~/.zshrc && source ~/.zshrc

# 永久 — bash
echo 'export KNOWFUN_API_KEY="kf_your_api_key_here"' >> ~/.bashrc && source ~/.bashrc
```

### 3. 测试安装

```bash
knowfun credits
```

---

## 📊 功能对比

| 功能 | Claude Code | Cursor | Cline | OpenClaw |
|------|:-----------:|:------:|:-----:|:--------:|
| 斜杠命令(`/knowfun`) | ✅ | ❌ | ❌ | ❌ |
| 自动技能调用 | ✅ | ❌ | ❌ | ✅ |
| CLI 工具(`knowfun`) | ✅ | ✅ | ✅ | ✅ |
| 自然语言请求 | ✅ | ✅ | ✅ | ✅ |
| 远程访问(Telegram 等) | ❌ | ❌ | ❌ | ✅ |
| npm 安装 | ✅ | ✅ | ✅ | ✅ |

---

## 🆘 故障排�
Confidence
75% confidence
Finding
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).

Missing User Warnings

High
Confidence
97% confidence
Finding
This section promotes remote chat control, browser automation, persistent memory, full file access, shell control, and self-installing extensions as benefits, but gives no security boundaries, authentication guidance, or privacy warnings. In a tool-integrated skill, these capabilities materially increase the attack surface and could enable unauthorized command execution, data exposure, or persistence if the surrounding platform is misconfigured or socially engineered.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The code does support the declared core capability of generating educational content through Knowfun.io by creating tasks for course, poster, game, and film. However, its behavior is broader than the description states. In addition to content generation, it acts as a general-purpose API/account management CLI, exposing operational and account-level capabilities: listing tasks, fetching task details/status, viewing credits, pricing, usage statistics, and schema. These are materially undeclared capabilities and go beyond a description focused only on content generation. No harmful exfiltration is evident, but the description does not accurately represent the full behavior of the code.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding
The description presents the skill as an end-user content generation tool for educational materials. The actual code shown is not implementing a general content-generation workflow; it is an administrative/test script for validating the Knowfun.io API and inspecting account/service state. Although it optionally creates a poster task, that action is framed as a diagnostic test consuming credits, not as fulfilling a user request to generate educational content. This is a materially different primary purpose from the declared description.

Credential Access

High
Category
Privilege Escalation
Content
Or create a `.env` file:
```bash
echo 'KNOWFUN_API_KEY="kf_your_api_key_here"' >> .env
```

---
Confidence
95% confidence
Finding
Writing an API key into a .env file is common, but presented without safeguards it can normalize unsafe secret handling and lead to accidental commits, backups, workspace sharing, or local disclosure. Because this credential authorizes paid API operations and access to account resources, compromise can directly enable unauthorized usage and billing abuse.

Credential Access

High
Category
Privilege Escalation
Content
或创建 `.env` 文件:
```bash
echo 'KNOWFUN_API_KEY="kf_your_api_key_here"' >> .env
```

---
Confidence
97% confidence
Finding
Instructing users to append an API key to `.env` without companion secret-handling guidance creates a concrete credential exposure risk. `.env` files are commonly committed accidentally, copied into support bundles, or read by other local tooling, making this more severe than a generic documentation nit.

External Script Fetching

High
Category
Supply Chain
Content
直接使用 curl(Claude 可以帮助构建这个):

```bash
curl -X POST https://api.knowfun.io/api/openapi/v1/tasks \
  -H "Authorization: Bearer $KNOWFUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
Confidence
90% confidence
Finding
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

External Script Fetching

High
Category
Supply Chain
Content
获取详细的使用统计:

```bash
curl -s "https://api.knowfun.io/api/openapi/usage?page=1&pageSize=20" \
  -H "Authorization: Bearer $KNOWFUN_API_KEY" | python3 -m json.tool
```
Confidence
90% confidence
Finding
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

External Script Fetching

High
Category
Supply Chain
Content
### 5. 保存任务 ID
跟踪你的任务 ID 以供将来参考:
```bash
TASK_ID=$(curl ... | python3 -m json.tool | grep taskId | cut -d'"' -f4)
echo "$TASK_ID" >> task_history.txt
```
Confidence
90% confidence
Finding
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.

Lp1

High
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The CLI forwards the entire parent environment into a spawned Bash process via `env: process.env`. In an agent setting, environment variables commonly contain secrets such as API keys, tokens, proxy settings, or execution controls; passing them wholesale to a shell wrapper increases the blast radius if the wrapper script, its children, or downstream commands leak, misuse, or are influenced by those values.

Lp1

High
Category
MCP Least Privilege
Confidence
95% confidence
Finding
The file is an executable shell script that performs network operations and handles API credentials, which is a powerful capability. If the enclosing skill does not explicitly declare shell execution permissions, the mismatch undermines least-privilege expectations and can let an agent execute commands and transmit data in ways users or the platform did not authorize.

External Transmission

Medium
Category
Data Exfiltration
Content
# Lines 46, 74, 110, 141, 163, 179, 206 - all hardcoded paths
```

### 2. curl Commands in Shell Script

**What Scanner Sees:**
```bash
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Session Persistence

Medium
Category
Rogue Agent
Content
1. **Update Documentation**: If you changed functionality, update docs
2. **Test Thoroughly**: Test on all supported platforms if possible
3. **Update Changelog**: Add entry to CHANGELOG.md
4. **Create PR**: Use a clear title and description
5. **Address Feedback**: Respond to review comments
Confidence
80% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Rp1

Medium
Category
MCP Rug Pull
Confidence
87% confidence
Finding
The installation guide instructs users to run `npx clawhub install knowfun-skills` without pinning a specific version. This allows execution of whatever package version is current at install time, increasing supply-chain risk if the upstream package is compromised or a breaking/malicious release is published.

Session Persistence

Medium
Category
Rogue Agent
Content
### Method 1: curl (Recommended — no cloning needed)

```bash
mkdir -p ~/.claude/skills/knowfun
curl -fsSL https://raw.githubusercontent.com/MindStarAI/KnowFun-Skills/master/SKILL.md \
  -o ~/.claude/skills/knowfun/SKILL.md
```
Confidence
79% confidence
Finding
Installing `SKILL.md` into `~/.claude/skills/knowfun` creates persistent agent behavior across future Claude Code sessions. Persistence is expected for a skill install, but from a security perspective it means remote-fetched instructions continue to influence later sessions until manually removed.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
```bash
git clone https://github.com/MindStarAI/KnowFun-Skills.git
sudo ln -s $(pwd)/KnowFun-Skills/scripts/knowfun-cli.sh /usr/local/bin/knowfun
chmod +x KnowFun-Skills/scripts/knowfun-cli.sh
```
</details>
Confidence
90% confidence
Finding
The alternative install path instructs users to use `sudo ln -s ... /usr/local/bin/knowfun`, which elevates privileges to modify a system-wide executable path. In a setup flow involving a locally cloned repository, encouraging privileged file placement increases the impact of any compromised or substituted script.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The guide tells users to export an API key directly in the shell and append it to `~/.zshrc` without warning about shell history, local file exposure, or safer secret-handling mechanisms. This can leak credentials through command history, shared dotfiles, backups, screenshots, or multi-user systems.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The Cursor section says natural-language requests will cause the agent to run CLI commands automatically, but does not warn users that this can trigger local command execution. In agent-integrated environments, normalizing automatic execution without confirmation increases the risk of unintended or prompt-influenced system actions.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The Cline section similarly states that a plain-language request will execute CLI commands automatically, with no safety notice about command execution or external API use. This can mislead users into treating natural-language interaction as harmless text rather than an action that affects their system and account.

Rp1

Medium
Category
MCP Rug Pull
Confidence
87% confidence
Finding
The OpenClaw installation section again relies on unpinned `npx clawhub`, which fetches and executes the latest available package version. In installation docs, this creates a repeatable remote-code-execution supply-chain exposure for users following the instructions.

Static analysis

Detected: suspicious.dangerous_exec, suspicious.generated_source_template_injection

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
knowfun.js:30

User-controlled placeholder is embedded directly into generated source code.

Critical
Code
suspicious.generated_source_template_injection
Location
CLAWHUB_VERIFICATION.md:80