T01 · Skill Instruction Hijacking
- Location
scripts/rag_web_ui.py:925- Finding
Unauthenticated Persistent Prompt Hijacking
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill matches its RAG-building purpose, but its unauthenticated Web UI and model-download code create high-impact security risks.
Install only if you are comfortable reviewing and hardening the code first. Do not expose the Web UI on a shared network; bind it to loopback, add authentication, avoid custom model identifiers from untrusted sources, pin dependencies, and use only trusted LLM endpoints because RAG context may be sent there.
scripts/rag_web_ui.py:925Unauthenticated Persistent Prompt Hijacking
scripts/rag_web_ui.py:1143Unauthenticated Administrative Web Server Exposed on All Network Interfaces
scripts/embedding_model_manager.py:168Arbitrary Python Code Execution Through Crafted Model Identifier
scripts/rag_web_ui.py:49Path Traversal in Configuration Template Save, Load, and Delete Operations
scripts/rag_standalone.py:48Arbitrary LLM Destination Enables SSRF and Knowledge-Base Data Disclosure
scripts/rag_web_ui.py:86Stored Script Injection Through Unescaped Prompt and Configuration Rendering
scripts/rag_env_setup.py:28Unpinned Automatic Installation of Large Third-Party Dependency Set
This finding is strengthened by the document itself acknowledging an independent mode that calls external LLM services, while branding the skill as a local RAG builder. Misrepresenting external dependency and local-only expectations can expose private documents or prompts to unintended network endpoints if a user assumes the system is fully local and isolated.
This finding is strengthened by the document itself acknowledging an independent mode that calls external LLM services, while branding the skill as a local RAG builder. Misrepresenting external dependency and local-only expectations can expose private documents or prompts to unintended network endpoints if a user assumes the system is fully local and isolated.
This finding is strengthened by the document itself acknowledging an independent mode that calls external LLM services, while branding the skill as a local RAG builder. Misrepresenting external dependency and local-only expectations can expose private documents or prompts to unintended network endpoints if a user assumes the system is fully local and isolated.
This finding is strengthened by the document itself acknowledging an independent mode that calls external LLM services, while branding the skill as a local RAG builder. Misrepresenting external dependency and local-only expectations can expose private documents or prompts to unintended network endpoints if a user assumes the system is fully local and isolated.
Referenced artifact was not completely inspected
> 📚 **渐进式加载**:本技能采用渐进式 MD 体系,`SKILL.md` 为入口(≤230行),详细内容拆分到 `references/*.md` 按需加载。
Referenced artifact was not completely inspected
python scripts/rag_web_ui.py
Referenced artifact was not completely inspected
python scripts/rag_web_ui.py
Referenced artifact was not completely inspected
python scripts/rag_web_ui.py
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
def _download_with_hf_mirror(model_id, cache_dir):
"""使用 HuggingFace 镜像下载"""
env = os.environ.copy()
env["HF_ENDPOINT"] = "https://hf-mirror.com"
script = f"""
import os, sys
The skill advertises operational capabilities such as environment repair, package installation, model downloads, web UI launch, and knowledge-base management, which imply shell, filesystem, environment, and network access, yet it does not declare an explicit tool scope. This creates a permission-transparency gap: a host agent or reviewer may underestimate what the skill can cause, increasing the chance of unintended execution of high-effect actions like installs, downloads, and file writes.
The manifest description, trigger list, and negative triggers are entirely specified in Chinese, which indicates the skill is designed to activate and operate only for Chinese-language inputs. The file does not offer an opt-in language choice or explain a justified region-specific constraint, so this is a natural-language locale policy concern.
This markdown file is written entirely in Chinese, including all architectural descriptions and operational notes, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking audience. The policy requires flagging language or locale constraints when they are imposed without user opt-in or a clear documented justification.
The document title, example queries, comments, and prompt templates are all presented in Chinese, and the usage examples hard-code Chinese queries such as "什么是 RAG?". This indicates a language-specific interaction pattern without any opt-in, alternative locale, or explanation that the skill is intended only for a Chinese-language context.
The document title and all instructions are written in Chinese, but the guide does not state that Chinese is optional, user-selectable, or required for a specific regional purpose. Under the language/locale policy, this can be a natural-language policy violation because it imposes a specific locale without user opt-in.
The guide documents a destructive deletion command for knowledge bases without warning that it removes stored data. In an agent or copy-paste workflow, users may run the command assuming it is reversible or harmless, leading to accidental data loss of indexed documents and configuration associated with that knowledge base.
The guide explicitly states that skill mode makes no external HTTP requests, creating a strong safety guarantee for agent integrations. In the same documented interface, it also exposes an import operation without clearly constraining inputs to local files; if that operation accepts remote URLs or fetches remote content, integrators may unknowingly permit outbound network access under a 'no HTTP' assumption.
The guide walks users through configuring and verifying external LLM endpoints without warning that prompts, retrieved context, and possibly sensitive local knowledge-base content may be sent to that service. In a RAG skill, this is especially relevant because retrieved documents can contain proprietary or personal data, so omission of the privacy boundary can lead to unintentional data disclosure.
The remove_model function performs shutil.rmtree on the stored model path, which is a destructive file deletion operation. Although the CLI later prints the result, there is no confirmation prompt, pre-deletion warning, or explicit user-facing disclosure in the function itself before the irreversible action occurs.
Natural-language strings throughout the module, including the top-level description and user-facing CLI help/output, are written only in Chinese. The file does not offer a language/locale option or explain that the tool is intentionally restricted to a Chinese-speaking environment, which can violate language-choice policy.
Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.
entry = {
"path": kb_path,
"description": description,
"created": str(__import__("datetime").datetime.now()),
"doc_count": 0,
}
if model_id:
The delete_knowledge_base function performs an unconditional shutil.rmtree() on a path taken from the persisted knowledge base index, with no path validation, confirmation, or confinement check that the target remains under KB_DIR. If the index file is corrupted, manually edited, or influenced elsewhere in the application, deletion could recursively remove arbitrary filesystem locations, causing severe data loss.
The lock cleanup logic automatically deletes files and directories under the pip cache heuristic once they appear stale, without strong validation that the targets are genuine pip lock artifacts. In an agent-operated local environment, automatic deletion increases the risk of accidental data loss or removal of attacker-planted paths if directory contents are manipulated.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def check_pip():
"""检查 pip 是否可用"""
try:
result = subprocess.run(
[get_python_path(), "-m", "pip", "--version"],
capture_output=True, text=True, timeout=30
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def list_installed():
"""列出已安装包(包名统一转为小写+连字符格式便于匹配)"""
try:
result = subprocess.run(
[get_python_path(), "-m", "pip", "list", "--format=columns"],
capture_output=True, text=True, timeout=30
)
This subprocess.Popen path executes python -m pip install ... where package names and mirror URLs can be influenced by CLI input (--mirror, optional package names) and are used to perform network-based package installation. While it is not shell injection, it is a genuine supply-chain risk because the script can fetch and install arbitrary packages from attacker-chosen indexes or package names, modifying the environment and potentially executing untrusted package install code.
os.makedirs(LOG_DIR, exist_ok=True)
try:
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
Detected: suspicious.autonomous_credential_egress