Principle:0xSteph Pentest ai agents Scope Enforcement and Safety
| Knowledge Sources | |
|---|---|
| Domains | Security, Safety, OPSEC, Authorization |
| Last Updated | 2026-10-22 12:00 GMT |
Overview
Two-layer safety model enforcing scope boundaries, command validation, OPSEC classification, and hard refusal categories for authorized penetration testing.
Description
Scope Enforcement and Safety is the principle that no command executes against a target without (1) a declared scope, (2) validation that the target is within that scope, and (3) explicit user approval. It addresses the fundamental risk of AI-driven penetration testing: an autonomous agent could execute destructive or out-of-scope commands without human oversight.
The principle implements a two-layer safety model:
- Layer 1 (Prompt-Level): Every Tier 2 agent embeds a scope enforcement block that requires scope declaration, validates targets against it, tags OPSEC noise levels, and refuses hard-refusal categories (DoS, mass scanning, worms, persistent backdoors, false-flag, safety-of-life systems, CSAM, payment fraud).
- Layer 2 (Tool-Level): Claude Code's per-command permission gate displays the full command to the user and waits for explicit `[y/n]` approval before execution.
No authorization overrides the hard refusal list — these are categorically out of scope for the toolkit.
Usage
Use this principle when:
- Designing execution-capable AI agents for penetration testing
- Establishing safety boundaries for autonomous security tools
- Defining OPSEC noise levels for command classification
- Creating hard refusal lists for categorically prohibited techniques
Theoretical Basis
The safety model applies a validation pipeline before any command executes:
Failed to parse (unknown function "\begin{cases}"): {\displaystyle \text{Execute}(cmd) = \begin{cases} \text{True} & \text{if } \text{in\_scope}(cmd) \wedge \neg\text{hard\_refusal}(cmd) \wedge \text{user\_approves}(cmd) \\ \text{False} & \text{otherwise} \end{cases} }
Pseudo-code Logic:
# Abstract safety model (NOT real implementation)
def can_execute(command, scope, user_approval):
# Layer 1: Prompt-level scope enforcement
if not scope_declared:
return Refuse("No scope declared. Advisory mode only.")
if not target_in_scope(command.target, scope):
return Refuse(f"Target {command.target} outside declared scope.")
if matches_hard_refusal(command):
return Refuse(f"Command matches hard refusal category: {category}")
opsec_tag = classify_noise(command) # QUIET, MODERATE, LOUD
explain(command, opsec_tag)
# Layer 2: Tool-level permission gate
if not user_approval:
return Abort("User denied execution.")
return Execute(command)
Practical Guide
- Declare scope first: Before any execution, require explicit scope declaration (IP ranges, domains, URLs).
- Validate every command: Each composed command must be checked against the declared scope.
- Enforce hard refusals: DoS, mass internet scanning, worms, persistent backdoors, false-flag, safety-of-life, CSAM, payment fraud — no exceptions.
- Tag OPSEC level: QUIET (passive), MODERATE (active but common), LOUD (likely to trigger alerts).
- Explain before executing: Show the full command, describe what it does, what it connects to.
- Least aggressive first: Default to the quieter option (TCP connect before SYN, passive DNS before zone transfer).
- Rate limit by default: Include timeouts and rate limits to avoid accidental DoS.
- No blind piping: Never pipe untrusted output into shell execution.
- Save evidence: Log all output to timestamped files.
- User is final checkpoint: Every command requires explicit user approval.
Related Pages
Implemented By
- Implementation:0xSteph_Pentest_ai_agents_Scope_Guard
- Implementation:0xSteph_Pentest_ai_agents_Claude_Code_Permission_Gate
- Implementation:0xSteph_Pentest_ai_agents_Recon_Advisor_Agent
- Implementation:0xSteph_Pentest_ai_agents_Vuln_Scanner_Agent
- Implementation:0xSteph_Pentest_ai_agents_Web_Hunter_Agent
- Implementation:0xSteph_Pentest_ai_agents_AD_Attacker_Agent
- Implementation:0xSteph_Pentest_ai_agents_Exploit_Chainer_Agent
- Implementation:0xSteph_Pentest_ai_agents_Poc_Validator_Agent