CVE-2023-30537
XWiki Platform allows code execution via unescaped styles in FlamingoThemesCode.WebHome
- CVSS 8.8
- CWE-94 Improper Control of Generation of Code ('Code 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 the right to add an object on a page can execute arbitrary Groovy, Python or Velocity code in XWiki leading to full access to the XWiki installation. The root cause is improper escaping of the styles properties `FlamingoThemesCode.WebHome`. This page is installed by default. The vulnerability has been patched in XWiki versions 13.10.11, 14.4.7 and 14.10.
- CVSS base score
- 8.8
- Published
- 2023-04-16
- OWASP
- A03 Injection
- 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 to XWiki versions 13.10.11, 14.4.7, or 14.10.
Vulnerable code sample
def execute_user_input(style_properties):
"""Vulnerable function that demonstrates the security issue."""
user_input = f"style={{ {style_properties} }}"
eval(user_input)Patched code sample
import ast
def escape_style_properties(style_properties):
"""Secure function that fixes the vulnerability."""
escaped_properties = {}
for key, value in style_properties.items():
modified_key = key.replace(";", "").replace("}", "").replace("{", "")
modified_value = value.replace(";", "").replace("}", "").replace("{", "")
escaped_properties[modified_key] = modified_value
return escaped_properties
def execute_user_input(style_properties):
"""Secure function that fixes the vulnerability."""
escaped = escape_style_properties(style_properties)
style_string = f"{{ {', '.join([f'{key}: {value}' for key, value in escaped.items()])} }}"
try:
ast.literal_eval(style_string)
except (ValueError, SyntaxError) as e:
print(f"Error evaluating the style string: {e}")
return NoneCite this entry
@misc{vaitp:cve202330537,
title = {{XWiki Platform allows code execution via unescaped styles in FlamingoThemesCode.WebHome}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2023},
note = {VAITP Python Vulnerability Dataset, entry CVE-2023-30537},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-30537/}}
}
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 ::
