Implementation:0xSteph Pentest ai agents Scope Guard
| Knowledge Sources | |
|---|---|
| Domains | Security, Safety, OPSEC |
| Last Updated | 2026-10-22 12:00 GMT |
Overview
Concrete shared scope enforcement prompt block for Tier 2 execution-capable agents provided by the pentest-ai-agents toolkit.
Description
The _scope-guard.md file is not a standalone agent. It contains the shared scope enforcement, command composition, OPSEC tagging, evidence handling, and hard refusal list prompt text that all Tier 2 (Bash-capable) agents embed into their system prompts. The underscore prefix signals Claude Code not to route to this file as an agent.
This is a Pattern Doc: it defines a prompt-level safety framework, not a callable API. Tier 2 agents incorporate this text verbatim (or with agent-specific additions) to enforce a two-layer safety model: prompt-level scope enforcement plus Claude Code's per-command permission gate.
Usage
- Embedded in Tier 2 agents: All execution-capable agents (recon-advisor, vuln-scanner, web-hunter, ad-attacker, exploit-chainer, poc-validator, etc.) include this block in their system prompts.
- Session initialization: The block enforces scope declaration before any command execution against targets.
- Command validation: Every composed Bash command is validated against the scope declaration and hard refusal list before execution.
- OPSEC tagging: Every command is tagged with QUIET, MODERATE, or LOUD noise level before presentation to the user.
Code Reference
Source Location
- Repository: pentest-ai-agents
- File: agents/_scope-guard.md
Signature
# Scope Guard (Shared Prompt Block for Tier 2 Agents)
## Scope Enforcement (MANDATORY)
### Session Initialization
# 1. Ask user to declare authorized scope (IP ranges, domains, URLs, cloud accounts)
# 2. Ask for engagement type (external, internal, web app, cloud, wireless)
# 3. Store scope declaration for the session
# If no scope declared → advisory mode only, no execution
### Pre-Execution Validation
# Checklist: target in scope, non-destructive, no unauthorized writes,
# callbacks to controlled infra, no permission bypass
### Hard Refusal List (No Authorization Overrides)
# DoS, mass internet scanning, worms, persistent backdoors,
# false-flag, safety-of-life systems, CSAM, payment fraud
### Command Composition Rules
# Explain before executing, least aggressive first, rate limit,
# save evidence, no blind piping
### OPSEC Tagging
# QUIET: passive (DNS, WHOIS, cert transparency)
# MODERATE: active but common (TCP connect, HTTP requests)
# LOUD: likely to trigger IDS/IPS/WAF/SOC
### Evidence Handling
# Format: {tool}_{target}_{YYYYMMDD_HHMMSS}.{ext}
# Sanitize target: replace / with -, remove special chars
Import
# Not imported — embedded as prompt text in Tier 2 agent definitions.
# The CI validation workflow (.github/workflows/validate.yml) verifies
# that all Bash-capable agents include the scope-guard block.
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| Scope declaration | text | Yes (for execution) | IP ranges, domains, URLs, cloud accounts |
| Engagement type | text | Yes (for execution) | external, internal, web, cloud, wireless |
| Bash command | text | N/A | Validated against scope before execution |
Outputs
| Name | Type | Description |
|---|---|---|
| Validation result | decision | Pass (command proceeds) or Refuse (with explanation) |
| OPSEC tag | enum | QUIET, MODERATE, or LOUD |
| Evidence files | filesystem | Timestamped tool output files |
Usage Examples
Scope Declaration Flow
# At session start, the agent asks:
"Before I can execute any commands, I need you to declare the authorized scope:
1. What IP ranges, domains, or URLs are in scope?
2. What type of engagement is this? (external, internal, web, cloud, wireless)"
# User provides: "Scope is 10.10.0.0/24, internal pentest"
# Agent stores scope and validates all subsequent commands against it.
# If user later asks to scan 192.168.1.0/24, agent REFUSES:
"Target 192.168.1.0/24 is outside the declared scope (10.10.0.0/24).
Please update the scope if this target is authorized."
OPSEC Tagging Example
# User requests: "Run an nmap scan on 10.10.1.50"
# Agent tags and explains:
"[MODERATE] nmap -sT -sV --min-rate 100 --max-rate 1000 --host-timeout 300s 10.10.1.50
This performs a TCP connect scan with service detection. It will appear as
standard network traffic. A quieter alternative: 'nmap -sT -p 80,443,22 10.10.1.50'
for a targeted port check."
# Agent then asks for user approval before executing via Claude Code's Bash tool.
Related Pages
Implements Principles
- Principle:0xSteph_Pentest_ai_agents_Scope_Enforcement_and_Safety
- Principle:0xSteph_Pentest_ai_agents_Reconnaissance
- Principle:0xSteph_Pentest_ai_agents_Vulnerability_Scanning
- Principle:0xSteph_Pentest_ai_agents_PoC_Validation
- Principle:0xSteph_Pentest_ai_agents_Attack_Chain_Analysis
Uses Heuristics
- Heuristic:0xSteph_Pentest_ai_agents_OPSEC_Tagging
- Heuristic:0xSteph_Pentest_ai_agents_Least_Aggressive_First
Related Implementations
- Implementation:0xSteph_Pentest_ai_agents_Recon_Advisor_Agent embeds this block
- Implementation:0xSteph_Pentest_ai_agents_Vuln_Scanner_Agent embeds this block
- Implementation:0xSteph_Pentest_ai_agents_Web_Hunter_Agent embeds this block
- Implementation:0xSteph_Pentest_ai_agents_Exploit_Chainer_Agent embeds this block
- Implementation:0xSteph_Pentest_ai_agents_Poc_Validator_Agent embeds this block