| Título | SourceCodester Online Food Ordering System v1.0 Improper Authentication |
|---|
| Descripción |
## Description
The deletion endpoints perform irreversible database operations based on request parameters without first establishing that the caller is an administrator. Some bootstrap the database directly; the order endpoint includes the shared guard, but that guard only sends a redirect and does not terminate execution (G01).
## Source evidence and analysis
Repository root: `targets/web-scan-20261028/web/`.
`admin/delete.php` (lines 2–13) connects the session/database, accepts the ID, and deletes the row without an identity check:
```php
include('../config/constants.php');
if (isset($_GET['id']) && isset($_GET['image_name'])) {
$id = intval($_GET['id']);
$image = $_GET['image_name'];
...
$sql = "delete from tbl_food where id=$id";
$res = mysqli_query($conn, $sql);
}
```
`admin/delete_category.php` has the same pattern (lines 2–5, 20–22):
```php
include('../config/constants.php');
if (isset($_GET['id']) && isset($_GET['image_name'])) {
$id = intval($_GET['id']);
$image = $_GET['image_name'];
...
$sql = "DELETE FROM tbl_category WHERE id=$id";
$res = mysqli_query($conn, $sql);
}
```
`admin/delete_admin.php` uses a prepared statement and numeric ID validation, but still has no authentication include or session check (lines 2–12):
```php
include('../config/constants.php');
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$id = intval($_GET['id']);
$stmt = $conn->prepare("DELETE FROM tbl_admin WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
}
```
`admin/delete_order.php` includes `partials/header.php` (line 2), then continues to delete after the flawed guard; it has no additional authorization check (lines 3–9). Prepared SQL protects its ID from injection but does not authorize the action.
These examples show why input validation and prepared statements are not substitutes for access control: they constrain *which* row is deleted, but not *who* is allowed to delete it. The category and food endpoints also perform image-file operations, discussed separately in G18.
## Reproduction (disposable local database only)
Create one disposable row of each type, record its ID, and send the requests with a fresh client and no session cookie. Do not use real or shared data.
```bash
BASE=http://127.0.0.1:8080
curl -i "$BASE/admin/delete.php?id=<FOOD_ID>&image_name="
curl -i "$BASE/admin/delete_category.php?id=<CATEGORY_ID>&image_name="
curl -i "$BASE/admin/delete_admin.php?id=<ADMIN_ID>"
curl -i "$BASE/admin/delete_order.php?id=<ORDER_ID>"
```
For the first two requests, an empty `image_name` passes the parameter-presence check while skipping file deletion. The corresponding disposable database row is still deleted. In the last request the redirect from the shared guard does not stop the handler.
## Impact and scope
An unauthenticated remote caller can remove food, category, administrator, or order records, causing data loss or disrupting administration and fulfillment. The operation is issued as a GET, so it may also be triggerable cross-site in a victim's browser; the primary issue is that no authenticated identity is required at all. Exploitability assumes the routes are web-accessible and the target IDs exist.
## Recommended fix
Require a valid administrator session and appropriate authorization at the start of every deletion endpoint, then reject and terminate unauthorized requests before any file or database side effect. Use POST/DELETE with CSRF protection for state-changing actions. Keep prepared statements for SQL safety, but do not treat them as authorization.
|
|---|
| Fuente | ⚠️ https://gist.github.com/Ka7arotto/c74ecc431ff3df8150a66bd3063113c5 |
|---|
| Usuario | Goku (UID 80486) |
|---|
| Sumisión | 2026-10-28 12:56 (hace 29 días) |
|---|
| Moderación | 2026-11-26 01:58 (29 days later) |
|---|
| Estado | Aceptado |
|---|
| Entrada de VulDB | 444127 [SourceCodester Online Food Ordering System 1.0 Deletion Endpoint admin/delete.php id/image_name autenticación débil] |
|---|
| Puntos | 20 |
|---|