# Authentication incident review — 16–17 November 2026

**Status: OPEN. The incident is not cleared for deployment sign-off.**

The pasted incident summary identifies `192.248.106.153` and reports four HTTP 200 password-login responses, 41 HTTP 201 registration responses, and 28 HTTP 200 OTP-verification responses. Raw production logs, response bodies, the deployed build and production database evidence have not been supplied. These counts are user-reported and have not been independently reconciled.

The workspace reports/artifacts, supplied attachment locations and local XAMPP Apache logs were checked. No raw production access/PM2/database incident evidence was found; the local Apache logs contain no matching IP entries. The local application database is not evidence from the Linux production database `newcw`. No real user tables were queried or changed for this investigation.

## What the response codes mean in the inspected source

| Reported events | Inspected handler behavior | Investigation status |
| --- | --- | --- |
| Four `POST /api/auth/login` HTTP 200 responses | The current main handler returns 200 after password/account checks and session creation, and sets an authentication cookie. MFA continuation returns 202. | Potential session issuance requiring urgent account/session correlation. Accounts and authorization of the activity are unknown. |
| 41 `POST /api/auth/register` HTTP 201 responses | Current registration creates or refreshes a pending registration and returns `requiresEmailVerification: true`, with no authenticated cookie. | A 201 is not a completed account in this code. Exact deployed revision and corresponding pending/active account records still need review. |
| 28 `POST /api/auth/verify-otp` HTTP 200 responses | Current code can activate an account after OTP validation and issue a session, or complete legacy email verification. | These are material activation/session candidates and must be correlated alongside the four logins. |

The inspected source is the local hardened version, not proof of what ran on 16–17 November. Apache may also log an upstream/rewrite result rather than the behavior assumed here. Verify the incident-time build and response semantics. Counts are requests, not distinct people or distinct accounts. Timestamp proximity alone cannot associate a failed-login fingerprint with a subsequent successful response.

## Preserve evidence and establish the running version

Use a private evidence directory outside the web root. Preserve original Apache access/error logs including rotations, PM2 `cv` output/error logs, the incident-time application/build revision, relevant database/audit exports and Brevo delivery records. Record SHA-256 hashes, source paths, collection time and timezones. Work from copies. Do not rotate/truncate logs, delete accounts or reset passwords while collecting evidence. Do not record passwords, cookies, reset tokens, OTP codes or environment secrets.

Use `pm2 describe cv` to establish the application path and actual log locations. Verify it is the website on port 3005. Do not inspect or change the separate sales application on port 3000. Preserve the relevant `.next/BUILD_ID` and compiled authentication route artifacts where available; a working-tree Git hash alone may differ from the running build. Avoid `pm2 env`, dumps of process environments or configuration files containing secrets in shared output.

Apache log timestamps contain their own UTC offset. Record the Apache `LogFormat` and historical proxy configuration so the logged address can be attributed correctly. A client-supplied forwarded-IP header is not reliable evidence unless the ingress overwrote it. Preserve original timestamps and convert to UTC for correlation; do not assume the database or PM2 timezone.

## Extract a secret-free request timeline

Run the repository's offline analyzer against preserved, non-overlapping copies of the actual production logs. It does not connect to a server or database, modify input evidence, print raw log lines, or conclude that a status code proves a compromise.

```sh
node scripts/review-auth-access-logs.mjs \
  --ip 192.248.106.153 \
  --from 2026-11-16 --through 2026-11-17 \
  --out /private/evidence/auth-timeline.json \
  /private/evidence/site-access.log \
  /private/evidence/site-access.log.1.gz
```

Substitute actual preserved paths. The output file must not already exist and cannot overwrite an input. Gzip rotations are supported. Byte-identical files are skipped using their hashes; overlapping content in differently encoded/partially copied logs still needs manual exclusion. Custom log formats with unparsed lines need parser review before counts are considered complete.

The timeline reconciles the reported 4/41/28 counts, records source hashes/line references and leaves account/session attribution explicitly unresolved. Query strings, referrers, user agents, cookies and request bodies are excluded; non-authentication paths are grouped to avoid exporting tokens embedded in URL paths. Do not use matching counts as sign-off.

## Read-only database correlation

Use a read-only database account on production `newcw` or an incident-time snapshot. Inspect columns first because the live schema may differ. The following queries do not change records.

```sql
SELECT DATABASE(), NOW(), UTC_TIMESTAMP(), @@global.time_zone, @@session.time_zone;

SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'newcw'
  AND TABLE_NAME IN ('users', 'users_pending_registration', 'users_email_otp',
                     'account_security_audit', 'users_password_history')
ORDER BY TABLE_NAME, ORDINAL_POSITION;
```

After confirming the schema and converting the incident window into the database timezone:

```sql
START TRANSACTION READ ONLY;

-- Candidate creation window only; existing targeted users must also be reviewed.
SELECT id, role_id, email_status, account_status, created_at, updated_at, last_seen,
       LEFT(SHA2(LOWER(TRIM(email)), 256), 12) AS email_fingerprint
FROM users
WHERE created_at >= '2026-11-16 00:00:00'
  AND created_at <  '2026-11-18 00:00:00'
ORDER BY created_at, id;

-- Pending records may already have been removed/overwritten after completion or resend.
SELECT id, LEFT(SHA2(LOWER(TRIM(email)), 256), 12) AS email_fingerprint,
       registration_context, created_at, updated_at, otp_sent_at, otp_expires_at, otp_attempts
FROM users_pending_registration
WHERE created_at >= '2026-11-16 00:00:00'
  AND created_at <  '2026-11-18 00:00:00'
ORDER BY created_at, id;

SELECT id, user_id, action, created_at
FROM account_security_audit
WHERE ip_address = '192.248.106.153'
  AND created_at >= '2026-11-16 00:00:00'
  AND created_at <  '2026-11-18 00:00:00'
ORDER BY created_at, id;

COMMIT;
```

The literal date bounds above are templates, not confirmation of the server's timezone. Query only columns verified to exist. Historical audit IPs may have been read from untrusted forwarded headers, so validate their provenance before attribution.

For accounts positively identified through request-correlated application events, review their verification status, role, creation/activation evidence, password/MFA/role changes and protected-resource requests. Select only needed fields; never export `password`, `pin`, `token`, `otp_hash` or email bodies. Use account IDs or normalized email fingerprints for reports. Restrict detailed account contact information to the incident reviewer when needed.

Current `last_seen`, `updated_at`, an OTP row or an email-delivery receipt cannot independently prove who logged in. These values are mutable or overwritten. The inspected older logging records failed-login fingerprints but does not provide a durable, request-correlated success ledger. If preserved logs/backups do not establish a match, classify the event as **inconclusive**, not harmless or confirmed unauthorized. New security controls cannot reconstruct missing historical evidence.

## Required event-by-event decisions

For every one of the four login-200 candidates, record the source hash/line, Apache/UTC time, verified originating IP, deployed handler/build, correlated account ID, session-issuance evidence, subsequent protected requests, whether that activity was authorized, and the evidence supporting the decision.

For all 41 registration-201 candidates, determine whether the request only refreshed a pending record, created an account in the incident-time implementation, or later resulted in verified activation. Correlate the 28 verification-200 candidates, and identify duplicates and existing-account verifications. Confirm whether any affected account had administrator privileges or accessed protected student/subscription/payment information.

Inspect Brevo delivery metadata for the incident window to determine OTP/recovery-email volume, failures and repeated recipients. Do not expose OTP values or message contents. Inspect relevant activity by other IPs for the identified accounts; do not block countries based on geolocation.

Record each event as **authorized**, **confirmed unauthorized**, or **inconclusive**. Request approval for any account suspension, session revocation, password reset or other remediation that changes real records. Do not automatically delete suspicious registrations or alter subscriptions/payments.

**Closure requirement:** all candidate events are accounted for with evidence and any residual uncertainty is explicitly accepted by the site owner. This document and the analyzer are a safe investigation procedure; they are not a completed investigation of the four logins or 41 registrations.
