Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when specifying trusted_hosts #1006

Closed
teohhanhui opened this issue Mar 23, 2017 · 5 comments
Closed

Problem when specifying trusted_hosts #1006

teohhanhui opened this issue Mar 23, 2017 · 5 comments
Labels

Comments

@teohhanhui
Copy link
Contributor

  1. Untrusted Host "localhost" when fixing the Request for filters.
  2. Untrusted Host "schema.org", etc. (from external IRI) when calling IriConverter::getItemFromIri.
@teohhanhui teohhanhui added the bug label Mar 23, 2017
@dunglas
Copy link
Member

dunglas commented Mar 23, 2017

I'm not sure to understand what's going on. Do you have a more detailed example?

@teohhanhui
Copy link
Contributor Author

Try setting trusted_hosts in your app/config.yml. You should get the same problem.

@bwegrzyn
Copy link
Contributor

bwegrzyn commented Apr 5, 2018

Running in to this issue as well. It seems to be because I have trusted hosts specified that do not include "localhost". When retrieving an item by IRI (/countries/0368c044-1bc9-4976-8f8e-299b09d11626), ApiPlatform\Core\Bridge\Symfony\Routing\Router creates a new RequestContext that does not copy over the host, which results in Request->getHost() throwing SuspiciousOperationException because a blank/localhost host is not part of the trusted hosts.

@dunglas Can we get this fixed? It makes it impossible to use the this library while specifying trusted hosts in Symfony. IMO, this should be classified as a security issue as the only way to get this working is to not specify any trusted hosts or add localhost to the list.

https://symfony.com/doc/current/reference/configuration/framework.html#trusted-hosts
https://symfony.com/blog/security-releases-symfony-2-0-24-2-1-12-2-2-5-and-2-3-3-released#cve-2013-4752-request-gethost-poisoning

@bwegrzyn
Copy link
Contributor

bwegrzyn commented Apr 5, 2018

There was this pull request #1620 which sets the hosts based on the previous request context, but it happens too late. Symfony validates the Host against trusted hosts when you call (new RequestContext())->fromRequest($request) a few lines above.

@Simperfit
Copy link
Contributor

@bwegrzyn Do you want to try to provide a pull request to fix this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants