# Admin Web Security Compliance Report

Assessment date: 2026-11-29  
Scope: `admin-web` frontend and its security-related integrations/configuration.  
Assessment type: source and configuration review; not a penetration test or formal certification.

## Executive Summary

The Admin Web uses a Next.js server-side BFF pattern. Authentication tokens are held in an encrypted server-validated `HttpOnly` cookie, and browser API calls go through a same-origin proxy. Mutating BFF endpoints check request origin. These are meaningful protections. No `localStorage`/`sessionStorage` token persistence or `dangerouslySetInnerHTML` use was found in the inspected source.

No critical or high severity vulnerability was verified in the frontend source reviewed. Several controls depend on the backend or deployment and could not be verified from this scope. The most important remaining items are confirmation of backend authorization/rate limiting/audit logging, production HTTPS and cookie configuration, and reducing the production CSP's reliance on `unsafe-inline` scripts. Two safe header hardenings were applied in `next.config.ts`.

Dependency auditing and executable verification could not complete: `npm audit --json` failed with `ENOSPC` (no space left on device), and the local `node_modules` installation is incomplete (Next package/binary unavailable). This is not evidence of a clean dependency tree or a successful build.

## Scope

Reviewed files under `admin-web`, including package metadata and lockfile entries, Next configuration, environment template, proxy/session/auth routes, frontend API client, route guard, admin shell, and relevant UI sources. Backend implementation and live deployment were not audited. Existing unrelated working-tree changes were preserved.

## Security Compliance Methodology

Applied the installed `security-compliance-compliance-check` skill's evidence-based gap analysis and remediation guidance. Reviewed source/configuration against relevant OWASP Top 10 and Secure Coding Practices concepts, OWASP API Security risks, secure session/authentication practices, least privilege, data minimization, and dependency/configuration management. Findings are limited to evidence available in this repository; no formal regulatory applicability determination was possible.

## Skills Used

- `security-compliance-compliance-check` (installed skill; its implementation playbook was also reviewed)

## Frameworks Referenced

- OWASP Top 10 (applicable categories)
- OWASP API Security Top 10 (backend-dependent items)
- OWASP ASVS concepts (authentication, session, access control, configuration)
- OWASP Secure Coding Practices
- Secure Software Development Lifecycle and least privilege

No certification or formal compliance claim is made. GDPR, HIPAA, SOC 2, and PCI-DSS applicability cannot be established from frontend source alone.

## Architecture Overview

- Framework: Next.js App Router, TypeScript, React.
- Declared versions: Next.js `^16.4.6`, React/React DOM `^19.3.1`, TypeScript `~5.9.3`; exact installed versions were unavailable because dependencies are not installed completely.
- TypeScript: strict mode, no emit, bundler module resolution, alias `@/*` to `src/*`.
- Dependencies: `lucide-react`, `openapi-fetch`, `zod`; tests/tooling include Vitest, Testing Library, ESLint, and OpenAPI type generation.
- Scripts: `dev`, `build`, `start`, `lint`, `typecheck`, `test`, `openapi:types`.
- App routes: public root and login; admin areas for dashboard, students, verifications, academics, teachers, routine, notices, attendance, assignments, results, reports, and settings.
- Route gating: `src/proxy.ts` redirects unauthenticated requests based on presence of the session cookie. This is only a navigation gate; BFF endpoints validate/decrypt the session separately.
- Authentication: `/api/auth/login`, `/session`, `/refresh`, `/logout`. Access and refresh tokens are sealed with AES-256-GCM into an `HttpOnly`, `SameSite=Lax` cookie; session has an 8-hour idle and 24-hour absolute lifetime.
- API access: client calls same-origin `/api/proxy/*`; the server validates the session and adds the bearer token to a fixed configured backend origin. The backend is expected to make authorization decisions.
- Environment: server-only `API_BASE_URL`, `SESSION_SECRET`, `COOKIE_SECURE`; `.env.example` contains placeholders/local defaults. No `NEXT_PUBLIC_*` variables or other env files were found in the target directory listing.
- Deployment: Next config supplies browser security headers. Deployment platform, TLS termination, backend CORS/rate-limiting/logging policies, and production environment values were not available.

## Compliance Checklist

| Control | Status | Evidence / risk | Affected file | Recommendation | Remediation |
|---|---|---|---|---|---|
| Passwords not stored by frontend | PASS | Login submits credentials to same-origin BFF; no browser persistence found. | `src/app/login/page.tsx` | Keep credentials out of logs and storage. | No change needed. |
| Token storage protected from browser JS | PASS | AES-256-GCM sealed cookie; cookie has `HttpOnly`, `SameSite=Lax`, path `/`; HTTPS protocol forces Secure. | `src/lib/session-cookie.ts` | Ensure production uses HTTPS and a unique high-entropy secret. | Verified in source. |
| Session expiry | PASS | 8-hour idle and 24-hour maximum enforced when unsealing. | `src/lib/session-cookie.ts` | Keep backend token expiry/revocation aligned. | Verified in source. |
| Login/refresh/logout CSRF checks | PASS | Mutating endpoints call same-origin validation; missing origin and referer rejected. | `src/lib/session-cookie.ts`, `src/app/api/auth/*` | Verify trusted proxy host/origin behavior in production. | Verified in source. |
| Protected page routing | PARTIAL | Route redirect checks cookie presence only; this is not authentication. BFF validates cookie cryptographically. | `src/proxy.ts`, `src/app/api/proxy/[...path]/route.ts` | Keep all data access behind server/backend authorization. | No frontend-only route check treated as authorization. |
| Backend authorization and resource ownership | NOT VERIFIED | Frontend displays permissions and sends requests; backend implementation was outside audit scope. | Backend API (not inspected) | Verify every endpoint enforces role, permission, tenant/resource scope, and ownership. | Backend review required. |
| Password policy, MFA, recovery, lockout | NOT VERIFIED | Login is delegated to upstream; frontend has no password reset or MFA flow visible. | Backend auth and deployment | Verify backend policy, MFA requirements, recovery, throttling, and generic failure behavior. | Backend verification required. |
| Token refresh and revocation | PARTIAL | Refresh rotation and logout revocation are implemented; single-flight lock is process-local. | `src/app/api/auth/refresh/route.ts`, `src/app/api/proxy/[...path]/route.ts`, `src/lib/refresh-lock.ts` | Validate refresh rotation under multi-instance deployment; coordinate lock or design backend rotation for concurrent requests. | Documented; backend/deployment validation required. |
| XSS / unsafe HTML | PASS | No `dangerouslySetInnerHTML` or direct `innerHTML` use found; React renders values normally. | `src/` | Continue treating API strings as untrusted React text. | Verified by source search. |
| CSP and clickjacking | PARTIAL | CSP uses `frame-ancestors 'none'`; X-Frame-Options DENY; CSP still allows `unsafe-inline` scripts. `object-src 'none'` added. | `next.config.ts` | Adopt nonce/hash CSP for scripts after validating Next rendering and third-party needs. | `object-src` remediated; inline script gap remains. |
| HTTP security headers | PARTIAL | `nosniff`, Referrer-Policy, Permissions-Policy, CSP, and X-Frame-Options configured. HSTS absent before this review; production HSTS added. | `next.config.ts` | Confirm public HTTPS at deployment and validate actual response headers. | HSTS added; runtime verification unavailable. |
| CORS / open redirect / SSRF | PARTIAL | Browser uses same-origin BFF; upstream origin is fixed by server env. No user-controlled redirect target found in reviewed login flow. Actual backend CORS not inspected. | `src/app/api/proxy/[...path]/route.ts`, deployment/backend | Keep API origin server-controlled; verify backend CORS allowlist. | Backend/deployment validation required. |
| Proxy path validation | PASS | Decoded path segments reject traversal, slash, backslash, NUL, and empty segments. | `src/app/api/proxy/[...path]/route.ts` | Preserve fixed-origin construction and no-store behavior. | Verified in source. |
| Request size and rate limiting | NOT VERIFIED | No frontend throttling or explicit payload cap in BFF source. Backend/edge may provide controls. | Login/proxy routes and deployment | Enforce login throttling and request size limits at backend/edge; verify upstream limits. | Backend/deployment verification required. |
| Secrets/environment | PARTIAL | Production schema requires API URL and 32-character secret; no public env prefix found. `.env.example` has a dummy secret placeholder. Deployment values unavailable. | `src/lib/env.ts`, `.env.example` | Provision unique random secret in secret manager; enforce HTTPS and `COOKIE_SECURE=true` as deployment policy. | Source validation present; deployment not verified. |
| Sensitive data minimization | NOT VERIFIED | Types/UI include student/staff contact, academic and verification data; source cannot establish what backend returns or whether fields are necessary. | API contracts and backend | Review endpoint field selection and restrict access to sensitive records. | Backend/data-owner review required. |
| Security audit logging | NOT VERIFIED | Request IDs are forwarded, but this frontend source does not establish durable failed-login/admin-action audit trails. | Backend | Log auth failures, denied actions, role changes, and sensitive reads in protected backend audit storage; never log secrets/tokens. | Backend requirement. |
| Dependency vulnerabilities | NOT VERIFIED | `npm audit --json` failed due to ENOSPC; no trustworthy vulnerability result. | `package-lock.json` | Re-run audit in an environment with disk space; review advisories and compatibility before updates. | Blocked by environment. |
| Build, lint, types, tests | NOT VERIFIED | Dependencies are incomplete; Next package could not be resolved. | Project scripts | Run all scripts after restoring dependencies and disk capacity. | Blocked by environment. |

## Findings

### SEC-01 — Production CSP permits inline scripts

- **Severity:** MEDIUM
- **Compliance category:** XSS defense / security configuration
- **Affected file:** `admin-web/next.config.ts`
- **Root cause:** `script-src` includes `'unsafe-inline'` for production as well as development.
- **Impact:** An injection flaw elsewhere would have a weaker browser-side CSP barrier.
- **Evidence:** `script-src 'self' 'unsafe-inline'...` is built unconditionally, except development additionally allows `unsafe-eval`.
- **Recommended fix:** Move to a nonce/hash-based CSP compatible with Next.js rendering and verify all pages and scripts before removing the allowance.
- **Fix status:** Open; safely removing this without validating the framework output could break rendering. `object-src 'none'` was added as an independent defense.

### SEC-02 — HSTS was not configured

- **Severity:** LOW
- **Compliance category:** Transport security / security configuration
- **Affected file:** `admin-web/next.config.ts`
- **Root cause:** No Strict-Transport-Security header was configured.
- **Impact:** Browsers may permit downgrade/interception on a first or later HTTP visit, depending on deployment and browser state.
- **Evidence:** Existing header list had CSP, frame, MIME, referrer, and permissions headers but no HSTS.
- **Recommended fix:** Serve the admin site over HTTPS and send HSTS. Add `includeSubDomains` only after confirming every subdomain supports HTTPS.
- **Fix status:** Fixed in source: production response now emits `max-age=31536000`; live HTTPS/header behavior remains unverified.

### SEC-03 — Authorization, brute-force controls, and audit trail depend on uninspected backend/deployment

- **Severity:** MEDIUM (verification gap; not a confirmed backend vulnerability)
- **Compliance category:** Access control / authentication / logging / API security
- **Affected file:** Backend API and deployment configuration (outside audited code)
- **Root cause:** Frontend can only provide navigation/UI filtering; it cannot prove server-side role enforcement, login throttling, request caps, or durable audit logging.
- **Impact:** If the backend omits these controls, unauthorized access, account guessing, or inadequate incident investigation may result.
- **Evidence:** `src/components/admin-shell.tsx` fetches `auth/me` to filter navigation; frontend permissions are presentation logic. Login BFF delegates authentication upstream. No backend/deployment controls were in reviewed scope.
- **Recommended fix:** Audit every backend endpoint for authorization and ownership; apply login rate limits and body limits at the edge/backend; record security events without credentials/tokens.
- **Fix status:** Not remediated in frontend; backend verification required.

### SEC-04 — Refresh concurrency coordination is process-local

- **Severity:** LOW
- **Compliance category:** Session management / availability
- **Affected file:** `admin-web/src/lib/refresh-lock.ts`
- **Root cause:** The single-flight refresh map exists only in one Node process.
- **Impact:** Concurrent requests routed to different app instances may race a rotating refresh token and cause intermittent session invalidation, depending on backend token rotation behavior.
- **Evidence:** In-memory map keyed by a hash of refresh token; refresh requests run within this helper.
- **Recommended fix:** Confirm backend tolerates brief refresh-token overlap or implement distributed coordination/rotation semantics where needed.
- **Fix status:** Open; deployment topology and backend semantics unknown.

## Critical Risks

None verified in the inspected Admin Web source.

## High Risks

None verified in the inspected Admin Web source. Backend authorization remains unverified and must be reviewed before treating the system as secured.

## Medium Risks

- SEC-01: Production CSP allows inline scripts.
- SEC-03: Backend authorization, rate limiting, and security audit logging require verification; this is a scope gap, not a proven backend flaw.

## Low Risks

- SEC-02: HSTS was missing; source fix applied, deployment verification remains.
- SEC-04: Process-local refresh coordination may race across instances.

## Security Improvements Implemented

- Added `object-src 'none'` to the existing CSP.
- Added production-only `Strict-Transport-Security: max-age=31536000` without `includeSubDomains`.
- Preserved the pre-existing uncommitted image source CSP changes.

## Files Changed

- `admin-web/next.config.ts` — added `object-src 'none'` and production HSTS. This file already had uncommitted changes before the assessment; those were preserved.
- `admin-web/ADMIN_WEB_SECURITY_COMPLIANCE_REPORT.md` — this report.

## Verification Results

- Source inspection and targeted searches: completed.
- `npm audit --json`: attempted; failed with `ENOSPC` / no space left on device. No audit result obtained.
- `npm run lint`, `npm run typecheck`, `npm test`, and `npm run build`: attempted; each failed at npm startup with `ENOSPC` before the script ran. Separately, the Next package is unavailable in `node_modules`. Re-run when disk space and dependencies are available.
- Live HTTP header verification: not possible without a running deployment/server.
- Security tests already present in source cover session sealing/tampering, expiration, cookie flags, same-origin checks, and refresh lock behavior; they were not executable in this environment.

## Remaining Compliance Gaps

1. Verify backend role/permission checks and resource ownership on every sensitive endpoint.
2. Verify backend login throttling, account lockout/risk controls, request size limits, password recovery, MFA policy, refresh rotation, and token revocation.
3. Verify backend audit logging for failed authentication, denied authorization, sensitive data reads/exports, and privileged changes.
4. Verify actual production HTTPS, HSTS delivery, `COOKIE_SECURE=true`, secret-manager provisioning, and secret rotation.
5. Implement and validate nonce/hash CSP before removing production `'unsafe-inline'`.
6. Review student/staff/teacher/verification payloads for minimum necessary fields and role scope.
7. Re-run dependency audit, lint, typecheck, tests, and build after fixing disk/dependency availability.
8. Inspect deployment CORS, TLS, rate limits, logging, and monitoring configuration.

## Backend Requirements

The backend is the security boundary for role/permission and ownership enforcement. It should reject unauthorized requests regardless of frontend visibility, rate-limit authentication and sensitive endpoints, validate request schemas and sizes, rotate/revoke tokens safely, and maintain an access-controlled audit trail. It should return only fields needed for each role and avoid logging passwords, bearer tokens, refresh tokens, or signed credential material.

## Recommendations

1. Prioritize backend authorization and authentication review.
2. Restore disk capacity/dependencies and run the declared checks plus `npm audit`.
3. Verify production response headers and HTTPS cookie behavior at the deployed edge.
4. Adopt a nonce/hash CSP strategy, testing all Next.js routes before rollout.
5. Test refresh rotation in the actual multi-instance deployment topology.
6. Conduct a separate privacy/data-flow review with the institution's data owner to determine applicable regulatory obligations.

## Final Security Status

**PARTIAL / NOT VERIFIED FOR PRODUCTION.** The inspected frontend has several sound session and BFF protections, and two safe header improvements were made. Backend authorization, deployment controls, dependency vulnerability status, and executable verification remain unverified. This assessment is not a certification or proof of regulatory compliance.

