| tiêu đề | SourceCodester (submitted by katojkalemba) Online Food Ordering System 1.0 Improper Authentication |
|---|
| Mô tả | ## Description
The shared admin guard handles an unauthenticated request by setting a message and sending a `Location` header. It never ends the PHP request. Every page that includes this guard continues through its own queries, rendering, and POST handlers, so the redirect is not an authorization boundary.
## Source evidence and analysis
Repository root for the paths below: `targets/web-scan-20261028/web/`.
`admin/partials/user_logged.php` (lines 1–6):
```php
if (!isset($_SESSION['user'])) {
$_SESSION['not-logged-in'] = "please login";
header("Location:" . SITEURL . 'admin/login.php');
}
```
The shared header includes the guard and then returns to the caller (`admin/partials/header.php`, lines 1–4):
```php
include("../config/constants.php");
include("user_logged.php");
```
The caller continues with protected work. For example, `admin/admin.php` selects every administrator and renders the names and usernames (lines 110–127):
```php
$sql = "select * from tbl_admin";
$res = mysqli_query($conn, $sql) or die(mysqli_error($conn));
...
<td><?php echo $full_name ?></td>
<td><?php echo $username ?></td>
```
In PHP, `header('Location: ...')` only sets a response header. It does not terminate execution. Because the guard has no `exit`, `die`, or equivalent return from the request, the protected page still runs after the redirect is queued. This affects pages whose access control depends on this include, including POST handlers that execute after `include('partials/header.php')`.
## Reproduction (local instance only)
1. Start the application with its test database and use a fresh client with no session cookie.
2. Request the protected administrator list without following redirects:
```bash
BASE=http://127.0.0.1:8080
curl -sS -D - "$BASE/admin/admin.php"
```
3. Inspect the first response. It contains a redirect to `admin/login.php`, but PHP has continued rendering the page body and running the administrator query. A browser normally follows the redirect; the response body can be inspected with `curl` or server-side request tracing.
## Impact and scope
An unauthenticated caller can reach protected page logic, including administrator data reads and state-changing handlers that rely only on this include. The exact reachable operation depends on each page's own input checks. Endpoints that omit the shared guard altogether are tracked separately in G02. A reverse proxy or web-server rule could add an external access boundary, but none is established by the reviewed application source.
## Recommended fix
Make authorization fail closed: after the unauthenticated check, terminate the request (and preferably return a 401/403 response for non-browser clients). Apply the same authorization middleware to every state-changing endpoint; a redirect must only be a user-experience action after access has already been denied.
|
|---|
| Nguồn | ⚠️ https://gist.github.com/Ka7arotto/c74ecc431ff3df8150a66bd3063113c5 |
|---|
| Người dùng | Goku (UID 80486) |
|---|
| Đệ trình | 28/10/2026 12:52 (cách đây 29 ngày) |
|---|
| Kiểm duyệt | 26/11/2026 01:58 (29 days later) |
|---|
| Trạng thái | được chấp nhận |
|---|
| Mục VulDB | 444126 [SourceCodester Online Food Ordering System 1.0 user_logged.php nâng cao đặc quyền] |
|---|
| điểm | 20 |
|---|