VAITP Dataset

← Back to the dataset

CVE-2011-4642

Splunk 4.2.x mappy.py allows remote code execution by authenticated admins via CSRF (SPL-45172)

  • CVSS 4.6
  • CWE-352 Cross-Site Request Forgery (CSRF)
  • Input Validation and Sanitization
  • Remote

mappy.py in Splunk Web in Splunk 4.2.x before 4.2.5 does not properly restrict use of the mappy command to access Python classes, which allows remote authenticated administrators to execute arbitrary code by leveraging the sys module in a request to the search application, as demonstrated by a cross-site request forgery (CSRF) attack, aka SPL-45172.

CVSS base score
4.6
Published
2012-01-03
OWASP
A10 Server Side Request Forgery (SSRF)
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

Upgrade to Splunk version 4.2.5 or higher.

Vulnerable code sample

import splunk.admin as admin

class Mappy(admin.MConfigHandler):
    def setup(self):
        """Vulnerable function that demonstrates the security issue."""
        self.supportedArgs.addOptArg('command')
        self.supportedArgs.addOptArg('arg1')
        self.supportedArgs.addOptArg('arg2')

        def handleList(self, confInfo):
            """Vulnerable function that demonstrates the security issue."""
            command = self.getArg('command')
        
            result = eval(command)(self.getArg('arg1'), self.getArg('arg2'))
            confInfo['result'] = result

Patched code sample

import os
import subprocess

import splunk.admin as admin
import splunk.util as util

class Mappy(admin.MConfigHandler):
    def setup(self):
        """Secure function that fixes the vulnerability."""
        self.supportedArgs.addOptArg('command')
        self.supportedArgs.addOptArg('arg1')
        self.supportedArgs.addOptArg('arg2')

        def handleList(self, confInfo):
            """Secure function that fixes the vulnerability."""
            allowed_commands = ['allowed_command1', 'allowed_command2']
            unsafe_commands = ['os.system', 'subprocess.Popen', 'eval', 'exec']

            command = self.getArg('command')

            if any(unsafe_cmd in command for unsafe_cmd in unsafe_commands):
                raise Exception("Unsafe command detected")

                if command not in allowed_commands:
                    raise Exception("Unauthorized command access")

                    result = self.execute_command(command, self.getArg('arg1'), self.getArg('arg2'))
                    confInfo['result'] = result

                    def execute_command(self, command, arg1, arg2):
                        """Secure function that fixes the vulnerability."""
                        safe_commands = {
                        'allowed_command1': f'print("Executing allowed_command1 with args: {arg1}, {arg2}")',
                        'allowed_command2': f'print("Executing allowed_command2 with args: {arg1}, {arg2}")',
                        }

                        if command not in safe_commands:
                            raise Exception("Unauthorized command execution attempt")

                            command_code = safe_commands[command]
                            exec(command_code)

Cite this entry

@misc{vaitp:cve20114642,
  title        = {{Splunk 4.2.x mappy.py allows remote code execution by authenticated admins via CSRF (SPL-45172)}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2012},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2011-4642},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2011-4642/}}
}
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 ::