Skip to content

fix(security): admin UI refuses to compile without form CSRF protection - #28

Merged
HecFranco merged 1 commit into
mainfrom
sec-csrf-fail-closed
Oct 28, 2026
Merged

HecFranco merged 1 commit into
mainfrom
sec-csrf-fail-closed

Conversation

@HecFranco

Copy link
Copy Markdown
Contributor

Problem (cross-bundle pattern P2)

Admin purge / delete / export (HttpLogAdminController::validateActionForm() on AbstractHttpLogActionType, which declares its own CSRF options) rely solely on Symfony's form CSRF extension. Without it (framework.csrf_protection: false / framework.form.csrf_protection: false) those forms validate without a token → cross-site POSTs could purge or delete logs.

Fix

  • src/DependencyInjection/Compiler/CsrfProtectionPass.php (modelled on UptimeMonitorBundle): when web_ui.enabled is true the container refuses to compile without security.csrf.token_manager + form.type_extension.csrf, or with form.type_extension.csrf.enabled = false. Registered in NowoHttpLogBundle::build().
  • symfony/security-csrf already in require.
  • Docs: SECURITY.md threat model, CHANGELOG [Unreleased] ### Security, UPGRADING.

Evidence

  • tests/Unit/DependencyInjection/Compiler/CsrfProtectionPassTest.php (3 fail-closed configs, pass, skips) + integration test asserts registration; both fail on old code.
  • Gates (throwaway container): composer validate --strict, cs-check, rector-dry, phpstan (no errors), igor (41 stateless), coverage 100% lines (1689/1689).

Host impact

Admin UI disabled or standard Flex CSRF config: none. Admin UI + disabled form CSRF now fails at compile (intended). Suggested release: minor.

🤖 Generated with Claude Code

Purge, delete and export (AbstractHttpLogActionType declares its own CSRF
options) rely on Symfony's form CSRF extension. Without
security.csrf.token_manager / form.type_extension.csrf, or with
framework.form.csrf_protection: false, they accepted tokenless cross-site
POSTs. CsrfProtectionPass now fails the container compile when
web_ui.enabled is true.
@github-actions

Copy link
Copy Markdown

@coderabbitai review

@HecFranco
HecFranco merged commit 044deff into main Oct 28, 2026
16 checks passed
@HecFranco
HecFranco deleted the sec-csrf-fail-closed branch October 28, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant