CVE-2024-31464: Insufficient Information (NVD-CWE-noinfo)
value: XWiki Platform is a generic wiki platform. Starting in version 5.0-rc-1 and prior to versions 14.10.19, 15.5.4, and 15.9-rc-1, it is possible to access the hash of a password by using the diff feature of the history whenever the object storing the password is deleted. Using that vulnerability it's possible for an attacker to have access to the hash password of a user if they have rights to edit the users' page.  With the default right scheme in XWiki this vulnerability is normally prevented on user profiles, except by users with Admin rights. Note that this vulnerability also impacts any extensions that might use passwords stored in xobjects: for those usecases it depends on the right of those pages. There is currently no way to be 100% sure that this vulnerability has been exploited, as an attacker with enough privilege could have deleted the revision where the xobject was deleted after rolling-back the deletion. But again, this operation requires high privileges on the target page (Admin right). A page with a user password xobject which have in its history a revision where the object has been deleted should be considered at risk and the password should be changed there. a diff, to ensure it's not coming from a password field. As another mitigation, admins should ensure that the user pages are properly protected: the edit right shouldn't be allowed for other users than Admin and owner of the profile (which is the default right). There is not much workaround possible for a privileged user other than upgrading XWiki.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
Published: 2024-04-10T19:15Z
Repository: https://github.com/xwiki/xwiki-platform
Language: Java
Files changed: xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java, xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/BaseObject.java
Commit date: 2023-10-16 10:50:00 +0200
Commit message: XWIKI-19948: Bad diff information when xobject is deleted (#2439)

  * Ensure to retrieve the xclass even when the xobject has been deleted
  * Ensure the BaseObject contains an XClass reference when creating it
    in XWikiDocument#getObjectDiff
Diff: diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
index 53ded9938d6a0..e26c1ddaf3b4e 100644
--- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
+++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
@@ -7129,11 +7129,14 @@ public List<List<ObjectDiff>> getObjectDiff(XWikiDocument fromDoc, XWikiDocument
                 if (originalObj != null) {
                     BaseObject newObj = toDoc.getXObject(originalObj.getXClassReference(), originalObj.getNumber());
                     List<ObjectDiff> dlist;
                     if (newObj == null) {
                         // The object was deleted.
-                        dlist = new BaseObject().getDiff(originalObj, context);
+                        newObj = new BaseObject();
+                        // We want the xclass reference to be set so that it can resolve the xclass properties.
+                        newObj.setXClassReference(originalObj.getXClassReference());
+                        dlist = newObj.getDiff(originalObj, context);
                         ObjectDiff deleteMarker =
                             new ObjectDiff(originalObj.getXClassReference(), originalObj.getNumber(),
                                 originalObj.getGuid(), ObjectDiff.ACTION_OBJECTREMOVED, "", "", "", "");
                         dlist.add(0, deleteMarker);
                     } else {
diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/BaseObject.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/BaseObject.java
index 3322b7a7cc578..6824fa4d11e68 100644
--- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/BaseObject.java
+++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/BaseObject.java
@@ -306,10 +306,16 @@ public List<ObjectDiff> getDiff(Object oldEntity, XWikiContext context)
         // Iterate over the old properties, in case there are some removed properties
         for (String propertyName : oldObject.getPropertyList()) {
             BaseProperty newProperty = (BaseProperty) this.getField(propertyName);
             BaseProperty oldProperty = (BaseProperty) oldObject.getField(propertyName);
             BaseClass bclass = getXClass(context);
+            // Bulletproofing: in theory the BaseObject is defined with a xclass reference allowing to resolve it
+            // however, it's possible that the reference is not set, in which case we might still find the info
+            // in the old object.
+            if (bclass == null) {
+                bclass = oldObject.getXClass(context);
+            }
             PropertyClass pclass = (PropertyClass) ((bclass == null) ? null : bclass.getField(propertyName));
             String propertyType = (pclass == null) ? "" : pclass.getClassType();
 
             if (newProperty == null) {
                 // The property exists in the old object, but not in the new one

Vulnerable code:                         dlist = new BaseObject().getDiff(originalObj, context);
Fixed code:                         newObj = new BaseObject();
                        // We want the xclass reference to be set so that it can resolve the xclass properties.
                        newObj.setXClassReference(originalObj.getXClassReference());
                        dlist = newObj.getDiff(originalObj, context);
            // Bulletproofing: in theory the BaseObject is defined with a xclass reference allowing to resolve it
            // however, it's possible that the reference is not set, in which case we might still find the info
            // in the old object.
            if (bclass == null) {
                bclass = oldObject.getXClass(context);
            }