Harden production configuration: security headers, secrets, CSRF (#526)#543
Open
maltehuebner wants to merge 1 commit into
Open
Harden production configuration: security headers, secrets, CSRF (#526)#543maltehuebner wants to merge 1 commit into
maltehuebner wants to merge 1 commit into
Conversation
Addresses several configuration hardening gaps: - Add SecurityHeadersSubscriber (kernel.response) setting X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, Referrer-Policy and HSTS (on secure requests), plus a frame-ancestors Content-Security-Policy. A full script/style CSP is intentionally deferred (needs a frontend asset audit + runtime verification). - Enable framework csrf_protection (symfony/security-csrf is present). - Replace the committed APP_SECRET with a placeholder and flip the tracked APP_ENV default to prod; local dev overrides via .env.local. - Drop the ADMIN_PASSWORD=123 default from .env.test (unused anywhere). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the production-hardening gaps in #526.
Changes
SecurityHeadersSubscriberonkernel.responsesetsX-Content-Type-Options: nosniff,X-Frame-Options: SAMEORIGIN,Referrer-Policy: strict-origin-when-cross-origin,Strict-Transport-Security(only on secure requests), and aContent-Security-Policy: frame-ancestors 'self'. Headers are set withreplace=falseso per-controller overrides still win. Registered automatically viaautoconfigure.framework.csrf_protection(symfony/security-csrfis already installed). JSON API endpoints are unaffected (form-only feature).devtoprodso a deploy that forgets to set it does not silently boot in debug/profiler mode. Local development now overrides withAPP_ENV=devin the untracked.env.local.ADMIN_PASSWORD=123default (grep shows zero consumers inconfig/,src/,tests/).Deliberately not implemented
Content-Security-Policy(script-src, style-src, connect-src, img-src for Leaflet tiles, Algolia autocomplete, fonts, etc.) requires a complete inventory of external asset hosts plus runtime verification of the rendered frontend, which cannot be done safely without a running app (PostGIS/Redis). Only the safe, host-independentframe-ancestorsdirective is enforced here. A follow-up should build the enforced CSP behind report-only first. The issue's suggestion ofnelmio/security-bundlewas not added to avoid a new dependency for the small header set needed today.Verification
vendor/bin/phpunit --testsuite="Project Test Suite"— OK (121 tests, 131 assertions)vendor/bin/phpstan analyse --no-progress— No errorsCloses #526
🤖 Generated with Claude Code