Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-24875

Trusted domains aren't updated after wiki descriptor change

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 18.8.0-rc-1, 18.4.6, 17.10.14
    • 13.3-rc-1, 12.10.7
    • URLs
    • None
    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      Tested on an instance reachable under two host names that both point to the same XWiki, e.g. http://localhost:8080 and http://127.0.0.1:8080. In a real farm these would be two real domains. The descriptor domain of the main wiki is localhost; the alias field only stores the host, the port is irrelevant.

      1. Log in as a user with admin rights on http://localhost:8080/xwiki.
      2. Open http://localhost:8080/xwiki/bin/redirect/Main/WebHome?xredirect=http://127.0.0.1:8080/xwiki/bin/view/Main/
        • Correct baseline behaviour: no redirect happens (blank page, HTTP 200 instead of HTTP 302), and xwiki.log contains:
          WARN SafeRedirectFilter$SafeRedirectResponse - Possible phishing attack, attempting to redirect
          to [http://127.0.0.1:8080/xwiki/bin/view/Main/], this request has been blocked.
          
      3. Go to http://localhost:8080/xwiki/bin/view/XWiki/XWikiServerXwiki (for a subwiki: Wiki Index > the wiki > its descriptor page). Under Create new alias, enter 127.0.0.1 and click Create.
        • The alias is saved and listed under View aliases, and the wiki is immediately reachable through it.
      4. Repeat step 2.
      5. Restart XWiki and repeat step 2 again.

      Expected result

      After step 4, step 5 returns HTTP 302 to http://127.0.0.1:8080/xwiki/bin/view/Main/ and no warning is logged: the alias is part of the wiki descriptor, so its domain is trusted.

      Actual result

      Step 5 behaves exactly like step 2: the redirect is blocked and the same Possible phishing attack warning is logged. Only after the restart in step 6 does the redirect work.

      The list of trusted domains is computed once from url.trustedDomains plus the aliases of all wiki descriptors and then cached. XWikiServerClassListener is supposed to invalidate that cache on every change of an XWiki.XWikiServerClass object, but it declares its events with a LocalDocumentReference of the xclass instead of BaseObjectReference.any("XWiki.XWikiServerClass"), so it never matches the events that are actually sent and never fires. Any change of a wiki's domain or aliases therefore takes effect only after a restart. The reverse direction is affected too: a deleted alias stays trusted until restart.

      Workaround

      Restart XWiki after every descriptor or alias change. Adding the domain to url.trustedDomains in xwiki.properties needs a restart as well, since that configuration ends up in the same cached set.

      Attachments

        Activity

          People

            MichaelHamann Michael Hamann
            MichaelHamann Michael Hamann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: