T01 · Skill Instruction Hijacking
- Location
scripts/expert_toolkit.py:281- Finding
Untrusted Role Files Are Promoted into Agent Instructions Without Validation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/expert_toolkit.py:27-28, 121-137, 281-291, 360, 377
Vulnerability Type: Prompt injection through untrusted local role content
Risk Level: MediumVulnerable Code
python DEFAULT_ROLES_ROOT = os.path.expanduser( "~/.openclaw/workspace/knowledge/agency-orchestrator/roles" ) ROLES_ROOT = Path(os.getenv( "EXPERT_TOOLKIT_ROLES_ROOT", DEFAULT_ROLES_ROOT ))python for md_file in category_dir.glob('*.md'): if md_file.name.startswith('.'): continue try: with open(md_file, 'r', encoding='utf-8') as f: content = f.read() except OSError as e: print(f"⚠️ 读取 {md_file} 失败: {e},跳过") continue chinese_name = self._extract_chinese_name( content, md_file.stem ) role = ExpertRole( md_file, md_file.stem, category, chinese_name ) role.content = contentpython def build_system_prompt(role: ExpertRole, user_query: str) -> str: """构建完整的system prompt""" role_content = role.load_content() return f"""{role_content} --- # 用户问题 {user_query} 请以{role.chinese_name}的专业身份回答用户问题。 """python prompt = build_system_prompt(role, args.strip())python output.append(build_system_prompt(role, requirement))Technical Analysis
The Skill discovers Markdown role files in a directory that can be changed through the
EXPERT_TOOLKIT_ROLES_ROOTenvironment variable. It reads each selected file in full and inserts its contents verbatim before the user's request in a string explicitly constructed as a system prompt.There is no integrity verification, provenance validation, trusted-file allowlist, content filtering, or effective instruction boundary between imported role content and controlling Agent instructions. The audited package does not in ...[truncated 2122 chars]
- Remediation
View remediation
Remediation Suggestions
- Bundle reviewed role files with the Skill or maintain an explicit allowlist of approved files and cryptographic hashes.
- Resolve and canonicalize the role root and every discovered file before reading it. Reject files outside the approved root and reject symbolic links unless they are explicitly required and securely validated.
- Avoid permitting unrestricted environment-variable replacement of the trusted role repository. If configurability is necessary, require an administrator-approved path and verify its ownership and permissions.
- Treat role Markdown as untrusted data rather than system-level instructions. Keep platform safety rules and task constraints at a higher instruction priority.
- Wrap imported role content in a clearly defined data boundary and instruct the consuming Agent not to follow commands embedded in that data.
- Validate role documents against an approved schema and reject content containing prohibited instruction patterns or unexpected tool-use directives. Filtering should supplement, not replace, instruction isolation and integrity checks.
- Run the consuming Agent with least privilege and require explicit user confirmation for sensitive filesystem, shell, network, credential, or memory operations.
- Record the selected role's canonical path and integrity hash for auditing, and fail closed when validation cannot be completed.
