Field manual · 06

Web and API testing

Assessment passes, browser sessions, OpenAPI/GraphQL discovery, scoped requests, fuzzing and Nuclei.

Three levels of fidelity, one boundary. A fetch-only assessment for the cheap checks, a real Chromium session for what needs a browser, and an API inventory with controlled requests and fuzzing. All three check RoE and scope before the first byte.

The bounded web assessment

pentest_web_assess takes one in-scope url and one bounded fetch pass. It is not a browser: no JavaScript runs, no session is created, and redirects are followed manually so a redirect to a non-HTTP scheme is never fetched. The response body is capped at 2 MB, headers at 100, and set-cookies at 20; cookie values are never echoed back.

Check familyExamplesEvidence recorded
Security headersCSP presence and strength, HSTS max-age, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-PolicyThe exact header value or its absence
Cookies and formsSecure/HttpOnly/SameSite flags, password form over plaintext HTTP, state-changing form without a CSRF tokenThe cookie attributes and the form action/inputs
Technology and endpointsLibrary and framework hints, script sources, in-page links and API-looking pathsThe script URL or body signature that matched
Safe probesHEAD-only, same-origin, never followed: /.git/HEAD, /.env, /server-status; presence of robots.txt, sitemap.xml, security.txtThe status code and the response excerpt
pentest_web_assess({ url: "https://shop.example.com/" })

Every finding carries a WSTG id and OWASP category, and the whole pass records one fact with its findings. Bounds are deliberate: 40 findings, 80 checks, 10 forms, 20 endpoints. When the output is truncated, the marker and byte count tell you so.

Browser sessions

pentest_browser drives an isolated Chromium session. launch takes a URL and returns a browserId; every later action takes that id. The 13 actions are launch, goto, snapshot, click, fill, press, eval, screenshot, cookies, storage, network, console and close.

pentest_browser({
  action: "launch",
  url: "https://shop.example.com/login",
  width: 1440,
  height: 900
})

pentest_browser({
  action: "fill",
  browserId: "<from-launch>",
  selector: "#email",
  value: "qa+engagement@example.com",
  submit: true
})

Scope is enforced at launch and on every navigation: only http(s) URLs whose host matches a target, domain or IPv4 CIDR are accepted, exclusions win, and metadata, file:, data:, javascript:, chrome: and devtools: are refused. Top-level Document requests are intercepted through the DevTools protocol, so a redirect cannot leave scope; blocked attempts appear in the session action log. Subresources still load, which is what lets a real page render.

JavaScript dialogs are dismissed by default so a stuck alert cannot freeze a snapshot or an eval; set browser.autoDismissDialogs: false when you need to inspect one. Sessions are limited to three by default and close after ten idle minutes. Screenshots land in the session's browser artifact directory and become evidence automatically. Without a Chromium binary the drawer reports available: false with the discovery reason, and the fetch-based tools keep working.

Web test drawer showing a ready Chromium session, current URL and title, action counters and a screenshot preview of the Acme Portal login
Figure 1. A live browser session. URL, title, last action, counters for screenshots, requests and console entries, and the latest capture. The scope notice is not advisory: navigation outside it is blocked at the document level and logged.

Worked example, web. Assess the login page, then use the browser only for what the fetch pass cannot see: the JavaScript-rendered error state and the authenticated dashboard. Record a finding with the WSTG id the assessment supplied rather than inventing one.

pentest_browser({ action: "snapshot", browserId: "<from-launch>" })
pentest_browser({ action: "screenshot", browserId: "<from-launch>", fullPage: true })
pentest_add_finding({
  title: "Login error state reflects the submitted address",
  severity: "low",
  cwe: "CWE-79",
  owasp: "A03:2021",
  wstgIds: ["WSTG-INPV-01"],
  evidence: "Snapshot after submit shows the address echoed unencoded.",
  status: "unverified"
})

API discovery

pentest_api_discover takes an in-scope baseUrl and merges five sources into one inventory. probeLimit caps common-path probes (0–100, default 60) and maxRequests caps the total request budget (1–200, default 120). The run is same-origin, no-redirect for discovery, rate-limited and bounded at 300 endpoints.

SourceWhat it contributesLimit
Browser-observed trafficXHR/fetch endpoints seen in a session passed as browserIdUp to 500 observed entries, merged first
OpenAPI / SwaggerPaths, methods, parameters, request bodies, security and server baseJSON is parsed fully; YAML is detected and reported but not expanded
GraphQL introspectionTypes, queries and mutations from /graphql and /api/graphqlUp to 200 field names per type
JavaScript bundlesAPI-looking paths extracted from supplied same-origin scripts10 scripts, 1 MB each, 200 endpoints
Bounded path probeCommon API paths and methodsCaller probeLimit; found statuses are 200/201/204/301/302/401/403/405
pentest_api_discover({
  baseUrl: "https://shop.example.com/api/",
  browserId: "<from-launch>",
  probeLimit: 40,
  maxRequests: 80
})

Endpoints become api-endpoint assets plus an inventory fact, so the API surface appears in the Assets tab and the report without a second recording step.

Single scoped requests

pentest_api_request is the explicit escape hatch for one authenticated call. It takes url, optional method (default GET), headers, body, contentType and allowRedirects. Redirects are manual, same-origin and capped at five; the response body is capped at 2 MB and only a 4 KB excerpt is returned, with bodyBytes and truncated.

pentest_api_request({
  method: "PATCH",
  url: "https://shop.example.com/api/v1/orders/1042",
  headers: { "Authorization": "Bearer <token>", "Content-Type": "application/json" },
  body: '{"status":"refunded"}',
  allowRedirects: false
})

Authorization, Proxy-Authorization, Cookie, Set-Cookie and X-Api-Key values are redacted in the result while the header names stay visible; token-looking query values are masked in stored targets. The exchange is captured as http evidence, so the redaction applies to the console representation, not to the proof you can download from the vault.

Parameter fuzzing

pentest_api_fuzz substitutes one parameter at a time. It sends a benign baseline first, then the payloads, and compares each response against that baseline. Nine payload families ship: sqli, xss, lfi, ssrf, nosql, redirect, traversal, idor and format. Explicit payloads override the category.

ControlRangeDefault
locationquery, path, body, headerrequired
concurrency1–83
ratePerSecond1–5010
maxRequests1–200100
Per-request timeoutfixed15 seconds; redirects are never followed

An anomaly is a status change, a body-length delta, a timing spike, a reflected payload or an error signature. The run stops after five consecutive transport errors and returns bounded partial results rather than pretending the endpoint was clean. Start with a small maxRequests and a low rate; widen only when the target tolerates it.

pentest_api_fuzz({
  url: "https://shop.example.com/api/v1/search?q=FUZZ",
  method: "GET",
  location: "query",
  parameter: "q",
  category: "sqli",
  ratePerSecond: 5,
  maxRequests: 30
})
API test drawer with discovery results for an OpenAPI document and GraphQL endpoint, base URL, 24 endpoints with methods and response codes
Figure 2. The API inventory after discovery. Spec title and version, GraphQL type/query/mutation counts, and endpoints with method, source, auth hint and last status. Each row is an asset; the inventory itself is a fact with a request budget behind it.

Worked example, API. Discover the surface, read the inventory for undocumented or unauthenticated endpoints, then make one explicit request and one small fuzz run. Keep the evidence and record only what the responses actually show.

pentest_api_request({
  method: "GET",
  url: "https://shop.example.com/api/v1/orders/1042",
  allowRedirects: false
})

pentest_api_fuzz({
  url: "https://shop.example.com/api/v1/orders/{parameter}",
  location: "path",
  parameter: "id",
  category: "idor",
  maxRequests: 20
})

Nuclei template scans

pentest_nuclei runs a scoped, rate-limited template scan and parses JSONL matches into a fact plus structured findings. Filters are url (required), severity (comma-separated), tags, templates and rateLimit (5–150, default 50).

pentest_exec({ tool: "nuclei", args: ["-update-templates"] })
pentest_nuclei({
  url: "https://shop.example.com/",
  severity: "critical,high",
  tags: "cve,exposure",
  rateLimit: 25
})

The apt package ships no templates. Install them once inside the container with -update-templates; they land in /root/.local/nuclei-templates. The scan parses up to 100 JSONL matches into one fact and returns runId, count and the first 50 structured matches. A match is a candidate, not a confirmed finding: convert it with evidence, and say so when the template is informational.

Rate is part of the authorization

Fuzzing and template scans are the two places where volume can hurt a target. A low ratePerSecond and a small maxRequests are not timidity; they are how you keep a production system inside the agreed impact. If the target shows instability, stop and record the observation instead of completing the run.

Every request left a record

Web assessments, browser screenshots, API inventories, single requests and fuzz exchanges are captured as evidence automatically. You do not need a second tool to preserve the proof; you need to read the response before you write the finding.

Next: the remaining chapters cover exploitation paths, evidence and findings, reports and the export bundle. Start at the field manual index, or read the full tool reference and the sample deliverables.

What good looks like

  • pentest_web_assess is fetch-only: headers, cookies, forms, technology, endpoints and three safe HEAD probes, all bounded.
  • Browser navigation is scope-intercepted at the document level; a redirect cannot leave scope, and blocked attempts are logged.
  • API discovery merges observed traffic, OpenAPI/GraphQL, JavaScript mining and a bounded path probe into asset nodes.
  • Requests redact credentials in the result; fuzzing compares against a baseline and stops on repeated transport errors.
  • Nuclei matches are candidates: install templates once, keep the rate low, and convert a match only with evidence.