Skip to content

CSRF and CORS ​

These commands configure request-forgery protection (CSRF) and cross-origin enforcement (CORS). The same section also covers data leak prevention, file upload checks and virtual patches, which the CLI groups here.

waap csrf get ​

Prints the CSRF protection settings.

sh
waap csrf get -app NAME [-json]

waap csrf set ​

Changes the CSRF protection settings as a new version. KEY= goes back to the default. The first set turns CSRF protection on.

sh
waap csrf set -app NAME [-m WHY] [-dry-run] KEY=VALUE...

Keys:

  • enabled, mode
  • methods: checked methods, comma-separated. GET, HEAD and OPTIONS are refused.
  • trusted_origins: exact origins such as https://pay.example.com
  • skip: paths, with a * suffix for a prefix
  • tokens.pages: pages whose POST forms get a token
  • tokens.require: paths whose POSTs need a token. Needs tokens.pages.
  • tokens.ttl: 5m to 24h

waap csrf keys list ​

Lists the form token keys: ID, created, by, and which key signs new tokens. The keys themselves are never shown.

sh
waap csrf keys list -app NAME [-json]

waap csrf keys rotate ​

Makes a new form token key now, on the active node. Form tokens must be on. Tokens signed with a key older than the 2 kept are refused.

sh
waap csrf keys rotate -app NAME [-json]

waap cors get ​

Prints the CORS enforcement settings.

sh
waap cors get -app NAME [-json]

waap cors set ​

Changes the CORS enforcement settings. The first set turns CORS enforcement on.

sh
waap cors set -app NAME [-m WHY] [-dry-run] KEY=VALUE...

Keys:

  • enabled, mode
  • on_disallowed: block or strip
  • assess: reports unsafe upstream CORS answers

waap cors list get ​

Prints the CORS rules as YAML.

sh
waap cors list get -app NAME -list rules

waap cors list set ​

Replaces the CORS rules with the records in FILE (YAML or JSON; - reads standard input). Each record has name, paths, origins, methods, headers, expose, credentials, max_age and preflight (answer or pass). An empty list ([]) removes them.

sh
waap cors list set -app NAME -list rules -f FILE [-m WHY] [-dry-run]

waap cors test ​

Decides a browser request under the active CSRF and CORS policy, without sending it.

sh
waap cors test -app NAME -path PATH [-method POST] [-origin URL] [-site SITE] [-preflight METHOD] [-headers H1,H2] [-host HOST] [-scheme https] [-json]

For each module it shows the state, what it finds (csrf.cross_site, cors.origin, ...) and why. It also shows the CORS answer headers the rule sets, and the outcome in the application's mode.

  • -site is the Sec-Fetch-Site value: same-origin, same-site, cross-site or none.
  • -preflight makes an OPTIONS request a preflight.
  • -host defaults to the application's first hostname.
sh
waap cors test -app shop -path /api/orders -method POST -origin https://evil.example -site cross-site

waap dlp get ​

Prints the data leak prevention settings.

sh
waap dlp get -app NAME [-json]

waap dlp set ​

Changes the data leak prevention settings. The first set turns it on. Response signatures are the application's policy.signatures.response_body, changed with waap apps set.

sh
waap dlp set -app NAME [-m WHY] [-dry-run] KEY=VALUE...

Keys:

  • enabled, mode, skip, block_status
  • per detector: detectors.KIND.action (off, log, mask or block) and detectors.KIND.block_at, where KIND is card, us_ssn, iban, aadhaar or uk_nino
  • detectors.card.keep_last4
  • requests.action (off, log or block) and requests.skip

waap dlp list get ​

Prints the custom patterns or word dictionaries as YAML.

sh
waap dlp list get -app NAME -list patterns|dictionaries
  • Patterns: name, regex, action, min_count, block_at.
  • Dictionaries: name, words, case_sensitive, action, min_count, block_at.

waap dlp list set ​

Replaces the custom patterns or dictionaries with the records in FILE (YAML or JSON; - reads standard input). An empty list ([]) removes them.

sh
waap dlp list set -app NAME -list patterns|dictionaries -f FILE [-m WHY] [-dry-run]

waap dlp test ​

Scans a sample text as an answer body under the active settings, without sending anything. The text is read from FILE, or from standard input when it is -. At most 256 KiB.

sh
waap dlp test -app NAME -f FILE [-json]

It prints the rules that found something (action, count, first match masked, and whether it refuses the answer), the text as it would be sent, and the outcome in the application's mode. Matches are never printed unmasked in the findings.

waap files get ​

Prints the file upload protection settings.

sh
waap files get -app NAME [-json]

waap files set ​

Changes the file upload protection settings. The first set turns it on. It checks nothing until an upload rule names paths.

sh
waap files set -app NAME [-m WHY] [-dry-run] KEY=VALUE...

Keys:

  • enabled, mode
  • the checks mismatch, scripts, names and webshells (off, log or block)
  • hash_lists.deny and hash_lists.allow: names of file lists, comma-separated

waap files list get ​

Prints the upload rules as YAML.

sh
waap files list get -app NAME -list rules

waap files list set ​

Replaces the upload rules with the records in FILE (YAML or JSON; - reads standard input). Each record has:

  • paths
  • max_size
  • allow and deny: families image, pdf, office, text, archive, audio, video, executable or script, or exact types
  • json_fields: JSON pointers
  • raw
  • archives: skip or inspect
  • encrypted: block or allow

The first matching rule applies. An empty list ([]) removes them.

sh
waap files list set -app NAME -list rules -f FILE [-m WHY] [-dry-run]

waap files test ​

Checks a file as if a browser uploaded it in a form to PATH, under the active settings. It sends and stores nothing. The file is read from FILE, or from standard input when it is -. At most 16 MiB.

sh
waap files test -app NAME -path PATH -f FILE [-name NAME] [-type TYPE] [-json]
  • -name is the file name sent. Default: FILE's base name.
  • -type is the declared Content-Type. Default: none.

It prints the size, the type found by content, the SHA-256, each finding (rule, action, archive member, why) and the outcome in the application's mode. A path no rule covers is reported as not checked.

waap vpatch list ​

Lists the application's virtual patches and its stored scanner reports.

sh
waap vpatch list -app NAME [-json]

For each virtual patch it shows:

  • ID, class, target, methods, paths and rule range
  • enforce: block blocks in detect mode too; mode follows the signatures mode
  • the scanner, report and finding the patch came from
  • "fixed upstream?": the later report of the same scanner that no longer has the finding

For each stored report it shows: ID, scanner, name, import time and account, findings, and whether it is patchable.

waap vpatch import ​

Imports a scanner report. The format is detected automatically:

  • ZAP (traditional JSON or XML report)
  • Nuclei (JSON lines or a JSON array)
  • Burp Scanner (XML issues export)
  • waap-findings/v1 JSON (docs/virtual-patches.md)

At most 50 MiB and 10,000 findings. -name names the report in lists. Default: the file's name.

sh
waap vpatch import -app NAME -f FILE [-name NAME] [-json]

The command prints the report ID and each finding: its key, name, severity, the proposed patch or why it is not patchable, and the patch covering it. It changes nothing.

waap vpatch show ​

Shows a stored report's findings, in the same form import prints.

sh
waap vpatch show -app NAME -report ID [-json]

waap vpatch apply ​

Applies findings of a report as patches in a new configuration version.

sh
waap vpatch apply -app NAME -report ID (-finding KEY ... | -all) [-m WHY] [-dry-run]
  • -finding takes a finding key. Quote it, because keys contain spaces. It may be repeated.
  • -all takes every patchable finding without a patch.
  • Findings already patched are skipped. A finding that is not patchable is refused.
  • -dry-run prints the changes.

waap vpatch remove ​

Removes patches by ID, or every patch marked fixed upstream.

sh
waap vpatch remove -app NAME (-id vp-0001[,vp-0002] ... | -fixed) [-m WHY] [-dry-run]
  • Repeat -id, or separate IDs with commas.
  • -fixed removes every patch marked fixed upstream.
  • -dry-run prints the changes.

waap vpatch delete-report ​

Deletes a stored report. Patches made from it stay.

sh
waap vpatch delete-report -app NAME -report ID