The vulnerability allowed remote code execution because XWiki improperly handled the execution context for default values of wiki macro parameters that accept wiki syntax. The core issue was that these default values were parsed and executed with the permissions of the author of the document where the macro was used, rather than the more restricted permissions of the macro's author.
The org.xwiki.rendering.wikimacro.internal.DefaultWikiMacroRenderer.parseParameterValue function was primarily responsible. Before the patch, it would take the default value of a wiki-type parameter and pass it to the parseWiki function without differentiating it from user-supplied values in terms of execution context.
The org.xwiki.rendering.wikimacro.internal.DefaultWikiMacroRenderer.parseWiki function (in its pre-patch form) would then invoke this.contentParser.parse using this.syncContext. This syncContext reflected the rights of the current page's author. Consequently, any script (Groovy, Python, Velocity) embedded in the default parameter value would execute with these rights. If an attacker could define a macro (or override an existing one like children) with a malicious script in a default parameter, and that macro was used on a page with programming rights (e.g., XWiki.ChildrenMacro), the script would execute with those elevated programming rights, leading to full access to the XWiki installation.
The patch rectifies this by modifying parseParameterValue to explicitly check if the content being parsed is the parameter's default value. If it is, parseWiki is now called with additional parameters (this.wikimacro.getSourceSyntax() and transform = true) that ensure the default value is parsed and executed within the context and with the rights of the macro's author. The parseWiki function signature was updated to accept these new parameters. Additionally, a new WikiMacroParameterObjectRequiredRightAnalyzer was introduced to enhance security by analyzing the required rights for wiki macro parameter objects, specifically checking their default values if they are of wiki type.