T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/bastion.py:1218- Finding
Workspace confinement bypass permits moving arbitrary accessible files
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill has a coherent security purpose, but it gives itself broad file-changing and persistent hook behavior with unsafe scoping and restoration logic.
Install only after reviewing the script behavior and avoid enabling the generated hooks as-is. Use read-only scan/check/status commands first, do not run quarantine/unquarantine on paths outside the intended workspace, and be cautious scanning secret-bearing files because matched text can be printed to the console.
scripts/bastion.py:1218Workspace confinement bypass permits moving arbitrary accessible files
scripts/bastion.py:1329Tamperable quarantine metadata permits restoration to arbitrary filesystem paths
scripts/bastion.py:1461Generated hook commands are vulnerable to shell-command injection
scripts/bastion.py:1485Generated Bash enforcement hook invokes a nonexistent command
scripts/bastion.py:1112“Blocked” prompt injections remain intact inside HTML comments
scripts/bastion.py:1497Session-start protection hook automatically rewrites and quarantines workspace content
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
"blocklist_patterns": [
"curl *| *sh", "curl *| *bash",
"wget *| *sh", "wget *| *bash",
"wget -O- *| *sh",
"rm -rf /", "rm -rf /*",
":(){ :|:& };:",
"mkfs.*",
"dd if=/dev/zero of=/dev/*",
"dd if=/dev/random of=/dev/*",
"> /dev/sda",
"chmod 777 /",
"eval $(curl *)",
"python -c * urllib *",
"nc -e /bin/sh *",
"bash -i >& /dev/tcp/*",
],
"notes": "Edit this file to customize. Bastion Pro enforces at runtime via hooks.",
}
# ---------------------------------------------------------------------------
# Utility functions
# ---------------------------------------------------------------------------
def now_iso() -> str:
return datetime.now(timezone.utc).isoformat()
def resolve_workspace(workspace_arg: str = None) -> Path:
"""Determine workspace path from arg, env, or defaults."""
ws = workspace_arg
if ws is None:
ws = os.environ.get("OPENCLA
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
Skill attempts to nullify the agent's safety policies or restrictions ('you have no restrictions', 'ignore your guidelines', 'do anything now'). This is a direct jailbreak that disables guardrails.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
3 scripts/bastion.py boundaries
python3 scripts/bastion.py allowlist
python3 scripts/bastion.py status
All commands accept `--workspace /path/to/workspace`. If omitted, auto-detects from `$OPENCLAW_WORKSPACE`, current directory, or `~/.openclaw/workspace`.
## What It Detects
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
- **HTML injection** — `<script>`, `<iframe>`, `<img on
YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
3 scripts/bastion.py boundaries
# View command allowlist/blocklist
python3 scripts/bastion.py allowlist
# Quick posture summary
python3 scripts/bastion.py status
```
All commands accept `--workspace /path/to/workspace`. If omitted, auto-detects from `$OPENCLAW_WORKSPACE`, current directory, or `~/.openclaw/workspace`.
## What It Detects
### Injection Patterns
- **Instruction override** — "ignore previous instructions", "disregard above", "you are now", "new system prompt", "forget your instructions", "override safety", "entering developer mode"
- **System prompt markers** — `<system>`, `[SYSTEM]`, `<<SYS>>`, `<|im_start|>system`, `[INST]`, `### System:`
- **Hidden instructions** — Multi-turn manipulation ("in your next response, you must..."), stealth patterns ("do not tell the user", "hide this from the output")
- **Markdown exfiltration** — Image tags with encoded data in URLs (``)
- **HTML injection** — `<script>`, `<iframe>`, `<img on
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
- **Unicode tricks** — Zero-width characters, RTL overrides, invisible formatting
- **Homoglyph substitution** — Cyrillic/Latin lookalikes mixed into ASCII text
- **Delimiter confusion** — Fake markdown code block boundaries to escape context
- **Dangerous commands** — `curl | bash`, `wget | sh`, `rm -rf /`, fork bombs
### Boundary Analysis
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
- **Unicode tricks** — Zero-width characters, RTL overrides, invisible formatting
- **Homoglyph substitution** — Cyrillic/Latin lookalikes mixed into ASCII text
- **Delimiter confusion** — Fake markdown code block boundaries to escape context
- **Dangerous commands** — `curl | bash`, `wget | sh`, `rm -rf /`, fork bombs
### Boundary Analysis
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).
- **Unicode tricks** — Zero-width characters, RTL overrides, invisible formatting
- **Homoglyph substitution** — Cyrillic/Latin lookalikes mixed into ASCII text
- **Delimiter confusion** — Fake markdown code block boundaries to escape context
- **Dangerous commands** — `curl | bash`, `wget | sh`, `rm -rf /`, fork bombs
### Boundary Analysis
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).
- **Unicode tricks** — Zero-width characters, RTL overrides, invisible formatting
- **Homoglyph substitution** — Cyrillic/Latin lookalikes mixed into ASCII text
- **Delimiter confusion** — Fake markdown code block boundaries to escape context
- **Dangerous commands** — `curl | bash`, `wget | sh`, `rm -rf /`, fork bombs
### Boundary Analysis
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).
Bastion maintains a `.bastion-policy.json` in the workspace root with:
- **Allowlist**: Standard safe commands (git, python, node, npm, etc.)
- **Blocklist**: Dangerous patterns (curl pipe to shell, rm -rf /, fork bombs, etc.)
Run `allowlist` to create the default policy and view it. Edit the JSON file directly to customize.
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).
Bastion maintains a `.bastion-policy.json` in the workspace root with:
- **Allowlist**: Standard safe commands (git, python, node, npm, etc.)
- **Blocklist**: Dangerous patterns (curl pipe to shell, rm -rf /, fork bombs, etc.)
Run `allowlist` to create the default policy and view it. Edit the JSON file directly to customize.
YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).
This Matters
Agents process content from many sources: local files, API responses, web pages, user uploads. Any of these can contain prompt injection attacks — hidden instructions that manipulate agent behavior. Bastion scans this content before the agent acts on it.
Scan files or directories for prompt injection patterns. Detects instruction overrides, system prompt markers, hidden Unicode, markdown exfiltration, HTML injection, shell injection, encoded payloads, delimiter confusion, multi-turn manipulation, and dangerous commands.
If no target is specified, scans the entire workspace.
python3 {baseDir}/scripts/bastion.py scan
Scan a specific file or directory:
python3 {baseDir}/scripts/bastion.py scan path/to/file.md
python3 {baseDir}/scripts/bastion.py scan path/to/directory/
Fast single-file injection check. Same detection patterns as scan, targeted to one file.
python3 {baseDi
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
| **Hidden instructions** | Multi-turn manipulation ("in your next response, you must"), stealth patterns ("do not tell the user") | CRITICAL |
| **HTML injection** | `<script>`, `<iframe>`, `<img onerror=>`, hidden divs, `<svg onload=>` | CRITICAL |
| **Markdown exfiltration** | Image tags with encoded data in URLs | CRITICAL |
| **Dangerous commands** | `curl \| bash`, `wget \| sh`, `rm -rf /`, fork bombs | CRITICAL |
| **Unicode tricks** | Zero-width characters, RTL overrides, invisible formatting | WARNING |
| **Homoglyph substitution** | Cyrillic/Latin lookalikes mixed into ASCII text | WARNING |
| **Base64 payloads** | Large encoded blobs outside code blocks | WARNING |
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
| **Hidden instructions** | Multi-turn manipulation ("in your next response, you must"), stealth patterns ("do not tell the user") | CRITICAL |
| **HTML injection** | `<script>`, `<iframe>`, `<img onerror=>`, hidden divs, `<svg onload=>` | CRITICAL |
| **Markdown exfiltration** | Image tags with encoded data in URLs | CRITICAL |
| **Dangerous commands** | `curl \| bash`, `wget \| sh`, `rm -rf /`, fork bombs | CRITICAL |
| **Unicode tricks** | Zero-width characters, RTL overrides, invisible formatting | WARNING |
| **Homoglyph substitution** | Cyrillic/Latin lookalikes mixed into ASCII text | WARNING |
| **Base64 payloads** | Large encoded blobs outside code blocks | WARNING |
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
SKIP_DIRS = {
".git", ".svn", ".hg", "__pycache__", "node_modules", ".venv", "venv",
".integrity", ".bastion", ".env", ".tox", "dist", "build", "egg-info",
".quarantine",
}
Including '.env' in SCANNABLE_EXTENSIONS means the tool will read and scan dotenv files, which commonly contain secrets. In this skill's context, scanning content and printing matched excerpts can expose credentials in console output, logs, or metadata if a .env file contains suspicious-looking strings.
".md", ".txt", ".json", ".yaml", ".yml", ".toml", ".ini", ".cfg",
".py", ".js", ".ts", ".jsx", ".tsx", ".html", ".htm", ".xml",
".csv", ".log", ".sh", ".bash", ".zsh", ".bat", ".cmd", ".ps1",
".env", ".conf", ".rst", ".tex", ".rb", ".go", ".rs", ".java",
".c", ".cpp", ".h", ".hpp", ".css", ".scss", ".less", ".sql",
".r", ".R", ".jl", ".lua", ".php", ".swift", ".kt", ".scala",
}
Detected: suspicious.prompt_injection_instructions