VAITP Dataset

← Back to the dataset

CVE-2005-2483

Karrigell < 2.1.8 has remote code execution via eval injection in manipulated script arguments

  • CVSS 7.5
  • CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code (Eval Injection)
  • Configuration Issues
  • Remote

Eval injection vulnerability in Karrigell before 2.1.8 allows remote attackers to execute arbitrary Python code via modified arguments to a Karrigell services (.ks) script, which can reference functions from libraries that are used by that script.

CVSS base score
7.5
Published
2005-08-07
OWASP
A03 Injection
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Configuration Issues
Subcategory
Remote File Inclusion (RFI)
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Karrigell
Fixed by upgrading
Yes

Solution

Update Karrigell to version 2.1.8 or higher.

Vulnerable code sample

def execute_script(script_code):
    # Vulnerable code that uses eval directly
    exec(script_code)

# Example usage
user_input = "__import__('os').system('ls')"  # Malicious input
execute_script(user_input)  # This would execute the command on the server

Patched code sample

import ast
import sys

def safe_eval(expr):
    # Restrict the eval to only allow certain safe expressions
    allowed_nodes = {
        ast.Expression,
        ast.Num,
        ast.Str,
        ast.List,
        ast.Tuple,
        ast.Name,
        ast.BinOp,
        ast.UnaryOp,
        ast.Load,
        ast.Store,
        ast.Call,
        ast.Attribute,
    }
    
    class SafeVisitor(ast.NodeVisitor):
        def visit(self, node):
            if type(node) not in allowed_nodes:
                raise ValueError("Unsafe operation detected.")
            return super().visit(node)

    tree = ast.parse(expr, mode='eval')
    SafeVisitor().visit(tree)
    
    # Evaluate the expression in a restricted environment
    return eval(compile(tree, filename="<ast>", mode="eval"), {"__builtins__": None}, {})

# Example usage
try:
    result = safe_eval("1 + 2")  # Safe expression
    print(result)
    
    # This would raise an error
    # result = safe_eval("__import__('os').system('ls')")  # Unsafe expression
except ValueError as e:
    print(e)

Cite this entry

@misc{vaitp:cve20052483,
  title        = {{Karrigell < 2.1.8 has remote code execution via eval injection in manipulated script arguments}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2005},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2005-2483},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2005-2483/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.