Skip to content

Harden admin mutations and calendar color rendering#274

Open
AnnoyingTechnology wants to merge 2 commits into
tchapi:mainfrom
AnnoyingTechnology:harden-admin-actions
Open

Harden admin mutations and calendar color rendering#274
AnnoyingTechnology wants to merge 2 commits into
tchapi:mainfrom
AnnoyingTechnology:harden-admin-actions

Conversation

@AnnoyingTechnology

@AnnoyingTechnology AnnoyingTechnology commented Jul 19, 2026

Copy link
Copy Markdown

Why

Several browser-admin actions currently mutate state through unrestricted routes, with some invoked through GET requests. Because these custom actions sit outside Symfony Forms, they also bypass the built-in CSRF protection.

Calendar colors can also be written through DAV without Symfony validation and are rendered directly into inline CSS. SQLite does not enforce the declared VARCHAR length, so the database schema does not bound that value.

This PR establishes the standard boundary for the admin interface: reads use GET, form handlers use GET/POST, state-changing actions require POST with a valid CSRF token, and stored calendar colors are allowlisted before entering a CSS context.

The rendering check closes the CSS sink for existing data and every current write path. Validating colors when they are written remains a desirable follow-up so malformed values are rejected instead of being stored inertly.

What changed

  • constrain every browser-admin route to its intended HTTP methods
  • require POST and CSRF validation for deletion, sharing, revocation, and delegation changes
  • protect logout with POST and Symfony logout CSRF validation
  • replace query-string mutation links with ordinary POST forms
  • restrict mutation parameters to the POST body
  • render calendar and subscription colors only when they exactly match #RRGGBB or #RRGGBBAA
  • omit the inline style for invalid stored colors
  • cover both rejected requests and successful share, revoke, delegate, delete, logout, and color-rendering flows

DAV and API endpoints are unchanged; they retain their existing protocol-specific authentication, storage behavior, and HTTP methods.

Verification

  • PHPUnit: 64 tests, 466 assertions
  • explicit coverage for every custom admin mutation route
  • successful calendar sharing/revocation and delegate addition/removal
  • valid calendar colors render unchanged; CSS declarations do not reach the inline style
  • Twig, YAML, container, JavaScript, Composer, PHP style, syntax, and whitespace checks

Calendar colors written through DAV bypass Symfony validation, and SQLite does not enforce the declared VARCHAR length. Rendering those stored values directly in an inline style therefore permits CSS declaration injection in the admin interface.

Allow only exact #RRGGBB and #RRGGBBAA values at the rendering boundary and omit the style attribute otherwise. This also protects existing records and all current write paths.

A follow-up should validate calendar colors on each write path so malformed values are rejected instead of being stored inertly.
@AnnoyingTechnology AnnoyingTechnology changed the title Require POST and CSRF protection for admin mutations Harden admin mutations and calendar color rendering Jul 20, 2026
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