T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/kb.py:49- Finding
Overbroad File Access Allows Ingestion of Sensitive Agent Data
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a local personal knowledge-base skill, but it can ingest broad local files into a persistent plaintext database and may be triggered too broadly.
Install only if you are comfortable with a Chinese-language local knowledge-base tool that stores full imported document text under ~/.yuzhi. Avoid adding secrets, credentials, agent configuration, logs, or broad workspace files, and prefer explicit knowledge-base lookup commands rather than automatic use for general questions.
scripts/kb.py:49Overbroad File Access Allows Ingestion of Sensitive Agent Data
scripts/kb.py:15Knowledge-Base Contents Are Created Without Explicitly Restrictive Permissions
代码整体上确实属于个人知识库系统,且实现了文档存储、PDF/TXT/Markdown 文本提取、关键词搜索,以及一种简单的基于词集合重叠的搜索,因此大方向与声明基本一致。但存在两处实质性描述不符:第一,声明中的“自动分类”未实现,代码没有基于内容推断标签的能力,只是提供固定标签并在 add 时由用户传入;第二,声明描述的是在用户提问时优先从知识库检索答案的技能行为,而代码只是一个命令行工具,没有任何聊天触发器、问题路由或回答生成逻辑。因此应判定为存在描述与实际行为的不匹配。
The skill advertises and appears to rely on file access and shell-driven CLI operations, but it does not declare any explicit tool scope or permission boundaries. In an agent environment, missing scope declarations can cause overbroad or ambiguous access, making it easier for the skill to read unintended local files or invoke shell commands without clear containment.
The activation language is broad enough to trigger on ordinary knowledge questions, which can cause the agent to invoke this skill unexpectedly and consult local knowledge sources when not necessary. In a knowledge-base skill with file and shell capabilities, over-triggering increases the chance of unnecessary exposure of local content, privacy leakage, or unintended tool use.
The workflow says user questions automatically cause recall from the knowledge base, but it does not define clear trigger constraints, consent checks, or data-scope limits. This can lead to routine prompts causing automatic local searches and surfacing snippets from personal documents, which is especially risky in a personal knowledge-base context.
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.
def init_db():
conn = get_db()
conn.execute("""CREATE TABLE IF NOT EXISTS kb (
id INTEGER PRIMARY KEY AUTOINCREMENT,
path TEXT UNIQUE NOT NULL,
tag TEXT DEFAULT '其他',
The skill's purpose is document indexing/search, yet PDF handling launches a fresh Python interpreter to execute dynamically constructed code. Even without obvious command injection, this introduces an unnecessary code-execution primitive and extra attack surface when processing untrusted PDFs, making the skill more dangerous than its stated function requires.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
elif path.suffix == ".pdf":
import subprocess
script = f"import pdfplumber; p=pdfplumber.open({str(path)!r}); print('\\n'.join([x.extract_text() or '' for x in p.pages]))"
result = subprocess.run(
["python3", "-c", script],
capture_output=True, text=True, timeout=30
)
When a file is added, the full extracted content is copied into a persistent SQLite database under ~/.yuzhi without any prominent warning, consent prompt, or data-minimization option. This can silently duplicate sensitive material from user documents, increasing exposure if the local profile, backups, or the database itself are later accessed by other software or users.
The delete command performs a destructive database delete immediately after locating the record. While it prints a success message afterward, there is no confirmation prompt, cautionary comment/docstring, or other user disclosure before the irreversible removal occurs.
The skill's docstring, argparse description, help text, and runtime messages are all presented only in Chinese. This imposes a specific language on all users without any visible opt-in, selection mechanism, or documented locale limitation.