Skip to content

Conversation

@MatTheCat
Copy link
Contributor

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #61560
License MIT

Currently trusted headers are both copied from the original request and used to generate the URI. That means if we have a trusted /foo prefix the URI generated for /bar would be /foo/bar, and the new request URI would be /foo/foo/bar.

This PR temporarily distrusts proxies so that the generated URI would be /bar, and the new request URI /foo/bar.

@nicolas-grekas
Copy link
Member

Thank you @MatTheCat.

@nicolas-grekas nicolas-grekas merged commit c5ac440 into symfony:6.4 Sep 5, 2025
9 of 11 checks passed
@MatTheCat MatTheCat deleted the ticket_61560 branch September 5, 2025 12:58
This was referenced Sep 27, 2025
@kira0269
Copy link

Hi @MatTheCat ,

It seems that there is still an issue when we try to create a request from a route name, not a path:

// In your test, use path to create the request => OK
(new HttpUtils())->createRequest(Request::create('/', server: ['HTTP_X_FORWARDED_PREFIX' => '/foo']), '/')->getUri(),

// Using route name to create the request => KO
(new HttpUtils())->createRequest(Request::create('/', server: ['HTTP_X_FORWARDED_PREFIX' => '/foo']), 'my_route')->getUri(),

@MatTheCat
Copy link
Contributor Author

Hey @kira0269 your example doesn’t mention what the problem is and I’m not able to see any. You can open a new issue if you noticed something is wrong.

@MatTheCat
Copy link
Contributor Author

Okay was able to reproduce: the URL generator context should also be updated. Will open a PR; no need for an issue.

Thanks!

nicolas-grekas added a commit that referenced this pull request Nov 12, 2025
…xt’s base URL isn’t empty (MatTheCat)

This PR was merged into the 6.4 branch.

Discussion
----------

[Security] Fix `HttpUtils::createRequest()` when the context’s base URL isn’t empty

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #61659 (comment)
| License       | MIT

Commits
-------

3210543 [Security] Fix `HttpUtils::createRequest()` when the context’s base URL isn’t empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants