Principle:0xSteph Pentest ai Playbook Driven Execution
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Methodology |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
A methodology-sharing pattern that encodes repeatable pentest approaches as ordered YAML phases with tool invocations, gating conditions, and phase dependencies — the way Nuclei templates share detection rules.
Description
Playbook Driven Execution is the principle that a penetration testing methodology can be encoded as a declarative YAML file with ordered phases, each specifying which tools to invoke, optional conditions that gate whether a phase runs, and dependencies on earlier phases. It solves the problem that pentest methodologies are traditionally tacit knowledge locked in a tester's head.
A playbook has:
- Inputs: Named parameters (e.g., target) with defaults, required flags, and env-var expansion
- Phases: Ordered list, each with an id, tool list, optional depends_on, optional condition, args, manual flag, and checklist
- Conditions: A sandboxed expression language (AST-walked, not eval) supporting has_finding(severity='high'), count_findings(...) > 2, phase_ran('recon'), and boolean ops
- Validation: Duplicate phase IDs, dangling dependencies, bare credential keys (refused — use auth_profile), intensity constraints
Execution creates an engagement, walks the planned phases, runs each tool through the registry or builtins, enforces scope per request, and persists findings to the DB.
Usage
Use this principle when:
- You want to share repeatable methodologies across teams (like Nuclei templates for pentest approaches)
- Phase gating depends on live findings (only run exploitation if recon found open ports)
- You need a dry-run mode that shows which phases will run and why
- Methodology should be versioned, authored, and shareable
Theoretical Basis
Phase planning is a conditional dependency graph:
# Abstract planning (NOT real implementation)
def plan_phases(playbook, findings):
ctx = ConditionContext(findings=findings)
for phase in playbook.phases:
if dependency_skipped(phase.depends_on):
skip(phase)
elif phase.condition and not eval_condition(phase.condition, ctx):
skip(phase)
else:
run(phase)
Condition evaluation uses an AST walker with a whitelist:
Failed to parse (syntax error): {\displaystyle \text{eval\_condition}(\text{expr}, \text{ctx}) = \text{ast.walk}(\text{expr}) \to \text{bool} }
Allowed calls: has_finding, count_findings, any_finding, phase_ran, phase_skipped. No attribute access, no function calls outside the registered helpers.