WebCalendar — 2 vulnerability checks

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

← All products · Feeds on GitHub

WebCalendar <= 1.2.4 install/index.php settings overwrite

CVECVE-2012-1495
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionset_var, http_request, script, match · highest QoD 70
Feedtests/vulnerabilities/webcalendar/CVE-2012-1495.yaml

WebCalendar 1.2.4 and earlier let any visitor submit the installer form (install/index.php) and save it into includes/settings.php, a PHP file, even when an installer password is set; a crafted value gives code execution. Release 1.2.5 fixed it.

The check requests login.php under the web root and the usual install directories and reads the release shown in the page footer. A release up to 1.2.4 is reported. Nothing is written to the target: confirming the flaw would require rewriting settings.php, so the result rests on the version only and is reported with a lower confidence.

How noctis detects it

  1. HTTP(S) request GET {{dir}}/login.php
  2. Parses / computes the next value with a Rhai script
  3. Checks hit for ^/ → finding QoD 70: WebCalendar <= 1.2.4 install/index.php settings overwrite (CVE-2012-1495)

References:

Feed source — tests/vulnerabilities/webcalendar/CVE-2012-1495.yaml
# WebCalendar <= 1.2.4 — install/index.php settings.php overwrite (CVE-2012-1495) — version check
#
# Before the fix of 2012-02 (release 1.2.5), install/index.php saved a posted form into
# includes/settings.php even when an installer password was required. The only way to
# prove it is to write to that file (the value ends up as PHP code in it), which changes
# the target's configuration; this feed therefore sends no write and reports the
# release shown on the login page, at QoD 70.
#
# Detection (read-only), per candidate directory "", /webcalendar, /WebCalendar, /calendar:
#   GET <dir>/login.php; the footer link `id="programname"` reads "WebCalendar v<x.y.z>".
#   A release <= 1.2.4 is reported (1.2.5 is the first fixed release).
#
# CVE mapping: the issue lists CVE-2012-1495 and CVE-2012-1496; the source check only
# targets 1495 (install/index.php), 1496 (local file inclusion) is a separate bug that a
# version check cannot separate, so only 1495 is named. NVD CVSS v3.x for 1495 is 9.8.
#
# Ported from OpenVAS/Greenbone NVT 2012/gb_webcalendar_53207.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103476, GPL-2.0-only). Improvement over it: no write to the
# target (the source check overwrites includes/settings.php).
uid: 7dd6add8-fb0f-47fc-8597-86823adc5daf
name: "WebCalendar <= 1.2.4 install/index.php settings overwrite (CVE-2012-1495)"
description: |
  WebCalendar 1.2.4 and earlier let any visitor submit the installer form
  (install/index.php) and save it into includes/settings.php, a PHP file, even when an
  installer password is set; a crafted value gives code execution. Release 1.2.5 fixed it.

  The check requests login.php under the web root and the usual install directories and
  reads the release shown in the page footer. A release up to 1.2.4 is reported. Nothing
  is written to the target: confirming the flaw would require rewriting settings.php, so
  the result rests on the version only and is reported with a lower confidence.
cves: [CVE-2012-1495]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.30
tags: [webcalendar, php, installer, version-check]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2012-1495"
  - "https://www.securityfocus.com/bid/53207"
  - "https://github.com/craigk5n/webcalendar/commit/cfc6e077c4e6d27f246c6f0b13f84dbc70b6534b"
  # OpenVAS/Greenbone NASL 2012/gb_webcalendar_53207.nasl (GPL-2.0-only)

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

  - id: init-login
    action: set_var
    var_name: login
    var_value: {status: 0, body: ""}
    loop:
      var: dir
      over: ["", "/webcalendar", "/WebCalendar", "/calendar"]

  - id: fetch-login
    action: http_request
    method: GET
    path: "{{dir}}/login.php"
    port: "{{port}}"
    tls_insecure: true
    timeout_secs: 15
    condition: 'hit == ""'
    store_as: login

  - id: check-version
    action: script
    condition: 'hit == "" && login.status == 200'
    code: |
      let body = if type_of(login.body) == "string" { login.body } else { "" };
      let m = eregmatch("id=\"programname\"[^>]*>\\s*WebCalendar v([0-9]+(?:\\.[0-9]+)*)", body);
      if type_of(m) != "array" || m.len() < 2 { return ""; }
      let p = m[1].split(".");
      let maj = parse_int(p[0]);
      let min = if p.len() > 1 { parse_int(p[1]) } else { 0 };
      let pat = if p.len() > 2 { parse_int(p[2]) } else { 0 };
      let vuln = maj < 1 || (maj == 1 && (min < 2 || (min == 2 && pat <= 4)));
      if vuln { (if dir == "" { "/" } else { dir }) + " (version " + m[1] + ")" } else { "" }
    store_as: hit

  - id: report
    action: match
    source: hit
    pattern: "^/"
    on_match:
      finding:
        title: "WebCalendar <= 1.2.4 install/index.php settings overwrite (CVE-2012-1495)"
        description: "The WebCalendar login page reports release 1.2.4 or earlier, whose installer (install/index.php) saves posted values into includes/settings.php without authentication, which gives code execution. The flaw was not exercised, since that would rewrite the target's configuration."
        remediation: "Upgrade WebCalendar to 1.2.5 or later and remove or restrict the install/ directory."
        confidence_delta: 0.40
        qod: 70
        evidence: "install dir {{hit}}: login.php footer shows a WebCalendar release <= 1.2.4"
      stop: true

WebCalendar view_entry.php 'id' SQL Injection

Severityhigh
Categorysqli — SQL injection
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/webcalendar/view-entry-id-sqli.yaml

Tests WebCalendar (0.9.x up to 1.0RC3) for the SQL injection through the id parameter of view_entry.php, reachable without authentication when public access is enabled. In the web root and in the /webcalendar, /WebCalendar and /calendar directories, once view_entry.php answers a plain id without a database error, the feed sends an id that makes MySQL raise an XPath error carrying the product of two random numbers. The correct product in WebCalendar's database error page confirms that the database ran the injected expression; the product is not part of the request, so a page that only echoes the URL is not reported. Releases that hide the SQL error details, and databases without the EXTRACTVALUE function, are reported when appending a single quote to id returns WebCalendar's database error page while the plain request did not. The probes read no table row and change nothing.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. Parses / computes the next value with a Rhai script
  3. HTTP(S) request GET {{dir}}/view_entry.php?id=1&date=1
  4. Parses / computes the next value with a Rhai script
  5. HTTP(S) request GET {{dir}}/view_entry.php?id=1%20AND%20extractvalue(1,concat(0x7e,{{m.a}}*{{m.b}}))&date…
  6. Parses / computes the next value with a Rhai script
  7. Checks proof for ^XPATH syntax error: ~[0-9]+$ → finding QoD 97: WebCalendar view_entry.php 'id' SQL Injection
  8. HTTP(S) request GET {{dir}}/view_entry.php?id=1%27&date=1
  9. Parses / computes the next value with a Rhai script
  10. Checks syn for ^WebCalendar database error on the entry query$ → finding QoD 75: WebCalendar view_entry.php 'id' SQL Injection

References:

Feed source — tests/vulnerabilities/webcalendar/view-entry-id-sqli.yaml
# WebCalendar view_entry.php 'id' SQL injection (Nov 2004)
#
# WebCalendar 0.9.x up to 1.0RC3 (the 1.0RC4 / 1.0.0 fix, CVS 2005-03,
# adds `if ( empty($id) || $id <= 0 || ! is_numeric($id) )` to view_entry.php)
# imports every GET value as a global (includes/functions.php) and
# view_entry.php pastes $id unquoted into its first access-check query:
#   SELECT webcal_entry.cal_id FROM webcal_entry, webcal_entry_user
#    WHERE webcal_entry.cal_id = webcal_entry_user.cal_id
#      AND webcal_entry.cal_id = <id> AND (webcal_entry.cal_create_by = '<login>' ...)
# A failed query ends in includes/php-dbi.php dbi_fatal_error():
#   <h2>Error</h2>\n<!--begin_error(dbierror)-->\n<msg>\n<!--end_error-->
# where <msg> is "Error executing query: <mysql_error()>\n\n<br />\n<sql>" up to
# 0.9.44, only "Error executing query." in 0.9.45 (details commented out, CVS
# 2004-10), and again the MySQL error + SQL in 1.0RC1–RC3 (the new
# $phpdbiVerbose ternary lacks parentheses, so it always prints the details).
# Checked against the upstream CVS history (github.com/craigk5n/webcalendar,
# view_entry.php and includes/php-dbi.php at 0.9.44, 0.9.45 and 1.0RC4).
# The page is reached unauthenticated when public access is enabled (otherwise
# validate.php sends the visitor to login.php first) — same reach as the
# source check.
#
# Detection (benign, read-only), per candidate directory
# ("", /webcalendar, /WebCalendar, /calendar):
#   1. Control: GET <dir>/view_entry.php?id=1&date=1 must answer without the
#      WebCalendar database error page / SQL error text (also gates the probes).
#   2. id=1 AND extractvalue(1,concat(0x7e,<a>*<b>)) — MySQL 5.1+ raises
#      "XPATH syntax error: '~<a×b>'", which 0.9.44 and older print in the
#      error page. The product is not in the request. No quote is used, so
#      magic_quotes_gpc does not matter. QoD 97.
#   3. Fallback: id=1' (the source check's request) returns the database error
#      page ("Error executing query", the MySQL syntax error or the echoed
#      webcal_entry query) while the control did not. Covers 0.9.45, which
#      hides the SQL, and older MySQL servers. QoD 75.
#
# Improvements over the source NASL: a database-computed proof (QoD 97), an
# error-free control request (a page that always shows SQL error text is not
# reported), the 0.9.45 release whose error page no longer quotes the query
# (the NASL misses it), and the usual install directories.
#
# CVE mapping: the source check lists CVE-2004-1506..1510 (Joxean Koret's
# Bugtraq advisory, BID 11651), but none of those records describes this SQL
# injection (1506 XSS, 1507 CRLF, 1508 init.php include, 1509 path disclosure,
# 1510 variable poisoning: is_admin=true etc. on view_entry.php / upcoming.php,
# considered and not matched), and no CVE record covers it, so cves is empty.
#
# Ported from OpenVAS/Greenbone NVT pre2008/webcalendar_sql_injection.nasl
# (OID 1.3.6.1.4.1.25623.1.0.15752, GPL-2.0-only).
uid: 8a065654-9af2-42a0-accf-d857bf6d8dcf
name: "WebCalendar view_entry.php 'id' SQL Injection"
description: |
  Tests WebCalendar (0.9.x up to 1.0RC3) for the SQL injection through the id
  parameter of view_entry.php, reachable without authentication when public
  access is enabled. In the web root and in the /webcalendar, /WebCalendar and
  /calendar directories, once view_entry.php answers a plain id without a
  database error, the feed sends an id that makes MySQL raise an XPath error
  carrying the product of two random numbers. The correct product in
  WebCalendar's database error page confirms that the database ran the injected
  expression; the product is not part of the request, so a page that only
  echoes the URL is not reported. Releases that hide the SQL error details, and
  databases without the EXTRACTVALUE function, are reported when appending a
  single quote to id returns WebCalendar's database error page while the plain
  request did not. The probes read no table row and change nothing.
cves: []
severity: high
category: sqli
confidence_base: 0.30
tags: [webcalendar, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
  - "https://seclists.org/bugtraq/2004/Nov/132"
  - "https://www.securityfocus.com/bid/11651"
  - "https://github.com/craigk5n/webcalendar"
  # OpenVAS/Greenbone NASL pre2008/webcalendar_sql_injection.nasl (GPL-2.0-only)

steps:
  # Random operands; the expected proof is computed locally.
  - id: mint
    action: script
    code: '#{ a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
    store_as: m

  - id: mint-product
    action: script
    code: '"" + (m.a * m.b)'
    store_as: prod

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

  # ── Loop group: every step below runs once per candidate directory ──────
  - id: init-ctl-r
    action: set_var
    var_name: ctl_r
    var_value: {status: 0, body: ""}
    loop:
      over: ["", "/webcalendar", "/WebCalendar", "/calendar"]
      var: dir

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

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

  - id: control
    action: http_request
    method: GET
    path: "{{dir}}/view_entry.php?id=1&date=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'proof == ""'
    store_as: ctl_r

  # The page must exist and show no database error for a plain id.
  - id: gate
    action: script
    code: |
      proof == "" && ctl_r.status == 200 && type_of(ctl_r.body) == "string" && stridx(ctl_r.body, "dbierror") < 0 && stridx(ctl_r.body, "Error executing query") < 0 && stridx(ctl_r.body, "error in your SQL syntax") < 0 && stridx(ctl_r.body, "XPATH syntax error") < 0
    store_as: ok

  # id=1 AND extractvalue(1,concat(0x7e,<a>*<b>)) — no quote, so
  # magic_quotes_gpc leaves it intact.
  - id: inject-numeric
    action: http_request
    method: GET
    path: "{{dir}}/view_entry.php?id=1%20AND%20extractvalue(1,concat(0x7e,{{m.a}}*{{m.b}}))&date=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'ok == true'
    store_as: num_r

  - id: verdict-numeric
    action: script
    code: |
      if ok == true && type_of(num_r.body) == "string" && egrep("XPATH syntax error: (?:'|&#0?39;|&#x27;|&apos;)?~" + prod + "(?:[^0-9]|$)", num_r.body) != "" { "XPATH syntax error: ~" + prod } else { proof }
    store_as: proof

  - id: report-xpath
    action: match
    source: proof
    pattern: "^XPATH syntax error: ~[0-9]+$"
    on_match:
      finding:
        title: "WebCalendar view_entry.php 'id' SQL Injection"
        description: "An unauthenticated GET to view_entry.php with SQL appended to the id parameter made the database compute the product of two random numbers, which came back in WebCalendar's database error page. Any query the calendar's database user may run can be injected the same way, including reading the user accounts and their password hashes."
        remediation: "Upgrade WebCalendar to 1.0.0 or later, which rejects non-numeric entry ids in view_entry.php. As a stopgap, disable public access so that view_entry.php requires a login."
        confidence_delta: 0.65
        qod: 97
        evidence: "GET {{dir}}/view_entry.php with an injected id computing {{m.a}}*{{m.b}} returned the database-computed result: {{proof}}"
      stop: true

  # Fallback: the source check's single quote. WebCalendar's database error
  # page (or the MySQL error / echoed query) while the control showed none.
  - id: inject-quote
    action: http_request
    method: GET
    path: "{{dir}}/view_entry.php?id=1%27&date=1"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 15
    condition: 'ok == true && proof == ""'
    store_as: quote_r

  - id: verdict-quote
    action: script
    code: |
      if proof == "" && ok == true && type_of(quote_r.body) == "string" && ((stridx(quote_r.body, "<!--begin_error(dbierror)-->") >= 0 && stridx(quote_r.body, "Error executing query") >= 0) || stridx(quote_r.body, "SELECT webcal_entry.cal_id FROM webcal_entry") >= 0 || stridx(quote_r.body, "You have an error in your SQL syntax") >= 0) { "WebCalendar database error on the entry query" } else { "" }
    store_as: syn

  - id: report-syntax
    action: match
    source: syn
    pattern: "^WebCalendar database error on the entry query$"
    on_match:
      finding:
        title: "WebCalendar view_entry.php 'id' SQL Injection"
        description: "An unauthenticated GET to view_entry.php with a single quote appended to the id parameter returned WebCalendar's database error page, while the same page with a plain id showed no error: the parameter is pasted into the SQL query without validation. Any query the calendar's database user may run can be injected the same way."
        remediation: "Upgrade WebCalendar to 1.0.0 or later, which rejects non-numeric entry ids in view_entry.php. As a stopgap, disable public access so that view_entry.php requires a login."
        confidence_delta: 0.50
        qod: 75
        evidence: "GET {{dir}}/view_entry.php?id=1'&date=1 returned WebCalendar's database error page (status {{quote_r.status}}); the same page with id=1 returned status {{ctl_r.status}} with no database error"
      stop: true

View these feeds on GitHub