Moodle — 1 vulnerability check
noctis ships 1 vulnerability check for Moodle, covering 3 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Moodle <= 1.4.2 forum search XSS, file.php traversal and Glossary SQL injection
| CVE | CVE-2004-1424, CVE-2004-1425, CVE-2004-2232 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | xss — XSS |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/moodle/moodle-1-4-2-multiple-vulnerabilities.yaml |
Moodle 1.4.2 and earlier print the search parameter of the forum page mod/forum/view.php unescaped into the page's search box, so a crafted link runs attacker script in the browser of whoever follows it (CVE-2004-1424); the front-page news forum needs no login. The same releases let file.php climb out of the course files with "..", exposing session files (CVE-2004-1425), and Moodle 1.4.1 and earlier build a Glossary query with an unquoted category id (CVE-2004-2232).
Under the web root and /moodle, this check opens the forum page for forum ids 1 and 2 with a search value that closes the input tag and adds a script element carrying a random marker. The XSS is confirmed when the page returns that script element unescaped, and a random page of the same directory, given the same parameters, does not (which rules out servers that echo any URL). The release named in the front-page footer ("moodle 1.4.2 (2004083125)") reports the other flaws when it is 1.4.2 or older, and the XSS too when its probe found no reachable forum.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{v.d}}/ - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{v.d}}/mod/forum/view.php?f={{v.f}}&search={{sc.p}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{v.d}}/mod/forum/{{sc.ctl}}.php?f={{v.f}}&search={{sc.p}} - Parses / computes the next value with a Rhai script
- Checks
hitfor/mod/forum/view\.php\?f=→ finding QoD 75: Moodle forum view.php search parameter cross-site scripting (CVE-2004-1424) - Parses / computes the next value with a Rhai script
- Checks
rcasefor^le141-noxss$→ finding QoD 70: Moodle <= 1.4.1 forum search XSS, file.php traversal and Glossary SQL injection (version) - Checks
rcasefor^le141-xss$→ finding QoD 70: Moodle <= 1.4.1 file.php traversal and Glossary SQL injection (version) - Checks
rcasefor^le142-noxss$→ finding QoD 70: Moodle 1.4.x before 1.4.3 forum search XSS and file.php traversal (version) - Checks
rcasefor^le142-xss$→ finding QoD 70: Moodle 1.4.x before 1.4.3 file.php traversal (version)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2004-1424
- https://nvd.nist.gov/vuln/detail/CVE-2004-1425
- https://nvd.nist.gov/vuln/detail/CVE-2004-2232
- http://www.securityfocus.com/bid/11688
- https://github.com/moodle/moodle/blob/v1.4.2/mod/forum/view.php
Feed source — tests/vulnerabilities/moodle/moodle-1-4-2-multiple-vulnerabilities.yaml
# Moodle <= 1.4.2 — forum view.php search XSS (CVE-2004-1424), file.php session
# file traversal (CVE-2004-1425), Glossary sql.php SQL injection (CVE-2004-2232).
#
# Source (moodle/moodle tags v1.4.1 / v1.4.2 / v1.4.3):
# - mod/forum/view.php takes `search` raw (optional_variable + register_globals)
# and, for a visitor who cannot edit the forum, prints it through
# forum_print_search_form() into `<input name=search ... value="$search">`.
# The site news forum belongs to the front-page course (category 0), so no
# login is needed. 1.4.3 reads it with optional_param('search', '') whose
# default PARAM_CLEAN runs strip_tags() with $ALLOWED_TAGS: the <script>
# element is removed (magic_quotes_gpc only adds a backslash before the `"`).
# - mod/glossary/sql.php (<= 1.4.1) splices the category id `hook` unquoted
# into `ce.categoryid = $hook`; 1.4.2 quotes it. Reaching it needs a glossary
# activity the visitor may view: not present on a default site → version only.
# - file.php (<= 1.4.2) allows one `..` in the slash argument; reading a session
# file needs a course directory under dataroot → version only.
# - Every page footer of the front page carries
# `<a title="moodle $CFG->release ($CFG->version)" href="http://moodle.org/"`.
#
# Detection:
# - QoD 75 (CVE-2004-1424): under / and /moodle, mod/forum/view.php?f=1|2 with
# search="><script>alert(/noctis<random>/)</script>; confirmed when the reply
# carries the script element unescaped and a random page of the same
# directory, given the same query, answers without it.
# - QoD 70: the front-page footer release is <= 1.4.2 (CVE-2004-1424/1425, plus
# CVE-2004-2232 when <= 1.4.1). With the XSS proven, the version finding names
# only the CVEs the proof does not cover.
#
# Ported from OpenVAS/Greenbone NVT `pre2008/moodle_sql_inject.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.15639, GPL-2.0-only): version-only check on the
# Moodle install found by the product detection, regex
# ^(0\..*|1\.([0-4][^0-9]?|[0-4]\.[012][^0-9]?))$. Differences: an in-band
# proof of the forum XSS, and the version regex covers every 1.0–1.3.x point
# release (the NASL's misses 1.3.5 and the like) while leaving 1.4.2+ weekly
# builds out.
# CVSS: NVD carries only CVSS v2 scores (7.5 SQLi, 5.0 traversal, 4.3 XSS).
uid: 5c5e65ae-c835-449d-a705-3de845c50069
name: "Moodle <= 1.4.2 forum search XSS, file.php traversal and Glossary SQL injection"
description: |
Moodle 1.4.2 and earlier print the search parameter of the forum page
mod/forum/view.php unescaped into the page's search box, so a crafted link
runs attacker script in the browser of whoever follows it (CVE-2004-1424);
the front-page news forum needs no login. The same releases let file.php
climb out of the course files with "..", exposing session files
(CVE-2004-1425), and Moodle 1.4.1 and earlier build a Glossary query with
an unquoted category id (CVE-2004-2232).
Under the web root and /moodle, this check opens the forum page for forum
ids 1 and 2 with a search value that closes the input tag and adds a script
element carrying a random marker. The XSS is confirmed when the page
returns that script element unescaped, and a random page of the same
directory, given the same parameters, does not (which rules out servers
that echo any URL). The release named in the front-page footer
("moodle 1.4.2 (2004083125)") reports the other flaws when it is 1.4.2 or
older, and the XSS too when its probe found no reachable forum.
cves: [CVE-2004-1424, CVE-2004-1425, CVE-2004-2232]
cvss: 7.5
severity: high
category: xss
confidence_base: 0.30
tags: [moodle, lms, php, xss, sqli, path-traversal, version-check]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2004-1424"
- "https://nvd.nist.gov/vuln/detail/CVE-2004-1425"
- "https://nvd.nist.gov/vuln/detail/CVE-2004-2232"
- "http://www.securityfocus.com/bid/11688"
- "https://github.com/moodle/moodle/blob/v1.4.2/mod/forum/view.php"
steps:
- id: gen-marker
action: script
code: |
let tok = "noctis" + rand_int(10000000, 99999999);
#{ tok: tok,
want: "<script>alert(/" + tok + "/)</script>",
p: "%22%3E%3Cscript%3Ealert%28%2F" + tok + "%2F%29%3C%2Fscript%3E",
ctl: "noctis" + rand_hex(6) }
store_as: sc
- id: init-hit
action: set_var
var_name: hit
var_value: ""
- id: init-ver
action: set_var
var_name: ver
var_value: ""
# ── Per install dir × forum id (loop group) ──────────────────────────────
- id: init-r
action: set_var
var_name: r
var_value: {status: 0, body: ""}
loop:
var: v
over:
- {d: "", f: 1}
- {d: "", f: 2}
- {d: "/moodle", f: 1}
- {d: "/moodle", f: 2}
- id: init-c
action: set_var
var_name: c
var_value: {status: 0, body: ""}
- id: init-home
action: set_var
var_name: home
var_value: {status: 0, body: ""}
# Front page of the dir (once per dir, until a release was read).
- id: home-page
action: http_request
method: GET
path: "{{v.d}}/"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 5
condition: 'ver == "" && v.f == 1'
store_as: home
- id: read-release
action: script
code: |
if ver != "" { ver } else {
let b = if type_of(home.body) == "string" { home.body } else { "" };
let m = eregmatch("title=\"moodle ([0-9][^\"(<>]{0,40}) \\(([0-9]{10})\\)\"", b);
if m.len() == 3 { m[1] + " (" + m[2] + ") at " + v.d + "/" } else { "" }
}
store_as: ver
- id: probe
action: http_request
method: GET
path: "{{v.d}}/mod/forum/view.php?f={{v.f}}&search={{sc.p}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 5
condition: 'hit == ""'
store_as: r
- id: check-probe
action: script
condition: 'hit == ""'
code: |
let b = if type_of(r.body) == "string" { r.body } else { "" };
r.status >= 200 && b.contains(sc.want)
store_as: reflected
# Generic-reflection control: same query on a random page of the directory.
- id: control
action: http_request
method: GET
path: "{{v.d}}/mod/forum/{{sc.ctl}}.php?f={{v.f}}&search={{sc.p}}"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 5
condition: 'hit == "" && reflected'
store_as: c
- id: check
action: script
condition: 'hit == ""'
code: |
let cb = if type_of(c.body) == "string" { c.body } else { "" };
let ok = c.status > 0 && c.status != 429 && c.status < 500;
if reflected && ok && !cb.contains(sc.want) { v.d + "/mod/forum/view.php?f=" + v.f + "&search= (HTTP " + r.status + ")" } else { "" }
store_as: hit
# ── Findings: a one-pass loop group, so they run once after the probes ───
- id: end-probes
action: set_var
var_name: reported
var_value: true
loop:
var: once
over: ["once"]
# XSS (QoD 75)
- id: report-xss
action: match
source: hit
pattern: "/mod/forum/view\\.php\\?f="
condition: 'hit != ""'
on_match:
finding:
title: "Moodle forum view.php search parameter cross-site scripting (CVE-2004-1424)"
description: "Moodle returned a script element passed in the search parameter of the forum page unescaped, inside the page's search box: a crafted link runs attacker script in the browser of a user who follows it, in the context of the Moodle site, and can steal that user's session."
remediation: "Upgrade Moodle: 1.4.3 and later strip tags from the forum search parameter. Moodle 1.4 is long out of support; move to a maintained release."
cves: [CVE-2004-1424]
cvss: 4.3
severity: medium
confidence_delta: 0.50
qod: 75
evidence: "{{hit}} returned {{sc.want}} unescaped; a random page of the same directory did not reflect it"
# ── Release fallback (QoD 70) ────────────────────────────────────────────
# case: "<le141|le142>-<xss|noxss>" — which CVEs the release covers, and
# whether the XSS was already proven in-band.
- id: release-case
action: script
code: |
// Spaces dropped ("1.4.2 +" = weekly build 1.4.2+). Weekly builds after
// 1.4 / 1.4.1 ("1.4+", "1.4.1+") predate 1.4.2: XSS + traversal only.
let rel = if ver != "" { str_replace(split(ver, " (")[0], " ", "") } else { "" };
let base = if rel == "" { "" }
else if ereg("^(0\\.|1\\.[0-3]([^0-9]|$)|1\\.4(\\.[01])?([^0-9.+]|$))", rel) { "le141" }
else if ereg("^1\\.4(\\.[01])?\\+", rel) { "le142" }
else if ereg("^1\\.4\\.2([^0-9.+]|$)", rel) { "le142" }
else { "" };
if base == "" { "" } else if hit != "" { base + "-xss" } else { base + "-noxss" }
store_as: rcase
- id: report-version-le141-noxss
action: match
source: rcase
pattern: "^le141-noxss$"
condition: 'rcase == "le141-noxss"'
on_match:
finding:
title: "Moodle <= 1.4.1 forum search XSS, file.php traversal and Glossary SQL injection (version)"
description: "The Moodle front page reports a release of 1.4.1 or older: the forum page reflects its search parameter unescaped (CVE-2004-1424), file.php accepts a \"..\" that reaches session files (CVE-2004-1425) and the Glossary module builds a query with an unquoted category id (CVE-2004-2232)."
remediation: "Upgrade Moodle to 1.4.3 or later; Moodle 1.4 is long out of support, so move to a maintained release."
cves: [CVE-2004-1424, CVE-2004-1425, CVE-2004-2232]
confidence_delta: 0.40
qod: 70
evidence: "front page footer names moodle release {{ver}}"
- id: report-version-le141-xss
action: match
source: rcase
pattern: "^le141-xss$"
condition: 'rcase == "le141-xss"'
on_match:
finding:
title: "Moodle <= 1.4.1 file.php traversal and Glossary SQL injection (version)"
description: "The Moodle front page reports a release of 1.4.1 or older: besides the forum XSS proven by this check, file.php accepts a \"..\" that reaches session files (CVE-2004-1425) and the Glossary module builds a query with an unquoted category id (CVE-2004-2232)."
remediation: "Upgrade Moodle to 1.4.3 or later; Moodle 1.4 is long out of support, so move to a maintained release."
cves: [CVE-2004-1425, CVE-2004-2232]
confidence_delta: 0.40
qod: 70
evidence: "front page footer names moodle release {{ver}}"
- id: report-version-le142-noxss
action: match
source: rcase
pattern: "^le142-noxss$"
condition: 'rcase == "le142-noxss"'
on_match:
finding:
title: "Moodle 1.4.x before 1.4.3 forum search XSS and file.php traversal (version)"
description: "The Moodle front page reports release 1.4.2 or a 1.4 / 1.4.1 weekly build (\"+\"): the forum page reflects its search parameter unescaped (CVE-2004-1424) and file.php accepts a \"..\" that reaches session files (CVE-2004-1425)."
remediation: "Upgrade Moodle to 1.4.3 or later; Moodle 1.4 is long out of support, so move to a maintained release."
cves: [CVE-2004-1424, CVE-2004-1425]
cvss: 5.0
severity: medium
confidence_delta: 0.40
qod: 70
evidence: "front page footer names moodle release {{ver}}"
- id: report-version-le142-xss
action: match
source: rcase
pattern: "^le142-xss$"
condition: 'rcase == "le142-xss"'
on_match:
finding:
title: "Moodle 1.4.x before 1.4.3 file.php traversal (version)"
description: "The Moodle front page reports release 1.4.2 or a 1.4 / 1.4.1 weekly build (\"+\"): besides the forum XSS proven by this check, file.php accepts a \"..\" that reaches session files (CVE-2004-1425)."
remediation: "Upgrade Moodle to 1.4.3 or later; Moodle 1.4 is long out of support, so move to a maintained release."
cves: [CVE-2004-1425]
cvss: 5.0
severity: medium
confidence_delta: 0.40
qod: 70
evidence: "front page footer names moodle release {{ver}}"