From 8338d0af1ef4aa5b23092e209108ff9889275361 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Mon, 11 May 2026 19:34:18 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20remaining=20bugs.md=20findings=20?= =?UTF-8?q?=E2=80=94=20Repo=20calls,=20process=20dict,=20CSS,=20rate=20lim?= =?UTF-8?q?its,=20Oban,=20debug=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Extract Repo calls from LiveViews into Agents.get_agent_token_for_org/2 and Accounts.verify_new_totp_device/2 context functions - Remove Process dictionary usage for cookie consent; use explicit assigns - Reject url() references in status page custom CSS changeset - Add per-organization rate limit check alongside per-IP - Document Oban flush as emergency-only with audit logging - Gate /admin/headers behind dev_routes (debug endpoint) --- bugs.md | 50 ------------------- lib/towerops/accounts.ex | 1 + lib/towerops/accounts/totp.ex | 13 +++++ lib/towerops/agents.ex | 10 ++++ .../status_pages/status_page_config.ex | 18 +++++++ lib/towerops_web/components/layouts.ex | 12 ++--- .../components/marketing_layouts.ex | 4 +- .../controllers/admin_controller.ex | 13 ++++- lib/towerops_web/live/agent_live/edit.ex | 5 +- .../live/user_settings_live/totp_manager.ex | 27 +++++----- lib/towerops_web/plugs/detect_eu_user.ex | 3 -- lib/towerops_web/plugs/rate_limit.ex | 39 +++++++++++---- lib/towerops_web/router.ex | 8 ++- lib/towerops_web/user_auth.ex | 3 -- .../controllers/debug_controller_test.exs | 32 +----------- 15 files changed, 110 insertions(+), 128 deletions(-) diff --git a/bugs.md b/bugs.md index 719c5893..f8471f93 100644 --- a/bugs.md +++ b/bugs.md @@ -36,20 +36,6 @@ Validation run: - Problem: CSP is set in both the browser pipeline and endpoint-level security plug, with different directives. The effective behavior depends on header overwrite order. The policy also requires `'unsafe-inline'` because templates include inline scripts, reducing CSP's value against XSS. - Fix: centralize CSP construction in one plug. Move inline scripts into `assets/js/app.js` or LiveView hooks and remove `'unsafe-inline'` where possible. Consider nonces only for unavoidable inline bootstrapping. -### 9. Custom CSS is rendered from database into a raw style tag - -- Category: OWASP A03 Injection / CSS injection -- Evidence: `lib/towerops_web/live/status_page_live.html.heex:26` -- Problem: `@config.custom_css` is rendered inside `