| عنوان | SourceCodester Online Food Ordering System 1.0 SQL Injection |
|---|
| الوصف | # [G07] The password-change page interpolates the request ID into SQL
**Assessment:** Confirmed by source audit; reported by the final Agent run.
**Vulnerability type:** SQL Injection (CWE-89).
## Description
The password-change page inserts `GET id` directly into its initial account lookup. This query runs while rendering the page, before the current-password comparison. The same raw ID is later reused in the password `UPDATE`.
## Source evidence and analysis
Repository root: `targets/web-scan-20261028/web/`.
`admin/change_pwd.php` (lines 4–11) reads and queries the unvalidated ID:
```php
if (isset($_GET['id'])) {
$id = $_GET['id'];
}
$sql = "select * from tbl_admin where id=$id";
$res = mysqli_query($conn, $sql);
$fetch = mysqli_fetch_assoc($res);
```
Only the later POST flow checks the old password (lines 13–19). The update uses the same raw ID (lines 25–33):
```php
if ($password === $current_password) {
...
$update = "update tbl_admin SET
password = '$newPassword'
where id= $id;
";
$execute = mysqli_query($conn, $update);
}
```
The current-password check does not protect the earlier `SELECT`; a request can alter that query before any password is submitted. The update also remains injectable, although successfully reaching that branch additionally requires the current-password comparison to pass.
## Reproduction (local instance only)
Use a test database with an administrator row. The request is read-only and changes the predicate to select a row despite the nonexistent ID:
```bash
BASE=http://127.0.0.1:8080
curl -i "$BASE/admin/change_pwd.php?id=0%20OR%201=1"
```
The page can render the selected username in its response before any current password has been supplied. Do not submit a password-change POST for this proof.
## Impact and scope
The initial query permits SQL predicate manipulation and can expose the selected administrator's username through the page. The code does not display the password hash in the response. A password update is not established by this proof and still checks the current password; do not describe this issue as an unconditional password reset. The shared admin guard is also non-terminating (G01).
## Recommended fix
Bind a validated integer ID in a prepared `SELECT` and `UPDATE`. Authorize the current administrator against the target account rather than trusting a caller-selected ID, and retain a correctly verified current-password check for password changes.
|
|---|
| المستخدم | Goku (UID 80486) |
|---|
| ارسال | 28/10/2026 01:25 PM (29 أيام منذ) |
|---|
| الاعتدال | 26/11/2026 01:58 AM (29 days later) |
|---|
| الحالة | تمت الموافقة |
|---|
| إدخال VulDB | 444130 [SourceCodester Online Food Ordering System 1.0 admin/change_pwd.php id حقن SQL] |
|---|
| النقاط | 20 |
|---|