Skip to content

Signature authoring ​

A signature is a YAML file that describes one detection: the requests we send to a target, the conditions that decide whether a response shows the problem, and the values worth keeping as evidence. The signature engine runs active signatures during a scan, and every signature that matches becomes one finding in the vault, with its matched requests attached as evidence.

This guide covers the file format as the backend reads it today. Each page describes one part of a signature:

PageCovers
RequestsRequest blocks, raw requests, multi-step chains, stopping early, injection paths
MatchersWord, regex, status, size, binary and DSL matchers, conditions and parts
ExtractorsRegex, header, JSON, XPath and DSL extractors, internal values
Variables and DSLPlaceholders, target context, functions and conditions
Payload attacksPayload lists and the three ways of combining them
ExamplesComplete signatures to start from

File anatomy ​

yaml
id: admin-panel-exposed
name: Exposed administration panel
version: 1.0
author: Your Name
severity: medium
description: >
  The administration login page is reachable without network restrictions.

tags:
  - exposure
  - admin

references:
  - https://example.com/advisory

info:
  cwe-id: CWE-284
  remediation: Restrict the administration interface to trusted networks.

requests:
  - method: GET
    path:
      - "/admin/login"

    matchers-condition: and
    matchers:
      - type: status
        status:
          - 200

      - type: word
        words:
          - "Administrator login"

Top-level fields ​

FieldRequiredDefaultMeaning
idYesUnique identifier. Saving a second signature with the same id is refused.
nameYesTitle shown in the library and used as the finding title.
severityNoinfoOne of info, low, medium, high, critical (lowercase). Anything else fails validation.
versionNo1.0Free-form version string.
authorNoShown in the library.
descriptionNoCopied into the finding's description.
tagsNo[]A list or a single string. Scans can select signatures by tag.
referencesNo[]A list or a single string of URLs.
infoNoClassification and remediation, see below.
variablesNo{}Named values for placeholders, see Variables and DSL.
requestsNoone GET /The requests to send, see Requests.
matchers, matchers-conditionNoorSignature-level matchers, used by requests that have none of their own.
extractorsNoSignature-level extractors, used by requests that have none of their own.
stop-at-first-matchNofalseStop after the first request block that matched.

The info block ​

info carries classification. We read these keys:

KeyUse
cve-idStored on the signature.
cwe-idStored on the signature and copied to each finding.
cvss-score, cvss-metricsStored with the signature's metadata.
classificationA free-form mapping, stored with the metadata.
remediationCopied to each finding as its remediation.
confidencetentative, firm or certain: the confidence of each finding it produces (other values are ignored, leaving firm).
limitationsWhat the check cannot tell, in words; kept in each finding's evidence and shown in its Evidence tab.

Any other key under info (for example owasp) is kept as custom metadata. cve_id, cwe_id and cvss_score are also accepted at the top level of the file. A top-level metadata: key is not read; put these values under info.

How the backend reads a signature ​

Every path that accepts a signature goes through one compiler (backend/app/core/signatures/compiler.py): the interface, the REST API, MCP tools, the built-in template sync and the scan runner. It parses the YAML, normalises it (single strings become lists, defaults are filled in) and validates it. The result is either a valid definition or a list of errors; there is no second, looser parser anywhere else.

Validation checks:

  • id and name are present and severity is one of the five levels.
  • Each request has a path or a raw block, a known method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS), a known attack mode and payloads given as a mapping.
  • Each matcher and extractor has a known type, the field its type needs (for example words for a word matcher), a known part and a condition of and or or.
  • matchers-condition is and or or, and variables is a mapping.
  • Every key is one the engine supports (below); anything else is refused with where it is, so a template written for another engine never looks valid while doing less than its author expects.

Validation does not run the signature, so a valid file can still never match. Test new signatures against a target you are authorised to scan.

Supported fields ​

WhereKeys
Top levelid, name, version, author, description, severity, type, tags, references, info, cve_id, cwe_id, cvss_score, variables, requests, matchers, matchers-condition, extractors, stop-at-first-match
Request blockid, method, path, raw, headers, body, redirects, follow-redirects, max-redirects, matchers, matchers-condition, extractors, payloads, attack, req-condition, stop-at-first-match
Matchertype, condition, part, negative, name, internal, words, case-insensitive, regex, status, size, binary, dsl
Extractortype, name, part, internal, regex, group, kval, json, xpath, dsl

Keys known from other engines are refused with the reason: http (request blocks go under requests), dns, network, tcp, headless, file (only HTTP request blocks), code, javascript (signatures never run code), workflows, flow, self-contained, threads, cookie-reuse, race, pipeline, unsafe, interactsh. The list lives in backend/app/core/signatures/fields.py.

History ​

Every change to a signature's template keeps the template it replaced, whether it was your edit (or an agent's, through signature_update) or a built-in updated by a new Phantom version. Each kept template has its version, its SHA-256, where it came from and who replaced it, at most 50 per signature. The History tab lists them: read one, copy its checksum, or restore it into a custom signature (the current template is kept first). Built-in signatures cannot be restored; duplicate one to change it (GET /signatures/{id}/revisions, POST /signatures/{id}/revisions/{revision}/restore).

Detection benchmark ​

Every built-in signature runs in the test suite against a local lab in two modes (backend/tests/scan_lab.py, test_scan_benchmark.py):

  • Hardened. The lab escapes every reflection, shows no database errors and no secrets, and sends no version headers. No built-in signature may match: the false-positive count must stay at zero, and the whole run must stay within 2,000 requests.
  • Vulnerable. The lab reflects input unescaped, shows a MySQL error on a quote, and returns the cloud metadata listing for a metadata URL. The signatures for those weaknesses (reflected, DOM and polyglot XSS, error-based SQL injection, both SSRF signatures) must find them.

Matchers and extractors are tested with the same lab: status, word (with and), regex, negative word, DSL, and the JSON, regex and header extractors.

The benchmark found four built-in signatures that matched an escaped or echoed payload: DOM XSS, polyglot XSS and both SSRF signatures. They now match only executable reflections or real metadata answers, never the payload echoed back. A change to the engine or a signature that brings a false positive back fails CI.

Built-in and custom signatures ​

Built-in signatures live in backend/templates, one file per signature, grouped in folders. At startup the backend syncs that folder into the signature library: the first folder name becomes the category, files that fail to compile are skipped with a warning in the log, built-ins whose file was removed are dropped, and your choice to enable or disable a built-in is kept across syncs. Built-ins are read-only: duplicate one to change it, and disable it instead of deleting it.

Custom signatures are created in the vault workspace's Signatures library. The editor validates the YAML with the backend as you write, and saving stores it as a user signature that you can edit, disable or delete.

The same operations are available over REST, under /api/v1:

RoutePurpose
POST /signatures/validateValidate {"template": "..."} without saving; answers {valid, errors, metadata}
GET /signaturesList, filtered by search, category, source (builtin or user) and active
POST /signaturesCreate a user signature from {"template": "..."}
GET /signatures/{signature_pk}One signature with its template
PATCH /signatures/{signature_pk}Replace the template (user signatures only) or set is_active
DELETE /signatures/{signature_pk}Delete a user signature

Agents use the matching MCP tools: signature_validate, signature_list, signature_get, signature_create, signature_update, signature_set_active and signature_delete, under the grants described in the MCP server guide.

How a scan runs signatures ​

A scan that includes the signature engine selects the active signatures, narrowed by the scan's chosen ids, tags and severities, and compiles each one again; a signature that no longer compiles is skipped with a warning in the scan log. Requests go through the scan's HTTP client, so the vault's scope is enforced on every request and out-of-scope hosts are refused. Timeout, redirect following, concurrency and extra headers are scan settings shared by every signature.

When a signature matches, we record one finding per signature with the signature's name, severity, description, remediation and CWE, the first matched URL without its query string, and evidence for up to 20 matched requests: URL, method, status, the payload or payloads used and the extracted values. The models behind signatures and findings are listed in Data models; where the engine sits in the backend is described in Architecture.