Skip to content

Commit 7f88255

Browse files
committed
XWIKI-19949: Livetable results allow reconstructing password hashes using 768 requests
1 parent d7ea663 commit 7f88255

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/src/main/resources/XWiki/LiveTableResultsMacros.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,15 @@
7373
##
7474
#set($tablelist = [])
7575
#foreach($colname in $collist)
76-
#livetable_addColumnToQuery($colname)
76+
## If a classname is defined and the class field corresponding to the column name,
77+
## we check the type of the field and skip it if it's Password.
78+
#if ($className != '' && $class.get($colname))
79+
#if ($class.get($colname).classType != 'Password')
80+
#livetable_addColumnToQuery($colname)
81+
#end
82+
#else
83+
#livetable_addColumnToQuery($colname)
84+
#end
7785
#end
7886
##
7987
## Tag filtering

xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/src/test/java/org/xwiki/livetable/LiveTableResultsTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.xwiki.livetable;
2121

2222
import java.util.Arrays;
23+
import java.util.Collections;
2324
import java.util.HashMap;
2425
import java.util.List;
2526
import java.util.Map;
@@ -44,6 +45,7 @@
4445

4546
import com.xpn.xwiki.XWikiContext;
4647
import com.xpn.xwiki.doc.XWikiDocument;
48+
import com.xpn.xwiki.objects.classes.BaseClass;
4749
import com.xpn.xwiki.objects.classes.StaticListClass;
4850
import com.xpn.xwiki.plugin.tag.TagPluginApi;
4951

@@ -500,6 +502,35 @@ void removeObfuscatedResultsWhenLimitIs0() throws Exception
500502
assertEquals(emptyList(), getRows());
501503
}
502504

505+
@Test
506+
void cleanupAccessToPasswordFields() throws Exception
507+
{
508+
// Initialize an XClass with a password field.
509+
DocumentReference documentReference = new DocumentReference("xwiki", "XWiki", "MyClass");
510+
XWikiDocument xwikiDocument = this.xwiki.getDocument(documentReference, this.context);
511+
BaseClass xClass = xwikiDocument.getXClass();
512+
xClass.addPasswordField("password", "Password", 30);
513+
this.xwiki.saveDocument(xwikiDocument, this.context);
514+
515+
when(this.queryService.hql(anyString())).thenReturn(this.query);
516+
when(this.query.setLimit(anyInt())).thenReturn(this.query);
517+
when(this.query.setOffset(anyInt())).thenReturn(this.query);
518+
when(this.query.bindValues(any(Map.class))).thenReturn(this.query);
519+
when(this.query.count()).thenReturn(0L);
520+
when(this.query.execute()).thenReturn(Collections.emptyList());
521+
522+
this.request.put("classname", "XWiki.MyClass");
523+
this.request.put("password", "abcd");
524+
this.request.put("collist", "password");
525+
526+
renderPage();
527+
528+
verify(this.queryService).hql(", BaseObject as obj "
529+
+ "where obj.name=doc.fullName "
530+
+ "and obj.className = :className "
531+
+ "and doc.fullName not in (:classTemplate1, :classTemplate2) ");
532+
}
533+
503534
//
504535
// Helper methods
505536
//

xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-ui/xwiki-platform-wiki-ui-mainwiki/src/main/resources/WikiManager/WikisLiveTableResultsMacros.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,15 @@
5757
##
5858
#set($tablelist = [])
5959
#foreach($colname in $collist)
60-
#livetable_addColumnToQuery($colname)
60+
## If a classname is defined and the class field corresponding to the column name,
61+
## we check the type of the field and skip it if it's Password.
62+
#if ($className != '' && $class.get($colname))
63+
#if ($class.get($colname).classType != 'Password')
64+
#livetable_addColumnToQuery($colname)
65+
#end
66+
#else
67+
#livetable_addColumnToQuery($colname)
68+
#end
6169
#end
6270
##
6371
## Tag filtering

0 commit comments

Comments
 (0)