# Permissions & RBAC Fixes — Implementation Plan > **Date:** 2026-02-05 > **Status:** Draft > **Depends on:** [2026-02-05-permissions-audit-design.md](2026-02-05-permissions-audit-design.md) > **Scope:** Phased fix of all permission issues identified in the audit --- ## Phasing Strategy Fixes are grouped into four phases by severity and dependency: - **Phase A:** Critical security fixes (must-do before any multi-user use) - **Phase B:** High-severity gaps (needed for MSP readiness) - **Phase C:** Medium-severity improvements (better UX and consistency) - **Phase D:** Low-severity cleanup (nice-to-haves) Each phase is independently deployable. Phase A should be done as a single PR. --- ## Phase A: Critical Security Fixes **Branch:** `fix/critical-security` **Priority:** Immediate — blocks all other work ### A1. Remove Self-Assignable Admin Role **Files to modify:** - `backend/app/schemas/user.py` — Remove `role` from `UserCreate` - `backend/app/api/endpoints/auth.py` — Hardcode `role="engineer"` in registration **Changes:** ```python # schemas/user.py — Remove role from UserCreate class UserCreate(UserBase): # role field REMOVED — always defaults to "engineer" password: str = Field(..., min_length=10) # auth.py — Hardcode role new_user = User( ... role="engineer", # Always engineer; admin set via admin endpoint only ... ) ``` **New endpoint (optional, can defer to Phase B):** - `PUT /api/v1/admin/users/{user_id}/role` — Admin-only endpoint to change user roles **Tests to add:** - Attempt to register with `role: "admin"` → should still be engineer - Verify no field in registration request can escalate privileges ### A2. Escape HTML Export Output **Files to modify:** - `backend/app/api/endpoints/sessions.py` — HTML export function **Changes:** ```python from html import escape # Escape all user-provided content html.append(f'

{escape(tree_name)}

') html.append(f'

Ticket: {escape(session.ticket_number or "")}

') html.append(f'

Client: {escape(session.client_name or "")}

') # ... escape all interpolated values ``` **Tests to add:** - Export session with `