CVE-2023-29522
XWiki Platform: Remote code execution via script macros
- CVSS 8.8
- CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
- 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 can execute arbitrary script macros including Groovy and Python macros that allow remote code execution including unrestricted read and write access to all wiki contents. The attack works by opening a non-existing page with a name crafted to contain a dangerous payload. This issue has been patched in XWiki 14.4.8, 14.10.3 and 15.0RC1. Users are advised to upgrade. There are no known workarounds for this vulnerability.
- CVSS base score
- 8.8
- Published
- 2023-04-19
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Fixed by upgrading
- Yes
Solution
Update XWiki Platform to version 14.4.8, 14.10.3, or 15.0RC1.
Vulnerable code sample
def execute_macro(user_input):
"""Vulnerable function that demonstrates the security issue."""
exec(user_input)
user_input = "import os; os.system('whoami')"
execute_macro(user_input)Patched code sample
def sanitize_input(user_input):
"""Secure function that fixes the vulnerability."""
forbidden_patterns = ['$', '{', '}', '(', ')', 'import', 'exec', 'eval']
for pattern in forbidden_patterns:
if pattern in user_input:
raise ValueError("Invalid input detected!")
return user_input
def execute_macro(user_input):
"""Secure function that fixes the vulnerability."""
sanitized_input = sanitize_input(user_input)
safe_globals = {
"__builtins__": {
"print": print,
"len": len
}
}
exec(sanitized_input, safe_globals)
try:
user_input = "import os; os.system('whoami')"
execute_macro(user_input)
except ValueError as e:
print(e)Cite this entry
@misc{vaitp:cve202329522,
title = {{XWiki Platform: Remote code execution via script macros}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2023-29522},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-29522/}}
}
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 ::
