Fix CVE-2025-50578: Host Header Injection & Open Redirect #1537
+46
−9
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 addresses CVE-2025-50578 as reported in #1451, which includes two security vulnerabilities:
X-Forwarded-Hostheader - allows attackers to make the application load assets (JS, CSS, images) from attacker-controlled domainsChanges
1. Configurable Trusted Proxies (
TrustProxies.php)The trusted proxy configuration is now configurable via the
TRUSTED_PROXIESenvironment variable.Backwards Compatibility: The default behavior is unchanged - private IP ranges (
192.168.0.0/16,172.16.0.0/12,10.0.0.0/8,127.0.0.1) are trusted by default, so existing setups behind reverse proxies will continue to work without changes.New Options:
TRUSTED_PROXIES=192.168.1.10orTRUSTED_PROXIES=192.168.1.10,192.168.1.11TRUSTED_PROXIES=trusts no proxiesTRUSTED_PROXIES=*trusts all proxies2. Open Redirect Fixes (
LoginController.php&RedirectIfAuthenticated.php)These fixes prevent attackers from redirecting users to external malicious domains via the HTTP
Refererheader:URL::previous()usage which trusted the untrustedRefererheaderback()redirect after authentication to use the safedashrouteredirect()->intended()to use a safe internal path (/)These changes are applied unconditionally and improve security for all users.
How to Secure Your Instance
For users who want enhanced security:
Add to your
.envfile:For users behind dynamic proxies (e.g., Docker networks):
The default behavior (trusting private IPs) or
TRUSTED_PROXIES=*should work, but be aware this is less restrictive.Testing
TRUSTED_PROXIEScan be set to restrict trusted proxiesReferences