CVE-2022-41935 (published 2022-11-23T20:15Z)

XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. Users without the right to view documents can deduce their existence by repeated Livetable queries. The issue has been patched in XWiki 14.6RC1, 13.10.8, and 14.4.3, the response is not properly cleaned up of obfuscated entries. As a workaround, The patch for the document `XWiki.LiveTableResultsMacros` can be manually applied or a XAR archive of a patched version can be imported, on versions 12.10.11, 13.9-rc-1, and 13.4.4. There are no known workarounds for this issue.

CVSS v3 base score: 4.3, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:N)

Weakness information:
cwe_id: NVD-CWE-Other
cwe_name: Other
description: NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/xwiki/xwiki-platform
commit_details: repo_url: https://github.com/xwiki/xwiki-platform
author: Manuel Leduc
author_date: 2022-07-12 12:04:02+02:00
msg: XWIKI-19999: Livetable sources filtering improvement
repository: repo_url: https://github.com/xwiki/xwiki-platform
repo_name: xwiki/xwiki-platform
description: The XWiki platform
repo_language: Java
owner: xwiki
file_changes: filename: LiveTableResultsMacros.xml
change_type: ModificationType.MODIFY
diff: @@ -336,7 +336,12 @@
   #set ($query = $query.setLimit($limit).setOffset($offset).bindValues($sqlParams))
   #set($items = $query.execute())
   #set($discard = $map.put('totalrows', $query.count()))
-  #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit)))
+  #if ($limit > 0)
+    #set($discard = $map.put('returnedrows', $mathtool.min($items.size(), $limit)))
+  #else
+    ## When the limit is 0, it's equivalent to no limit at all and the actual number of returned results can be used.
+    #set($discard = $map.put('returnedrows', $items.size()))
+  #end
   #set($discard = $map.put('offset', $mathtool.add($offset, 1)))
   #set($rows = [])
   #foreach($item in $items)

programming_language: PowerShell
filename: LiveTableResultsTest.java
change_type: ModificationType.MODIFY
diff: @@ -47,6 +47,7 @@
 import com.xpn.xwiki.objects.classes.StaticListClass;
 import com.xpn.xwiki.plugin.tag.TagPluginApi;
 
+import static java.util.Collections.emptyList;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -470,6 +471,35 @@ void removeObfuscatedResultsWhenTotalrowsLowerThanLimit() throws Exception
         assertEquals("XWiki.Viewable", viewable.get("doc_fullName"));
     }
 
+    @Test
+    void removeObfuscatedResultsWhenLimitIs0() throws Exception
+    {
+        when(this.queryService.hql(anyString())).thenReturn(this.query);
+        when(this.query.setLimit(anyInt())).thenReturn(this.query);
+        when(this.query.setOffset(anyInt())).thenReturn(this.query);
+        when(this.query.bindValues(any(Map.class))).thenReturn(this.query);
+        when(this.query.count()).thenReturn(1L);
+        when(this.query.execute()).thenReturn(Arrays.asList("XWiki.NotViewable"));
+
+        when(this.oldcore.getMockContextualAuthorizationManager()
+            .hasAccess(same(Right.VIEW), eq(new DocumentReference("xwiki", "XWiki", "NotViewable")))).thenReturn(false);
+
+        this.request.put("limit", "0");
+        this.request.put("classname", "");
+        this.request.put("collist", "doc.title,doc.location,doc.content");
+        this.request.put("doc.title", "Sandbo");
+        this.request.put("doc.location", "Sandbox.TestPage3");
+        this.request.put("doc.content", "dummy");
+        this.request.put("limit", "0");
+
+        renderPage();
+
+        assertEquals(0, getTotalRowCount());
+        assertEquals(0, getRowCount());
+        assertEquals(1, getOffset());
+        assertEquals(emptyList(), getRows());
+    }
+
     //
     // Helper methods
     //

programming_language: Java