Review main Abandoned

30577[FEATURE] Add "DOMAIN_RECORD" to trusted HTTP_HOST configuration

Christian Zenker CR 0 V 0 Hard +253 −0 updated 08/26/15, 14:20

Commit message

$TYPO3_CONF_VARS['SYS']['trustedHostsPattern'] is getting
hard to maintain in bigger multi-domain projects.

This patch adds an option "DOMAIN_RECORD" as a possible
value for trustedHostsPattern. A host is trusted
if (and only if) it is found as a non-deactivated
sys_domain record in the TYPO3 installation.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 4

Review log 26

Show 1 earlier messages
  1. Christian Zenker uploaded patch set 2 06/05/14, 09:03

  1. Helmut Hummel commented on patch set 2 CR -1 06/05/14, 11:06

    Hi Christian, thanks for this initiative, however there are more things to consider in this area. I know this because I invested a few days to get this right before completely giving up on it. 1. Domain records can contain a path: domain.tld/path/ 2. How to handle the case with an installation with invalid domain records only (which is not a problem with only one tree, but would break when setting to DOMAIN_RECORDS) 3. How to handle deactivating/deleting/modification of a domain record with this setting active which is the only one valid for backend editing 4. How to handle not valid ports in regard of domain records (port handing in general should be discussed, maybe we are currently adding strictness which is not needed) 5. How handle setting this value without(valid) domain records first. Like that, it would immediately break the site (backend and frontend) I tried to handle all these cases in code, which introduced a high complexity. We could decide to handle some of these cases only in documentation, but they have to be considered somehow. Decisions on these cases need to be reflected in unit tests, to be sure the functionality does what we intend it to do. I would highly appreciate any help in this area to make this security change less painful to use and I will support any initiative in doing so. So let's get this right together!
  2. Helmut Hummel commented on patch set 2 06/05/14, 11:07

    Adding the comments again for better readability: 1. Domain records can contain a path: domain.tld/path/ 2. How to handle the case with an installation with invalid domain records only (which is not a problem with only one tree, but would break when setting to DOMAIN_RECORDS) 3. How to handle deactivating/deleting/modification of a domain record with this setting active which is the only one valid for backend editing 4. How to handle not valid ports in regard of domain records (port handing in general should be discussed, maybe we are currently adding strictness which is not needed) 5. How handle setting this value without(valid) domain records first. Like that, it would immediately break the site (backend and frontend)
  3. Helmut Hummel commented on patch set 2 06/05/14, 11:15

    I pushed my previous work in progress to sandbox/helhum/tusted-hosts-domain-records for reference
  4. Christian Zenker commented on patch set 2 06/05/14, 12:54

    Hi Helmut. I expected this to be less straight-forward then it first looked. 1. Domain records can contain a path: domain.tld/path/ Yeah, that should be fixed. I was not aware of this. 2. How to handle the case with an installation with invalid domain records only (which is not a problem with only one tree, but would break when setting to DOMAIN_RECORDS) If there are no valid domain records that feature should not be enabled. 3. How to handle deactivating/deleting/modification of a domain record with this setting active which is the only one valid for backend editing Hm, that's tricky. I personally could live with that risk. Usually only administrators should be able to edit domain records. If they give rights to normal editors, they should create a seperate backend domain that only administrators can edit to prevent blocking the backend by normal editors. If an administrator breaks the domain record... well... their bad. :) They can use the install tool to regain access. But this needs to be documented! 4. How to handle not valid ports in regard of domain records (port handing in general should be discussed, maybe we are currently adding strictness which is not needed) Is there any use in a non-numeric port? Or would there be any security concerns by just accepting any numeric port number? An attacker would need to open a port on the server to exploit the port number, but I guess the tainted HTTP_HOST would be the least of your problems then...!? 5. How handle setting this value without(valid) domain records first. Like that, it would immediately break the site (backend and frontend) This setting should not be active by default, but opt-in by an administrator.
  5. Helmut Hummel commented on patch set 2 06/05/14, 15:45

    Hi Christian, thanks for your feedback! Regarding 2., 3. and 5. I agree that this can handled in documentation as this addition is not the default (I had the latter in mind when working on it) Regarding 4. (ports) This is not about not numeric ports, but about the fact that the port I connect to does not need to match the port I submit in the HTTP_HOST header (which can contain a port). Imagine a scenario where a service is running on host.tld:80 and another service on host.tld:88 and these services do not trust each other. There is an attack vector when I connect to port 80 but send host.tld:88 has host header. Most of the issues we see with SERVER_NAME as value are related to the strict port check I introduced there (to cover the above scenario). So the questions are: How handle this scenario with DOMAIN_RECORDS as as new value and do we need to handle this scenario in general? Or: Should we introduce an option (disabled by default) which enables a port check when host check passes. Bonus Question: If we loosen (or remove) the port check from SERVER_NAME, is there still a need for DOMAIN_RECORDS check? We could define that SERVER_NAME does NOT check ports and if someone has a scenario as described above (probably not that many) they need to use a strict pattern that denies requests with wrong ports.
  6. Christian Zenker uploaded patch set 3 06/06/14, 13:02

  7. Christian Zenker commented on patch set 3 06/06/14, 13:05

    new upload that adds support for paths in the domain detection see inline comments.

    GeneralUtility.php:3609

    Mostly a copy of TYPO3\CMS\Frontend\Page\PageRepository::getDomainStartPage() I do not really like the duplicate code, but having a dependency on the Repository (that is setup by the TypoScriptFrontendController) would by much worse IMHO.
  8. Christian Zenker commented on patch set 3 V -1 06/06/14, 14:17

    -1: still needs some kind of port handling At the moment you could still use some host like "example.com:@evil.com" at least in my setting (nginx + apache) About the ports: I also thought about that, but could not come up with a real-world example where such a setup might exist for good reason.
  9. Christian Zenker uploaded patch set 4 06/06/14, 14:35

  10. Helmut Hummel commented on patch set 4 CR -1 06/11/14, 08:02

    besides the comment in the code, this still needs unit tests and a (general) decision how to deal with not matching ports.

    GeneralUtility.php:3610

    just exploding is not an option. ipv6 addresses contain several colons and as you point out credentials also. parse_url handles both things porperly (see above code)
  11. Christian Zenker commented on patch set 4 06/11/14, 12:42

    > this still needs [...] a (general) decision how to deal with not matching ports. *Who* will do that?

    GeneralUtility.php:3610 Reply

    Then this will also need to be changed in PageRepository::getDomainStartPage() too where I took most of the code from.
  12. Christian Zenker uploaded patch set 5 06/11/14, 16:24

  13. Christian Zenker commented on patch set 5 V -1 CR -1 06/11/14, 16:26

    added functional tests for the feature. Still, port handling needs to be cleared up.
  14. Christian Zenker voted on patch set 5 V 0 06/11/14, 16:26

  15. Mr. Jenkins commented on patch set 5 CR -1 V -1 06/11/14, 16:38

  16. Christian Zenker uploaded patch set 6 06/12/14, 06:57

  17. Mr. Jenkins commented on patch set 6 06/12/14, 07:10

  18. Benni Mack commented on patch set 6 CR -1 01/08/15, 20:10

    -1 I don't really like the solution of having another getDomainStartPage method lying around.
  19. Mathias Brodala commented on patch set 6 CR -1 01/09/15, 08:11

    Inline comments in addition to what Benjamin said.

    GeneralUtility.php:3622

    There's been exec_SELECTgetRows since ages, you know? ;-)

    GeneralUtility.php:3627

    Please "use" this.
  20. Christian Kuhn commented on patch set 6 01/09/15, 09:58

    Another thing to think about: This introduces a dependency to a working DB connection, so the host check can no longer be done at an early state in bootstrap. I think it is a general question if we really want the low level host check to be DB dependent. I tend to say "no, better not", but I'm not sure.
  21. Anja Leichsenring commented on patch set 6 04/04/15, 20:57

    I tend to propose the usage of ext:hosts_pattern and leave the core with the very basic stuff.
  22. Anja Leichsenring updated the commit message in patch set 7 04/04/15, 20:58

  23. Nicole Hummel commented on patch set 7 V -1 04/05/15, 22:20

  24. Anja Leichsenring commented on patch set 7 07/17/15, 12:03

    what now? I feel an ambilvalent 'rather no' for this patch. Someone in defense of it? Otherwise please someone man up and abandon it.
  25. Anja Leichsenring abandoned the change 08/26/15, 14:20

    abandoned for no activity and rather 'please no' from strategy team.