Python Core
Python Core rules for Python
Run All Python Core Rules
pathfinder scan --ruleset python/lang --project .Rules
Dangerous eval() Usage Detected
HIGHeval() executes arbitrary Python expressions from strings, enabling remote code execution when called with untrusted input.
Dangerous exec() Usage Detected
HIGHexec() executes arbitrary Python statements from strings or code objects, enabling remote code execution when called with untrusted input.
Dangerous code.InteractiveConsole Usage
HIGHcode.InteractiveConsole and code.interact() enable arbitrary Python code execution and should not be exposed to untrusted users.
Dangerous globals() Usage Detected
MEDIUMglobals() exposes the module's global namespace as a mutable dictionary, allowing arbitrary attribute injection when passed to untrusted code.
Non-literal Dynamic Import Detected
MEDIUM__import__() or importlib.import_module() with a non-literal argument can import arbitrary modules when called with untrusted input.
Dangerous typing.get_type_hints() Usage
MEDIUMtyping.get_type_hints() evaluates string annotations as Python expressions, enabling code execution when annotation strings contain untrusted content.
Dangerous os.system() or os.popen() Call
HIGHos.system() and os.popen() execute shell commands via /bin/sh, enabling command injection when arguments contain untrusted input.
Dangerous os.exec*() Call
HIGHos.exec*() replaces the current process image with a new program, enabling arbitrary program execution when arguments are untrusted.
Dangerous os.spawn*() Call
HIGHos.spawn*() spawns a new process and can execute arbitrary programs when the executable path or arguments are derived from untrusted input.
Shell Command with Wildcard Character
MEDIUMos.system() calls containing wildcard characters (*) may lead to unintended file inclusion or command injection through wildcard expansion.
Python Reverse Shell Pattern Detected
CRITICALReverse shell pattern detected using socket connections with subprocess or exec(). This is a strong indicator of malicious code or a backdoor.
Dangerous subprocess Usage
HIGHsubprocess calls detected. Ensure command arguments are not user-controlled to prevent OS command injection.
subprocess Called with shell=True
HIGHsubprocess called with shell=True passes the command through the system shell, enabling command injection when any part of the command contains untrusted input.
Dangerous asyncio Shell Execution
HIGHasyncio.create_subprocess_shell() passes the command through the system shell, enabling command injection when arguments contain untrusted input.
Dangerous subinterpreters run_string() Usage
HIGHsubinterpreters.run_string() executes arbitrary Python code strings in sub-interpreters, enabling code injection when called with untrusted input.
Insecure MD5 Hash Usage
MEDIUMMD5 is cryptographically broken and unsuitable for security-sensitive purposes. Use SHA-256 or SHA-3 instead.
Insecure SHA-1 Hash Usage
MEDIUMSHA-1 is cryptographically weak due to practical collision attacks. Use SHA-256 or SHA-3 for security-sensitive hashing.
Insecure Hash via hashlib.new()
MEDIUMhashlib.new() with an insecure algorithm name (MD5, SHA1, SHA-224) creates a cryptographically weak hash. Use SHA-256 or SHA-3.
SHA-224 or SHA3-224 Weak Hash Usage
LOWSHA-224 and SHA3-224 provide only 112-bit collision resistance, which is below the 128-bit minimum recommended by NIST for new applications.
MD5 Used for Password Hashing
HIGHMD5 is being used to hash passwords. MD5 is cryptographically broken and orders of magnitude too fast for password hashing. Use bcrypt, scrypt, or argon2.
Pickle Deserialization of Untrusted Data
HIGHpickle.loads() and pickle.load() execute arbitrary Python code during deserialization. Never unpickle data from untrusted sources.
PyYAML Unsafe Load Function
HIGHyaml.load() and yaml.unsafe_load() can execute arbitrary Python objects during YAML parsing. Use yaml.safe_load() instead.
jsonpickle Deserialization Detected
HIGHjsonpickle.decode() can execute arbitrary Python code during deserialization. Use the standard json module for untrusted data.
ruamel.yaml Unsafe Loader Configuration
HIGHruamel.yaml configured with typ='unsafe' can instantiate arbitrary Python objects during YAML parsing. Use typ='safe' or the default round-trip loader.
marshal Deserialization Detected
MEDIUMmarshal.loads() and marshal.load() are not secure against erroneous or malicious data and should not be used to deserialize untrusted input.
shelve Module Usage Detected
MEDIUMshelve.open() uses pickle internally for value serialization and is not safe for storing or retrieving data from untrusted sources.
dill Deserialization Detected
HIGHdill.loads() and dill.load() extend pickle with broader serialization capabilities and can execute arbitrary code when deserializing untrusted data.
Unverified SSL Context Created
HIGHssl._create_unverified_context() disables certificate verification entirely, making TLS connections vulnerable to man-in-the-middle attacks.
Weak SSL/TLS Protocol Version
HIGHSSLContext configured with SSLv2, SSLv3, TLSv1.0, or TLSv1.1 uses deprecated protocols with known vulnerabilities. Use TLS 1.2 or TLS 1.3.
Deprecated ssl.wrap_socket() Usage
MEDIUMssl.wrap_socket() is deprecated since Python 3.7 and should be replaced with SSLContext.wrap_socket() for proper TLS configuration.
Certificate Validation Disabled (verify=False)
HIGHTLS certificate validation is explicitly disabled via verify=False or CERT_NONE, making connections vulnerable to man-in-the-middle attacks.
Insecure HTTP Connection via http.client
MEDIUMhttp.client.HTTPConnection transmits data in plaintext without encryption. Use HTTPSConnection for sensitive communications.
HTTP Request Without TLS (requests library)
MEDIUMHTTP URLs in requests calls transmit data in plaintext without encryption. Use HTTPS URLs for sensitive data transmission.
Insecure urllib.request.urlopen() Usage
MEDIUMurllib.request.urlopen() over HTTP transmits data in plaintext. Verify HTTPS URLs are used and SSL context is properly configured.
Insecure urllib Request Object Usage
MEDIUMurllib.request.Request() and OpenerDirector used with HTTP URLs transmit data in plaintext. Verify HTTPS URLs are used.
FTP Without TLS (ftplib.FTP)
MEDIUMftplib.FTP() transmits data and credentials in plaintext. Use ftplib.FTP_TLS() or SFTP (via paramiko) for secure file transfer.
telnetlib Usage Detected
HIGHtelnetlib.Telnet() transmits all data including credentials in plaintext. Replace with SSH (paramiko) for remote command execution.
Socket Bound to All Interfaces (0.0.0.0)
MEDIUMBinding a socket to 0.0.0.0 exposes the service on all network interfaces, including public-facing ones. Bind to specific interfaces in production.
Paramiko Implicit Host Key Trust (AutoAddPolicy)
HIGHparamiko.AutoAddPolicy() and WarningPolicy() automatically accept unknown SSH host keys, enabling man-in-the-middle attacks on SSH connections.
Paramiko exec_command() Usage
MEDIUMparamiko exec_command() runs commands on a remote host. Audit that command arguments are not derived from untrusted input to prevent command injection.
multiprocessing Connection.recv() Usage
MEDIUMmultiprocessing.Connection.recv() uses pickle internally and is not safe for receiving data from untrusted connections.
psycopg2 SQL Injection via String Formatting
CRITICALSQL query built with string formatting passed to psycopg2 cursor.execute() enables SQL injection. Use parameterized queries with %s placeholders.
Formatted SQL Query Passed to cursor.execute()
HIGHSQL query built with string formatting detected. String-formatted SQL strings are a common SQL injection vector. Use parameterized queries.
Insecure XML Parsing (XXE Vulnerability)
MEDIUMxml.etree.ElementTree is vulnerable to XML External Entity (XXE) attacks. Use defusedxml for safe XML parsing.
Insecure xml.dom.minidom Usage (XXE)
MEDIUMxml.dom.minidom is vulnerable to XML External Entity (XXE) attacks. Use defusedxml.minidom for safe XML parsing.
Insecure xmlrpc Usage (XXE Risk)
MEDIUMxmlrpc.client.ServerProxy and xmlrpc.server modules are vulnerable to XXE attacks via malicious XML-RPC payloads. Use defusedxml.xmlrpc for protection.
Mako Template Usage Detected
MEDIUMMako templates execute Python expressions without sandboxing. Ensure templates are from trusted sources and user input is not rendered as template code.
csv.writer Audit (Formula Injection Risk)
LOWcsv.writer() detected. Audit CSV output for formula injection (CSV injection) if data is exported to spreadsheet applications.
UUID Version 1 Leaks MAC Address
LOWuuid.uuid1() embeds the host MAC address in the generated UUID, leaking hardware identity information.
Insecure File Permissions via os.chmod
MEDIUMos.chmod() or os.fchmod() sets overly permissive file permissions that allow unauthorized read, write, or execute access.
Hardcoded Password in Default Function Argument
HIGHA function defines a default argument whose name suggests a password or secret but whose value is a hardcoded string literal.
Regex DoS Risk
LOWDetects re.compile(), re.match(), re.search(), and re.findall() calls that should be audited for catastrophic backtracking patterns.
logging.config.listen() Eval Risk
HIGHDetects logging.config.listen() which opens a socket that accepts and executes arbitrary logging configuration, enabling remote code execution.
Logger Credential Leak Risk
MEDIUMDetects logging calls (info, debug, warning, error, critical) that should be audited for accidental credential or secret leakage in log output.