Implementation:0xSteph Pentest ai build oracle from finding
| Knowledge Sources | |
|---|---|
| Domains | Security_Testing, Verification |
| Last Updated | 2026-10-23 12:00 GMT |
Overview
Concrete dispatcher that maps a finding's verification recipe to a concrete Oracle instance via a registry of recipe builders, provided by the pentest-ai engine.
Description
build_oracle_from_finding is the generic dispatch function that turns a candidate finding's verification_recipe dict into an executable Oracle. It parses the recipe (dict or JSON string), looks up the oracle kind in a _RECIPE_BUILDERS registry, and calls the matching builder function.
The registry supports 20+ oracle kinds including: idempotent_replay, differential, oast, unescaped_reflection, sqli_login_bypass, jwt_alg_none, ssrf, ssti, xxe, path_traversal, data_exposure, http_desync, stored_xss, host_header_poison, type_confusion, mass_assignment, sequential_idor, race_condition, asrep, dom_xss, deserialization_bounded, nosql_injection.
A finding with no recipe, or whose recipe's oracle kind has no registered builder, returns None — the finding honestly stays a candidate. Building an oracle off an LLM-authored title would let an LLM assertion earn a verdict, which the product law forbids.
Usage
Import this when you need to:
- Build an oracle for a finding during the orchestrator's validation phase
- Build an oracle for capsule replay
- Stamp verdicts during a probe sweep
Code Reference
Source Location
- Repository: pentest-ai
- File: engine/oracles.py
Signature
def build_oracle_from_finding(
finding: dict[str, Any],
session: Any,
intensity: str = "normal",
) -> Oracle | None:
"""Return an Oracle for a finding, or None.
Requires a probe-emitted verification_recipe (generic dispatch).
A finding with no recipe stays a candidate.
"""
def _parse_recipe(finding: dict[str, Any]) -> dict[str, Any] | None:
"""Parse verification_recipe from dict or JSON string."""
# Registry of oracle kinds to builder functions
_RECIPE_BUILDERS: dict[str, Callable] = {
"idempotent_replay": _build_idempotent_replay_oracle,
"differential": _build_differential_oracle,
"oast": _build_oast_oracle,
"unescaped_reflection": _build_unescaped_reflection_oracle,
"sqli_login_bypass": _build_sqli_login_bypass_oracle,
# ... 20+ kinds total
}
Import
from engine.oracles import build_oracle_from_finding
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| finding | dict[str, Any] | Yes | Finding dict with verification_recipe, target, and recipe-specific fields |
| session | Any | Yes | aiohttp.ClientSession for live HTTP requests |
| intensity | str | No | Controls replay N: stealth=2, normal=3, aggressive=5 |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | None | Protocol with .kind and async verify() -> OracleResult; None if no recipe/builder |
Usage Examples
Building and Running an Oracle
import aiohttp
from engine.oracles import build_oracle_from_finding
from engine.verifier import Verifier
async with aiohttp.ClientSession() as session:
for finding in findings:
oracle = build_oracle_from_finding(finding, session, intensity="normal")
if oracle is None:
# No recipe or unknown oracle kind — stays candidate
continue
receipt = await Verifier().verify_candidate(
engagement_id=engagement_id,
finding_id=finding["id"],
oracle=oracle,
)
if receipt.verdict.value == "verified":
await db.update_finding_verdict(finding["id"], "verified", receipt.model_dump_json())