Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xSteph Pentest ai agents Scope Guard

From Leeroopedia
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

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

Uses Heuristics

Related Implementations

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment