Cyber Monday: 2XCYBER doubles your top-up, up to $2,000.Double my top-up

nc://zap

v0.1.0Pinned
Backnodecode-ai
ThomSharksecurity cells: harden scope, Nuclei containment, ffuf authority and scrub (#183)245fa9c· 2 Dec2 commits
test1 filecell.lisp5.3 KBscope.lisp11.1 KBtools.lisp14.2 KBwire.lisp6.0 KB

nodecode-zap

OWASP ZAP through its REST API, only against targets you list as in scope: spider a site, run an active scan, follow both, read the alerts grouped by kind, and export ZAP's report. Written for Nodecode from ZAP's documented API.

Get it

Tell the agent "add the zap cell", or run nodecode add nc://zap.

Set it up

The cell talks to a ZAP you run; nothing here vendors ZAP. Start it as a daemon with an API key, for example with the official image:

export ZAP_API_KEY=$(openssl rand -hex 16)
docker run -d --name zap -p 127.0.0.1:8080:8080 zaproxy/zap-stable \
  zap.sh -daemon -host 0.0.0.0 -port 8080 -config api.key=$ZAP_API_KEY \
  -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true

or zap.sh -daemon -port 8080 -config api.key=... from a desktop install. Keep ZAP_API_KEY in Nodecode's environment.

Then set the scope: the targets you are authorized to test. An empty scope refuses every spider and active scan. See config.example.jsonc:

Key Default What it does
base_url "http://127.0.0.1:8080" Where ZAP's API listens: http:// on a loopback address, or https://. A plain address: userinfo, a backslash, a query or a fragment is refused.
api_key_env "ZAP_API_KEY" The environment variable holding the key.
api_key none A key written here instead; the environment variable wins.
scope [] What a spider or active scan may reach. Only the operator sets it.
timeout 60 One API call's ceiling, in seconds.
max_alerts 100 How many alert kinds one zap_alerts answer lists.
max_alert_instances 5000 How many alert instances zap_alerts reads before grouping.
max_urls 200 How many URLs a finished spider's status lists.

A scope entry is a host, *.domain (any subdomain, not the apex), an IPv4 or IPv6 address, or an address block (192.0.2.0/24, 2001:db8::/32). A loopback, private, link-local, multicast or reserved address (IPv4-mapped and NAT64 forms included), or localhost, is reached only through an entry that names it or its block; a wildcard never reaches one, and a zoned IPv6 address (fe80::1%eth0) is never reached. A target with userinfo (user@), a backslash, a control character or a space in its host is refused, so the host checked is the host reached.

Use it

Tool ZAP API For
zap_version core/view/version Proves the connection and the key.
zap_spider spider/action/scan Crawl a site from a URL in scope; max_children, recurse, subtree_only. Answers a scan id.
zap_active_scan ascan/action/scan Attack what ZAP's tree holds under a URL in scope; recurse, in_scope_only, scan_policy. Answers a scan id.
zap_status spider/view/status, ascan/view/status, pscan/view/recordsToScan Progress and the passive queue; a finished spider lists its URLs.
zap_stop spider/action/stop, ascan/action/stop Stop one scan.
zap_alerts core/view/alerts Alerts grouped by kind, worst risk first; base_url, risk floor.
zap_report OTHER/core/other/{html,json,xml,md}report Write ZAP's full report to an absolute file path (never a folder); overwrite to replace one.
3 alert kinds in 7 instances: Medium 2, Low 1
  MEDIUM .env Information Leak (confidence Medium, CWE-215, plugin 40034) - 1 place: https://app.example.com/.env
    Fix: Ensure the .env file is not accessible.
  MEDIUM Content Security Policy (CSP) Header Not Set (confidence High, CWE-693, plugin 10038) - 4 places: https://app.example.com/, https://app.example.com/admin/, https://app.example.com/robots.txt ...
    Fix: Ensure that your web server, application server, load balancer, etc. is configured to set the Content-Security-Policy header.
  LOW X-Content-Type-Options Header Missing (confidence Medium, CWE-693, plugin 10021) - 2 places: ...

/zap checks the connection, the key and ZAP's version.

The key and the evidence

  • The API key rides only the X-ZAP-API-Key header, never a URL, and is sent in clear only to a loopback ZAP: any other base_url must be https://.
  • Every answer and every refusal has the key scrubbed out, so an error that echoes it cannot carry it into the conversation. ZAP drops a request with a wrong or missing key without answering; the cell says so.
  • zap_alerts never shows an alert's evidence, attack or other notes, which can quote a token or a password from the target. They stay in ZAP and in the report zap_report writes, which the answer says to keep private.

Test

.github/test-cell.sh tools/nodecode-zap

Eighteen tests, offline: nlk:http is stubbed to answer by URL, so the scope, each tool's API call and parameters, the key's header and its scrubbing, and the alert grouping are asserted with no ZAP and no network.

License

MIT. See LICENSE. ZAP is Apache-2.0 and is not included.

Add nc://zap

  1. 1

    Install Nodecode

    Once per machine.

    $ curl -fsSL https://nodecode.ai/install.sh | sh
  2. 2

    Add the cell

    Pinned at 245fa9c.

    $ nodecode add nc://zap

    Or tell the agent add the zap cell.