Back to skill

Security audit

kingdoc

Security checks for vulnerabilities and agentic risk

Overview

This skill is a powerful cloud document automation tool, but it asks users to share app secrets in chat and exposes destructive document operations without enforceable confirmation gates.

Install only if you are comfortable granting broad access to your Kingsoft/KDocs documents. Do not paste production App Secrets into chat; use a least-privilege test app/key if you proceed. Treat delete, permanent delete, version restore, permission changes, webhook processing, memory bridging, and local indexing as high-impact features and require your own manual confirmation outside the skill until code-enforced approvals exist.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • 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
engine/api/mcp_server.py:183
Finding

Destructive cloud operations lack code-enforced user confirmation

Content
View full analysis

Vulnerability Details

File Location: engine/api/mcp_server.py:118-120, 183-195, 279-281; engine/api/tools.py:109-114, 154-171
Vulnerability Type: Missing authorization gate for destructive operations
Risk Level: High

Vulnerable Code

python
@mcp.tool()
async def kdoc_file_delete(file_id: str) -> str:
    return await _wrap("kdoc_file_delete")(file_id)

@mcp.tool()
async def kdoc_trash_destroy(file_id: str) -> str:
    return await _wrap("kdoc_trash_destroy")(file_id)

@mcp.tool()
async def kdoc_version_restore(file_id: str, version: int) -> str:
    return await _wrap("kdoc_version_restore")(file_id, version)

@mcp.tool()
async def kdoc_file_permission(file_id: str, members: List[Dict]) -> str:
    return await _wrap("kdoc_file_permission")(file_id, members)

The corresponding backend methods immediately perform authenticated state-changing requests:

python
def kdoc_file_delete(self, file_id: str) -> Dict:
    if not validate_file_id(file_id):
        raise KingDocError("KD011", "非法 file_id 格式")
    resp = self.client.delete(f"/personal/files/{file_id}")
    return resp

def kdoc_trash_destroy(self, file_id: str) -> Dict:
    resp = self.client.post("/personal/trash/destroy", json={"file_id": file_id})
    return resp

def kdoc_version_restore(self, file_id: str, version: int) -> Dict:
    resp = self.client.post(
        f"/appspace/versions/{version}/restore",
        json={"file_id": file_id},
    )
    return resp

def kdoc_file_permission(self, file_id: str, members: list) -> Dict:
    resp = self.client.put(
        f"/personal/files/{file_id}/permissions",
        json={"members": members},
    )
    return resp

Technical Analysis

The Skill documentation states that deletion, permanent trash destruction, version restoration, and permission changes require explicit user confirmation. Permanent deletion is documented as requiring secondary confirmation.

The executable MCP entry points do not enforce those requi ...[truncated 2047 chars]

Remediation
View remediation

Remediation Suggestions

  1. Add a mandatory confirmation object to every destructive or authorization-changing MCP tool.
  2. Implement a two-step workflow:
    • A preview endpoint returns the exact operation, affected resources, and consequences.
    • A separate execution endpoint requires a server-generated confirmation token.
  3. Bind each confirmation token to:
    • The authenticated user or session.
    • The operation name.
    • Target file identifiers.
    • All operation parameters.
    • A short expiration time.
    • A single-use nonce.
  4. Require a distinct second confirmation token for irreversible deletion.
  5. Enforce confirmation in the backend immediately before the API request so alternate entry points cannot bypass it.
  6. Implement dry_run as an executable backend control rather than relying on agent instructions.
  7. Record confirmation issuance and consumption in an audit log without storing authentication credentials.
  8. Add tests proving that destructive backend methods reject direct calls without valid approval state.

T02 · Agent Memory Poisoning

Warning
Location
engine/webhook_center.py:214
Finding

Missing webhook signatures are accepted, allowing forged events to enter persistent memory

Content
View full analysis

Vulnerability Details

File Location: engine/api/mcp_server.py:2178-2190; engine/webhook_center.py:214-258, 353-377; engine/memory_bridge.py:198-247
Vulnerability Type: Authentication bypass leading to persistent state pollution
Risk Level: Medium

Vulnerable Code

The MCP entry point makes the signature optional and defaults it to an empty string:

python
@mcp.tool()
async def kdoc_webhook_process_event(payload: str, signature: str = "") -> str:
    try:
        import json
        from engine.webhook_center import process_event
        payload_obj = json.loads(payload)
        result = process_event(payload_obj, signature)
        return _to_text(result)
    except Exception as e:
        return f"[ERR] 处理事件失败:{e}"

Signature verification only occurs when a non-empty signature is supplied:

python
def process_incoming_event(
    self,
    payload: Dict[str, Any],
    signature: str = "",
) -> Dict[str, Any]:
    event_type = payload.get("event_type", "")
    table_id = payload.get("table_id", "")
    record_id = payload.get("record_id", "")

    if signature and not self._verify_signature(payload, signature):
        return {"success": False, "error": "签名校验失败"}

    event_hash = self._compute_event_hash(payload)
    if self._is_duplicate(event_hash):
        return {
            "success": True,
            "status": "duplicate",
            "message": "重复事件已忽略",
        }

    event_id = f"evt_{int(time.time())}_{event_hash[:8]}"

After acceptance, selected events are forwarded to the persistent memory bridge:

python
def _trigger_memory_bridge(
    self,
    event_type: str,
    table_id: str,
    record_id: str,
    payload: Dict[str, Any],
):
    try:
        from engine.memory_bridge import get_memory_bridge
        bridge = get_memory_bridge(backend=self.backend)
        memory_event = {
            "record_created": "create",
            "record_updated": "edit",
            "record_deleted": "delete",
        }
...[truncated 3624 chars]
Remediation
View remediation

Remediation Suggestions

  1. Reject missing signatures before any event storage, deduplication, dispatch, or memory operation:
    python
    if not signature:
        return {"success": False, "error": "A webhook signature is required"}
    if not self._verify_signature(payload, signature):
        return {"success": False, "error": "Invalid webhook signature"}
    
  2. Remove the empty default from the MCP entry point and make the signature a required argument.
  3. Use a unique, randomly generated secret for each subscription instead of relying on a public hardcoded default.
  4. Resolve the target subscription before verification and validate the signature with that subscription’s secret.
  5. Validate event types, table IDs, record IDs, timestamps, and payload structure before persistence.
  6. Include an authenticated timestamp and nonce in the signed material, enforce a short replay window, and maintain nonce-based replay protection.
  7. Invoke notification and memory handlers only after successful authentication and schema validation.
  8. Separate untrusted event content from trusted memory facts. Store provenance and authentication status, and prevent unauthenticated records from being migrated.
  9. Add tests confirming rejection of empty, missing, malformed, expired, replayed, and incorrectly signed events.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (176)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The skill explicitly tells users to provide their App ID and App Secret directly to the AI for automatic setup, without a nearby warning that the secret is sensitive and should not be shared in normal chat. This can lead to credential exposure to the model, logs, transcripts, or other unintended storage/processing paths, enabling unauthorized cloud document access.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Instructing the user to give the App Secret to the AI for automatic generation of config files is a direct secret-handling anti-pattern. It expands exposure from the local machine to the conversational system and any associated logging or telemetry, potentially compromising document accounts, team files, and API quotas.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
| v4.2.0 | 2026-09-19 | 增加:团队知识库模式引擎 `engine/knowledge_hub.py`(空间级本地倒排索引全文检索,可选 jieba 中文分词,权限矩阵先鉴权后检索,无 read 权限文档不进结果集,硬件自适应分块建索引);增加:政企合规中心引擎 `engine/complianc

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
er.py`(SQLite 按天计数 500 次/天 + 令牌桶限速 5 req/s + 429 指数退避 + 批量任务硬件自适应削峰);增加:格式转换引擎 `engine/format_converter.py`(补齐 jpg/png/txt 三类目标格式,全格式覆盖 pdf/jpg/png/txt/docx/xls

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The installation section repeats the instruction to reveal App ID and App Secret to the AI, normalizing unsafe credential-sharing behavior. Repetition increases the likelihood users will expose production credentials and believe the practice is intended and safe.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The installation section reinforces the same insecure pattern of disclosing credentials to the AI, increasing the chance of widespread secret leakage during onboarding. Because this skill also enables cloud write operations, leaked credentials could be used for unauthorized uploads, sharing changes, history manipulation, or webhook abuse.

Content

No source excerpt is available for this finding.

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 131)May include surrounding context.

md
2. Office 二进制文档(默认拦截用户上传):.docx .xlsx .pptx .doc .xls .ppt
                                     .xlsm .docm .pptm
  3. 二进制镜像 / 安装包:.iso .dmg .zip .rar .7z .tar .gz .apk .jar
  4. 系统缓存 / 隐藏文件:.DS_Store .git(.git 目录) .env .log .tmp
  5. 其他风险脚本:.sh .com .scr .hta .reg

设计原则:

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 · engine/security.py (reported line 8)May include surrounding context.

python
2. Office 二进制文档(默认拦截用户上传):.docx .xlsx .pptx .doc .xls .ppt
                                     .xlsm .docm .pptm
  3. 二进制镜像 / 安装包:.iso .dmg .zip .rar .7z .tar .gz .apk .jar
  4. 系统缓存 / 隐藏文件:.DS_Store .git(.git 目录) .env .log .tmp
  5. 其他风险脚本:.sh .com .scr .hta .reg

设计原则:

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 · engine/security.py (reported line 39)May include surrounding context.

python
# 3. 二进制镜像 / 安装包
    '.iso', '.dmg', '.zip', '.rar', '.7z', '.tar', '.gz', '.apk', '.jar',
    # 4. 系统缓存 / 隐藏文件
    '.ds_store', '.env', '.log', '.tmp',
    # 5. 其他风险脚本
    '.sh', '.com', '.scr', '.hta', '.reg',
}

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 · references/security.md (reported line 125)May include surrounding context.

md
# 3. 二进制镜像 / 安装包
    '.iso', '.dmg', '.zip', '.rar', '.7z', '.tar', '.gz', '.apk', '.jar',
    # 4. 系统缓存 / 隐藏文件
    '.ds_store', '.env', '.log', '.tmp',
    # 5. 其他风险脚本
    '.sh', '.com', '.scr', '.hta', '.reg',
}

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/auth.md (reported line 155)May include surrounding context.

4.4 删除文档(软删除)

text
DELETE /personal/files/:file_id

⚠️ 删除后文档进入回收站,可恢复。

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/auth.md (reported line 163)May include surrounding context.

4.5 彻底删除

text
DELETE /personal/files/:file_id/permanent

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/auth.md (reported line 282)May include surrounding context.

POST /et/formula/set # 设置公式 POST /et/sheets # 添加工作表 PUT /et/sheets/:sheet_id # 重命名工作表 DELETE /et/sheets/:sheet_id # 删除工作表

text

---

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/auth.md (reported line 299)May include surrounding context.

POST /dbt/views # 添加视图 POST /dbt/records # 添加记录 PUT /dbt/records/:record_id # 更新记录 DELETE /dbt/records/:record_id# 删除记录 GET /dbt/records/:table_id # 查询记录 POST /dbt/webhooks # 设置 Webhook

text

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/auth.md (reported line 312)May include surrounding context.

POST /personal/forms # 创建收集表 GET /personal/forms/:form_id # 获取收集表 PUT /personal/forms/:form_id # 修改收集表 DELETE /personal/forms/:form_id# 删除收集表 GET /personal/forms/:form_id/answers?offset=0&limit=50 # 查询答卷 POST /personal/forms/:form_id/submit # 提交答卷

text

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/auth.md (reported line 294)May include surrounding context.

2.3 删除字段

text
DELETE /dbt/fields/:field_id

2.4 列出字段

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/dbt_references.md (reported line 60)May include surrounding context.

2.3 删除字段

text
DELETE /dbt/fields/:field_id

2.4 列出字段

Tool Parameter Abuse

High
Category
Tool Misuse
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).

Content

Scanner excerpt · references/dbt_references.md (reported line 135)May include surrounding context.

4.4 删除记录

text
DELETE /dbt/records/:record_id

4.5 查询记录

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README explicitly instructs users to give the AI their App ID and App Secret and states it will generate config files and collect local hardware profiling, but it does not provide clear boundaries on secret handling, storage, redaction, or consent for local data collection. In an agent/skill context, asking users to paste credentials into AI chat increases the risk of unintended logging, retention, or disclosure through the model, tooling, or surrounding platform.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

Telling users to provide App ID and App Secret directly to the AI is a genuine credential-handling flaw because it normalizes secret disclosure into a conversational channel that may be logged or exposed to downstream components. If those credentials are captured, an attacker could access the user's Kingsoft/KDocs integration and act on documents, history, permissions, or other connected resources.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
97% confidence
Finding

The skill advertises and instructs use of powerful capabilities including shell execution, file read/write, network access, environment access, and MCP operations, but the manifest declares no explicit tool scope or permission boundaries. That creates a confused-deputy risk where the agent may be granted broader authority than users or reviewers expect, especially given the skill includes automation, webhook, scheduling, and local system operations.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The manifest description is effectively empty while the body describes a very broad feature set including local file generation, OCR, cloud document access, scheduling, webhook handling, and automation. This undermines informed consent and security review because the declared surface area is far smaller than the actual operational behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The skill documentation, examples, and user-facing instructions are entirely in Chinese and position the product as “文档全中文” for use. There is no indication that users can opt into another language or locale, which can violate language/locale choice expectations unless explicitly justified and scoped.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
70% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

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

macOS

brew install tesseract tesseract-lang

Linux

sudo apt-get install tesseract-ocr tesseract-ocr-chi-sim

text

### 3. 配置并加载

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The trigger examples use generic conversational phrases such as writing notes, creating tables, searching files, or uploading PDFs, which may cause accidental invocation in ordinary conversation. In a skill with file-management, upload, permission, and version-control actions, over-broad triggers increase the chance of unintended access or state-changing operations.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.