VAITP Dataset

← Back to the dataset

CVE-2022-41934

XWiki Platform Macro Execution Vulnerability

  • CVSS 8.8
  • CWE-116
  • Input Validation and Sanitization
  • Remote

XWiki Platform is a generic wiki platform offering runtime services for applications built on top of it. Any user with view rights on commonly accessible documents including the menu macro can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki installation due to improper escaping of the macro content and parameters of the menu macro. The problem has been patched in XWiki 14.6RC1, 13.10.8 and 14.4.3. The patch (commit `2fc20891`) for the document `Menu.MenuMacro` can be manually applied or a XAR archive of a patched version can be imported. The menu macro was basically unchanged since XWiki 11.6 so on XWiki 11.6 or later the patch for version of 13.10.8 (commit `59ccca24a`) can most likely be applied, on XWiki version 14.0 and later the versions in XWiki 14.6 and 14.4.3 should be appropriate.

CVSS base score
8.8
Published
2022-11-23
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Insecure Direct Object References (IDOR)
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Fixed by upgrading
Yes

Solution

Upgrade XWiki version 14.6RC1, 13.10.8, or 14.4.3.

Vulnerable code sample

def execute_macro(macro_content, context):
    """Vulnerable function that demonstrates the security issue."""
    return eval(macro_content)

user_input = "__import__('os').system('ls')"
context = {}
result = execute_macro(user_input, context)
print(result)

Patched code sample

import ast

def execute_macro(macro_content, context):
    """Secure function that fixes the vulnerability."""
    escaped_content = escape_macro_content(macro_content)
    return execute_in_context(escaped_content, context)

def escape_macro_content(content):
    """Secure function that fixes the vulnerability."""
    return content.replace("{", "{{").replace("}", "}}")

def execute_in_context(content, context):
    """Secure function that fixes the vulnerability."""
    try:
        evaluated_content = ast.literal_eval(content)
        return f"Executed: {evaluated_content}"
    except ValueError as e:
        return f"Error in evaluation: {e}"

user_input = "__import__('os').system('ls')"
context = {}
result = execute_macro(user_input, context)
print(result)

Cite this entry

@misc{vaitp:cve202241934,
  title        = {{XWiki Platform Macro Execution Vulnerability}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2022},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2022-41934},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-41934/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::