Security: Prevent Host Header Injection attacks #1071
Merged
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.
Summary
This PR fixes a critical security vulnerability that allows Host Header Injection attacks, which can be exploited to hijack password reset tokens and compromise user accounts.
The Vulnerability
The current implementation in
config/bootstrap.php(lines 168-170) dynamically setsApp.fullBaseUrlfrom theHTTP_HOSTheader when not configured:Attack Scenario
Host: attacker.comhttp://attacker.com/users/reset_password/valid-token-123The Fix
1. Changed
config/app.php:App.fullBaseUrlto useAPP_FULL_BASE_URLenvironment variable (instead offalse)2. Enhanced
config/bootstrap.php:App.fullBaseUrlis not configured3. Updated
config/.env.example:APP_FULL_BASE_URLconfiguration with security documentationImpact
Development
✅ No breaking changes - HTTP_HOST fallback still works in debug mode
Production
This is intentional to force proper security configuration in production environments.
As this only applies to new apps, this is BC. current apps are most likely vulnerable in many cases, though.
Maybe debug kit or sth could warn here.
Configuration Options
Developers can configure this in multiple ways:
Option 1: Environment Variable (Recommended)
Option 2: config/app(_local).php
Testing
Manual testing performed:
References
Related Security Concern
The existing comment in
config/app.php(line 42) already mentions "if you are concerned about people manipulating the Host header" but didn't enforce it. This PR makes that concern actionable by requiring explicit configuration in production.