How to Write Nuclei Templates: A Starter and a Tested Example
December 2026
A Nuclei template is a short YAML file that tells the Nuclei scanner what to request and what counts as a finding. Writing your own lets you check for a new vulnerability as soon as the advisory is out, and check the conditions it needs, not only its version. This guide gives you a starter template to adapt for a new CVE whose conditions a web request can see, the steps that make a template reliable, and a worked example: a lab-tested template for the exploitable WordPress flaw CVE-2026-119977.
Go straight to the starter template, or, if you run WordPress sites, to checking them for CVE-2026-119977.
How Nuclei Templates Work
A template has three parts that matter for detection: an info block that describes the check, the requests it sends, and its matchers, the conditions a response has to meet to count as a result. Extractors, optionally, pull a value such as a version number out of a response for the matchers to use.
Several requests in one block can be read together. With req-condition: true, Nuclei sends every path and numbers the responses, so a matcher can compare status_code_2 with status_code_3. Each matcher can carry a name, which Nuclei prints with the result, so one template can report several different results.
A template has one severity, set in info, and it applies to every result. So a template that reports both protected and exposed sites uses a low severity, and the matcher name says which result applies. Nuclei prints that name with every finding, for example :denied or :exposed-on-next-update.
Templates in the public library are signed by ProjectDiscovery, and one you write yourself is not. Nuclei prints a warning when it loads an unsigned template and runs it anyway, unless it uses the code protocol, which runs commands on the machine doing the scan: unsigned code templates are blocked. An HTTP template like the starter below needs no signature.
Nuclei sends whatever a template asks for, and some library templates confirm a flaw by triggering it, so read a template's requests before you run it against a production site.
A Starter Template for a New CVE
This is the pattern behind the WordPress example, with the WordPress details taken out. It reads the version from two places, checks the condition the flaw needs with one request, and adds a control request. The template is also available on GitHub nuclei-detections.
id: product-cve-yyyy-nnnnn
info:
name: Product - Condition Check (CVE-YYYY-NNNNN)
author: you
severity: info # one severity covers every result; the matcher name says which result it is
description: |
What the flaw needs, which of those conditions this template checks,
and which it cannot see from outside.
reference:
- https://example.com/vendor-advisory
tags: cve,passive
http:
- method: GET
req-condition: true # send every path, then read the responses together
path:
- "{{BaseURL}}/where-the-version-shows" # 1: the version
- "{{BaseURL}}/another-place-the-version-shows" # 2: a fallback, if the first is hidden
- "{{BaseURL}}/path-the-flaw-needs/" # 3: the condition
- "{{BaseURL}}/path-the-flaw-needs/made-up-name.txt" # 4: a control that a real path never answers with 200
extractors:
- type: regex
name: found_version
internal: true
part: body
group: 1
regex:
- 'version ([0-9]+\.[0-9]+\.[0-9]+)'
matchers-condition: or
matchers:
- type: dsl
name: exposed
condition: and
dsl:
# Affected versions, one range per branch, written once and reused below
- &affected >-
compare_versions(found_version, '>= 2.0.0', '< 2.0.9') ||
compare_versions(found_version, '>= 1.0.0', '< 1.4.12')
- "status_code_3 == 200 && status_code_4 != 200"
- type: dsl
name: protected
condition: and
dsl:
- *affected
- "status_code_3 == 403 && status_code_4 == 403"
- type: dsl
name: undetermined
condition: and
dsl:
- *affected
- "status_code_3 == 404 && status_code_4 == 404"Reading the Starter Template
← Scroll to see full table
| Element | What it does |
|---|---|
id and info | The id names the check and appears in every result. info holds the name, author, severity, description, references and tags. |
req-condition: true | Numbers the responses in path order: status_code_3 is the third path's status code, body_1 the first path's body. |
extractors with internal: true | Pulls a value out of a response, here the version, into a named variable (found_version) the matchers can use. internal: true keeps it out of the printed output. |
matchers-condition: or | The template reports a result when any one matcher is true. Each matcher here is one possible result. |
condition: and | Inside one matcher, every line must be true: the version is affected, and the status codes fit that result. Without it, any one line is enough. |
type: dsl | DSL stands for domain-specific language: short expressions built from response values and helper functions such as compare_versions, joined with && (and) and || (or). |
&affected and *affected | Standard YAML anchors, not a Nuclei feature. &affected labels the version expression where it first appears, and *affected repeats it, so the ranges are written once. |
dsl is one of seven matcher types. The other six each test one part of a response: status (the status code), word (fixed text), regex (a pattern), binary (bytes, written in hex), size (the content length) and xpath (a query on HTML or XML). The starter uses dsl so each result can check the version and two status codes together.
For the full field list and naming, ProjectDiscovery's template guide covers structure, the matchers reference lists every matcher type, and the helper functions reference lists what a dsl expression can call. The syntax reference on GitHub documents every field. Check your file with nuclei -validate -t yourfile.yaml before you run it.
To adapt the starter, fill in four things from the advisory: where the version shows, the affected ranges for each branch, the path or setting the flaw needs, and the response that path gives when it is protected. Then add a matcher name for every other result your lab shows. Make every matcher read the last response, status_code_4 here, or it can report the same site twice.
The skeleton passes nuclei -validate, and in a quick test it returned one result each against three stub servers built to be exposed, protected and missing the path. Treat it as a starting point: run it against a lab with a case for every result, and you catch problems such as a matcher reporting the same site twice before a real scan does.
How to Write a Good Nuclei Template
← Scroll to see full table
| Step | Why it matters | In the WordPress example |
|---|---|---|
| Check the conditions the flaw needs, not just the version | A version tells you what to patch, not what is exposed | Whether the staging folder is served, as well as the version |
| Take version ranges from each branch's fixed release | A single "before X" reports patched older branches as vulnerable | 25 branches, from 4.7.39 to 7.1.4 |
| Read the version from more than one place | Sites can hide it or move it | /feed/, then /?feed=rss2 |
| Send only safe requests | A check must never be the first step of the exploit | Four GET requests; the file inside the folder is a made-up name |
| Name every result, including "can't tell", and keep the severity low if any result means safe | People act on the name; one severity covers every result | Five names, severity info |
| Add a control request | Stops the template firing on a server that answers 200 to every path | In the lab, no real folder answered 200 for a made-up file; the catch-all control server did |
| Test every result in a lab | Real cases catch results you did not expect | 21 WordPress sites and two servers that are not WordPress |
When you build on someone else's template, read its matchers, not only its description, and record the version you tested.
Worked Example: WordPress CVE-2026-119977
WordPress fixed CVE-2026-119977 on 28 October 2026, and CISA added it to its Known Exploited Vulnerabilities catalogue on 3 November. The public Nuclei template library had a check for it by 1 December, which reads the WordPress version. The flaw also needs the web server to serve wp-content/upgrade/, the staging folder WordPress unpacks each update into before installing it, and that is the condition this example adds.
This example reads the library template, tests it against a lab and builds an extended template from it. The extended template adds two requests to the folder, which tell the protected sites from the exposed ones, and a second feed address, which reads the version on sites the first one misses. The template, the lab and every result are on GitHub under an MIT licence.
The fix is to update. WordPress 7.1.4 and the backported releases down to 4.7.39 fix the flaw. The researcher who found it, Umut Bayram, notes that the fixes do not all protect the update that installs them, so the first update from an affected release needs care. He advises denying web access to wp-content/upgrade/ and confirming it answers 403 before updating. The check below shows, for each site, whether that folder is already denied or still reachable.Check Your WordPress Sites for CVE-2026-119977
You need Nuclei (tested on v3.11.1). Run the library template and our extended template side by side:
# The public library template: version only
nuclei -id CVE-2026-119977 -u https://www.example.com
# Our extended template: version from two feed addresses, the staging folder, and a made-up file inside it
curl -O https://raw.githubusercontent.com/cyberdesserts/nuclei-detections/main/templates/CVE-2026-119977-upgrade-folder.yaml
nuclei -t CVE-2026-119977-upgrade-folder.yaml -u https://www.example.comOur extended template reports one result per site, as the name after the colon in Nuclei's output, for example [wordpress-upgrade-folder-cve-2026-119977:denied]. A deny rule, below, means a web server setting that refuses requests to wp-content/upgrade/: a Require all denied or RedirectMatch 403 line in Apache, or a location block with deny all in NGINX.
← Scroll to see full table
| Result | What it means | What to do |
|---|---|---|
exposed-on-next-update | Affected version, and the folder is served: files the next core update stages there can be requested from the web | Deny the folder, confirm a 403, then update |
listable | Affected version, and the folder is served and lists its contents | As above. Anyone can also see what the folder holds |
version-unreadable-folder-served | The folder is served, but neither feed address shows the version | Check the version on the host (wp core version). Treat as exposed until you have |
undetermined | Affected version, the folder does not exist yet, and no deny rule is visible from outside | Check the server configuration for a deny rule. If there is none, add one on the URL path, such as RedirectMatch 403 or an NGINX location block, which a rescan can confirm |
denied | Affected version, and a deny rule refuses the folder | Update. The rule protects the folder while you do |
| No result | A fixed release, or not a WordPress site | Nothing for this CVE |
The template sends four ordinary GET requests: two for the RSS feed, one for the staging folder, and one for a made-up file name inside that folder, which shows whether a 403 on the folder comes from a deny rule or only from the server declining to list it. It never asks for an update package, the installer or any PHP file. Scan only sites you are authorised to test.
What the WordPress Flaw Needs to Be Exploitable
During a core update that uses a full WordPress package, affected versions unpack the new files into a predictable folder under wp-content/upgrade/, and that copy includes the WordPress installer. An attacker with no account on the site who requests the staged installer while it exists can run it against a database of their own and reach unauthenticated remote code execution.
Wordfence lists four conditions: a full-package update that contains the installer files, web and PHP access to the staging folder, a staging path the attacker can predict or find, and time to finish before WordPress deletes the copy. In Wordfence's lab the copy existed for seconds, and attackers still poll for it. Wordfence recorded more than 18,500 requests aimed at staged setup-config.php paths in the first 21 hours after its firewall rule went live, and the two largest sources polled small groups of sites for about 14.5 hours.
← Scroll to see full table
| Condition | Can a scan see it? |
|---|---|
| An affected version | Yes, from the version in the RSS feed, if the site publishes it there |
Web access to wp-content/upgrade/ | Yes, with two requests, except in one case covered below |
| A predictable staging path | Implied by the version: fixed releases add 16 random characters to the folder name |
| A full-package update in progress, and a race won | No |
The fix in 7.1.4 does three things: it randomises the staging folder's name, keeps a blank index.php in wp-content/upgrade/ so the folder cannot be listed, and stops the update promoting a staged configuration file. CVSS rates the attack complexity as high, and CISA's own assessment on the CVE record marks it as not automatable.
The library template tests the first row. The extended template adds the second, a server setting the site owner controls.
Read the Library Template
The library template sends one request, to /feed/, the RSS feed WordPress publishes for its posts. By default the feed names the software that produced it in a <generator> line, for example <generator>https://wordpress.org/?v=7.1.3</generator>. The template pulls the version out of that line, compares it against 25 version ranges, one per branch from 4.7 to 7.1, and requires a 200 response. It is tagged passive and does not request wp-content/upgrade/.
Its description says it "only flags the 7.1, 7.0 and 6.9 branches". Its matchers (the conditions that decide whether a site is reported) check all 25. In the lab it correctly reported a vulnerable site on 6.8.11, a branch the description says it skips. Nuclei runs the matchers, not the description, so read the matchers to see what a template checks.
The template answers one question: is this an affected version? It reads that from the feed, so a site that strips the version from the <generator> tag, or uses plain permalinks so /feed/ does not resolve, gets no result.
This describes the template as fetched on 5 December 2026 (SHA-256 beginning d69bf5871ce0). Library templates change, so check the one you run.
Build the WordPress Test Lab
If you have not built a test lab before, the cybersecurity practice lab guide covers the options. The lab in the repository runs in Docker and builds 21 WordPress sites and two servers that are not WordPress, on four containers, with every port bound to 127.0.0.1. The sites differ in the WordPress version (7.1.3 or 7.1.4, and 6.8.11 or 6.8.12 on an older branch), Apache or NGINX, the state of the staging folder, the rule guarding it, the permalink setting, and whether the feed shows the version. Each site's row in cases.tsv records its settings and what each template should report.
The lab only sets up the conditions the template looks for. It never runs a real WordPress update, so the staging folder never holds an update package or the installer file the attack requests. The setup script creates each staging folder in one of three states: empty, holding a blank index.php, or not created at all. The deny and listing rules are fixed lines in the lab's Apache and NGINX configuration files, or, for two Apache sites, a RedirectMatch 403 line in the site's .htaccess.
git clone https://github.com/cyberdesserts/nuclei-detections.git
cd nuclei-detections
(cd lab/wordpress-upgrade && ./setup.sh)
lab/run-tests.sh lab/wordpress-upgradeYou need Docker with Compose, curl, Nuclei and about 3 GB of disk. The first run downloads WordPress and takes a few minutes. run-tests.sh runs both templates against every case, compares each answer with the recorded row in cases.tsv, and exits with an error if any differs.
Run against the lab, the library template reported every affected site whose /feed/ showed a version, including the ones a deny rule protects, and gave no result for the four whose /feed/ did not. All four have a served folder. Two remove the version from the feed with a small filter. The other two use plain permalinks, where /feed/ returns a 404 on Apache and the site's front page on NGINX.
Extend the Template to Check the Upgrade Folder
The extended template keeps the library's version check and adds three requests:
http:
- method: GET
req-condition: true
redirects: true
max-redirects: 2
path:
- "{{BaseURL}}/feed/"
- "{{BaseURL}}/wp-content/upgrade/"
- "{{BaseURL}}/wp-content/upgrade/cyberdesserts-probe-nonexistent.txt"
- "{{BaseURL}}/?feed=rss2"The fourth request reads the feed at /?feed=rss2, the query-string form of the feed address. On the two plain-permalink sites it showed the version that /feed/ did not. On the two sites that strip the version, neither address shows it, so the extended template reports them as version-unreadable-folder-served.
One request to the folder cannot tell a denied folder from a served one. A folder denied by a rule answers 403, and so does a served folder that will not list its contents, the default on both servers in the lab. The third request separates them. A deny rule covers everything under the folder, so a file inside it is refused too, with another 403. A served folder passes the request on to WordPress or the web server, and a file that does not exist gets a 404, or on two NGINX sites with plain permalinks, a redirect. In the lab, those two ordinary GET requests showed whether a WordPress site's update staging folder was protected or exposed. The only case they could not settle was a site where the folder had not been created yet.
← Scroll to see full table
| Folder | Missing file inside it | Folder state |
|---|---|---|
| 403 | 403 | Denied |
| 403 | 404 or a redirect | Served, not listable |
| 200, "Index of" page | 404 | Listable |
| 200, empty | 404 | Served, holding an index.php |
| 404 | 404 | Not created yet, and no rule on the URL |
The 25 version ranges are written once, as a YAML anchor, and each matcher reuses them, so a correction is made in one place:
matchers-condition: or
matchers:
- type: dsl
name: denied
condition: and
dsl:
- &vulnerable_version >-
(contains(body_1, 'wordpress.org/?v=') ||
contains(body_4, 'wordpress.org/?v=')) &&
(compare_versions(wp_version, '>= 7.1.0', '< 7.1.4') ||
compare_versions(wp_version, '>= 7.0.0', '< 7.0.8') ||
# ... 23 more branches, down to 4.7
compare_versions(wp_version, '>= 4.7.0', '< 4.7.39'))
- "status_code_2 == 403 && status_code_3 == 403"
- type: dsl
name: exposed-on-next-update
condition: and
dsl:
- *vulnerable_version
- >-
(status_code_2 == 403 && status_code_3 != 403) ||
(status_code_2 == 200 && status_code_3 != 200 &&
!contains(body_2, 'Index of'))The status_code_3 != 200 check guards against a server that answers 200 to every path, as some single-page applications and catch-all routes do. In the lab, no real folder answered 200 for a file that is not there. Without the guard, such a server would read as a served folder. The lab includes a catch-all control server, and the extended template reports nothing on it.
Three more matchers complete the set: listable, undetermined, and version-unreadable-folder-served, which reports a served folder when neither feed address shows the version, so the site cannot be cleared. The matchers are written so that at most one of the five names fires per site, and the full template is in the repository.
When the Staging Folder Does Not Exist Yet
A rule written against the URL, in .htaccess or an NGINX location block, answers 403 even before the folder exists, so the scan confirms it straight away. An Apache <Directory> block matches a folder on disk. It protects the folder from the moment an update creates it, but until then it has nothing to apply to, and the site answers 404 and 404, the same as a site with no rule at all. In the lab, the Apache site with that rule could not be told from the site without one until the folder was created by hand.
The extended template reports undetermined for that case. Of the six protected sites in the lab, the scan confirmed five.
How the Library and Extended Templates Compare
For a site still on an affected version, the extended template also reports whether the staging folder is protected.
The library template has one possible result. When /feed/ answers 200 and names an affected version, Nuclei prints a finding titled "WordPress Core < 7.1.4 - Remote Code Execution" at high severity. It does not look at the folder, so the same finding appears whether the folder is denied, served or not there yet. The lab results, for both templates on Nuclei v3.11.1:
← Scroll to see full table
| Sites | Staging folder | Extended template | Library template |
|---|---|---|---|
| 5 | Refused by a deny rule | denied | High-severity finding on all 5 |
| 6 | Served, does not list its contents | exposed-on-next-update | High-severity finding on 4; nothing on the 2 that show their version only at /?feed=rss2 |
| 2 | Served, lists its contents | listable | High-severity finding on both |
| 3 | Not created yet, no rule visible | undetermined | High-severity finding on all 3 |
| 2 | Served, version hidden from both feeds | version-unreadable-folder-served | Nothing |
| 5 | Fixed release (3) or not WordPress (2) | Nothing | Nothing |
All 23 cases matched their rows in cases.tsv, and the raw run, with both templates' hashes, is in the repository's tests/ folder.
In the lab, every site the library template gave a finding for also got a result from the extended template, with the folder's state in the result name. The extended template also reports the sites the library template missed: two as exposed-on-next-update, after reading the version from the second feed address, and two as version-unreadable-folder-served.
A result shows that one condition the flaw needs is met, not that a site can be exploited. The lab's mix of sites was chosen for testing, so its proportions say nothing about how common each state is on the internet. Once a site is on a fixed release, the staging folder's name is random, and the version check alone is enough.
Using the Extended Template During an Incident
Wordfence told its customers to update at once rather than deny the folder first, reasoning in the comments under its post that owners who are not technical might put off updating while they worked out how. It agreed that denying the folder first is better for anyone who manages many sites and controls the servers, the reader the extended template is written for.
Across a portfolio, the results set the order:
exposed-on-next-update,listableandversion-unreadable-folder-served. Denywp-content/upgrade/with a rule on the URL path, rerun the extended template to confirmdenied, then update.undetermined. Check the server configuration for a rule. If there is none, add one on the URL path and rescan.denied. Update on the normal schedule. The rule protects the folder until then.- No result. Confirm on the host that the update finished.
Aim the scan at the origin, not at a CDN or a web application firewall, which may answer for the site. If a site was exposed before it updated, look in its access logs for requests under wp-content/upgrade/, as Wordfence advises.
Porting an Nmap Script to a Nuclei Template
When the Nmap check for the nginx2root flaws was ported to Nuclei, the version check worked straight away. The HTTP/2 check needed one change. Nuclei v3.11.1 only offers HTTP/2 when the scan runs with the -fh2 flag, and with it, the template told HTTP/2 servers from the rest just as the Nmap script does. Without the flag, every server reads as HTTP/1.1 and nothing warns you.
The flag belongs to the scan, not the template, so a template that depends on it should say so in its description and in the command you give people to run it. Before porting any check, ask whether Nuclei needs something outside the template to see the condition, and write it down where the person running the scan will see it. The guide to Nmap scripts for vulnerability scanning covers where Nmap fits.
Summary
Writing your own Nuclei template lets you check the conditions a vulnerability needs that a web request can check. Start from the starter template, fill in where the version shows and what the flaw needs, and test every result in a lab before you rely on it. In the WordPress example, two extra requests showed whether each site's staging folder was protected, and a second feed address read the version on two different site configurations the library template did not have. The template, the lab and the recorded runs are in nuclei-detections.
References
- WordPress.org. (2026). WordPress 7.1.4 release documentation. https://wordpress.org/documentation/wordpress-version/version-7-1-4/
- Wordfence (as CNA), via CVE.org. (2026). CVE-2026-119977. https://www.cve.org/CVERecord?id=CVE-2026-119977
- CISA. Known Exploited Vulnerabilities Catalog, CVE-2026-119977, added 3 November 2026. https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- Wordfence (Alex Thomas). (2026, 29 October). WordPress 7.1.4 Patches Unauthenticated Upgrade-Window RCE; Exploitation Attempts Detected After Release. https://www.wordfence.com/blog/2026/10/wordpress-7-1-4-security-release-rce/
- Umut Bayram, Picus Security. (2026, updated 9 November). CVE-2026-119977: When Updating WordPress Becomes the Vulnerability. https://www.picussecurity.com/resource/blog/cve-2026-119977-when-updating-wordpress-becomes-the-vulnerability
- WordPress.
wp-admin/includes/class-wp-upgrader.php, 6.8 branch against the 6.8.0 tag. https://github.com/WordPress/wordpress-develop - ProjectDiscovery. nuclei-templates:
http/cves/2026/CVE-2026-119977.yaml. https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2026/CVE-2026-119977.yaml - ProjectDiscovery. Nuclei documentation: templates, HTTP requests and matchers. https://docs.projectdiscovery.io/templates/introduction
- CyberDesserts. (2026). nuclei-detections: template, lab and recorded runs. https://github.com/cyberdesserts/nuclei-detections
- ProjectDiscovery. Nuclei documentation: matchers, helper functions and template signing references. https://docs.projectdiscovery.io/templates/reference/matchers, https://docs.projectdiscovery.io/templates/reference/helper-functions and https://docs.projectdiscovery.io/templates/reference/template-signing
- ProjectDiscovery. Nuclei template syntax reference. https://github.com/projectdiscovery/nuclei/blob/dev/SYNTAX-REFERENCE.md
Member discussion