# general-imports-python-v1

> general-imports-python-v1: 8 Keryn rules for python (2 warning, 6 info).

Source: https://keryn.dev/rules/general-imports-python-v1/

8 rules · Keryn Software Licence · rules 0.8.0 · [all packs](https://keryn.dev/rules/)

**How to read a rule**

- **Severity**: How bad the finding is if it is real: `error` fails a default gate, `warning` and `info` do not.

- **Confidence**: **P0** exploitable as written; **P1** dangerous in context; **P2** a heuristic or a posture check: confirm by reading the code.

- **False-positive risk**: **low**: an exact API or flag, so hits are almost always real; **medium**: the pattern is legitimate in many programs, so check each hit; **high**: it finds a lead to confirm, so expect benign hits.

- **Edge**: The relationship the finding sits on. **reaches**: content or traffic gets to a thing; **calls**: one thing invokes another; **reads**: one thing reads from another; **writes**: one thing writes to another; **sends**: data leaves for another party; **grants**: authority is given or left unchecked; **depends_on**: something relies on a component it does not verify; **trusts**: one party believes another without evidence. The boundary it crosses, when there is one: **user->prompt** (untrusted input reaching a prompt); **model->code** (model output reaching code, a shell, a query or a page); **secret->outside** (a secret leaving the trusted side); **supply-chain** (code, models or prompts pulled in from outside).

- **Taxonomy chips**: References for readers who work in OWASP LLM 2025, OWASP Agentic, CWE or NIST AI RMF. They say where a rule belongs, not that a framework is satisfied.

## keryn.general.python.import-process-execution

`info` python python

Imports subprocess: this file can start operating-system processes. Inventory only; the command-execution rules report the calls that matter.

Confidence **P1**: dangerous in context.

Edge inspected: [depends_on](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-78](https://keryn.dev/taxonomies/cwe/#cwe-78-os-command-injection) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**References:** [https://docs.python.org/3/library/subprocess.html#security-considerations](https://docs.python.org/3/library/subprocess.html#security-considerations)

## keryn.general.python.import-object-deserializer

`info` python python

Imports pickle, cPickle, dill or shelve: this file can turn bytes into arbitrary Python objects, which runs code if the bytes are untrusted. Inventory only; the deserialisation rules report the load calls.

Confidence **P1**: dangerous in context.

Edge inspected: [depends_on](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-502](https://keryn.dev/taxonomies/cwe/#cwe-502-deserialization-of-untrusted-data) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**References:** [https://docs.python.org/3/library/pickle.html#restricting-globals](https://docs.python.org/3/library/pickle.html#restricting-globals)

## keryn.general.python.import-stdlib-xml-parser

`info` python python

Imports a standard-library XML parser (ElementTree, SAX, expatbuilder, minidom, pulldom). Those parsers expand entities without limit; inventory only, the XML rule reports the parse calls.

Confidence **P1**: dangerous in context.

Edge inspected: [depends_on](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-776](https://keryn.dev/rules/?cwe=CWE-776) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**References:** [https://docs.python.org/3/library/xml.html#xml-vulnerabilities](https://docs.python.org/3/library/xml.html#xml-vulnerabilities)

## keryn.general.python.import-cleartext-protocol

`info` python python

Imports telnetlib or ftplib: this file speaks Telnet or FTP, protocols that send credentials in clear text (ftplib.FTP\_TLS excepted). Inventory only; the cleartext-protocol rule reports the client constructors.

Confidence **P1**: dangerous in context.

Edge inspected: [depends_on](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify; it crosses the [`supply-chain`](https://keryn.dev/docs/edges/trust-boundaries/#supply-chain) boundary (code, models or prompts pulled in from outside).

[CWE-319](https://keryn.dev/rules/?cwe=CWE-319) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**References:** [https://peps.python.org/pep-0594/#telnetlib](https://peps.python.org/pep-0594/#telnetlib) · [https://docs.python.org/3/library/ftplib.html](https://docs.python.org/3/library/ftplib.html)

## keryn.general.python.xmlrpc-expat

`warning` python python

Imports xmlrpc. Its client and server parse responses and requests with expat, which expands entities without limit, so a hostile peer can exhaust memory or CPU.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another.

[CWE-776](https://keryn.dev/rules/?cwe=CWE-776) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**Fix:** Call defusedxml.xmlrpc.monkey\_patch() at start-up, or replace XML-RPC with a JSON API.

**References:** [https://docs.python.org/3/library/xmlrpc.html](https://docs.python.org/3/library/xmlrpc.html) · [https://github.com/tiran/defusedxml#defusedxmlxmlrpc](https://github.com/tiran/defusedxml#defusedxmlxmlrpc)

## keryn.general.python.cgi-handler-httpoxy

`warning` python python, twisted

A CGI handler (wsgiref CGIHandler, twisted CGIScript/CGIDirectory) maps the client's `Proxy:` header to the HTTP\_PROXY environment variable (httpoxy, CVE-2016-5385/5386), so outgoing HTTP from the application can be sent through an attacker's proxy.

Confidence **P1**: dangerous in context. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [calls](https://keryn.dev/docs/edges/edge-kinds/#calls) one thing invokes another.

[CWE-454](https://keryn.dev/rules/?cwe=CWE-454) [LLM05](https://keryn.dev/taxonomies/owasp-llm/#llm05-improper-output-handling)

**Fix:** Serve the application through a WSGI server instead of CGI, or strip the Proxy request header before the handler runs.

**References:** [https://httpoxy.org/](https://httpoxy.org/) · [https://docs.python.org/3/library/wsgiref.html#wsgiref.handlers.CGIHandler](https://docs.python.org/3/library/wsgiref.html#wsgiref.handlers.CGIHandler)

## keryn.general.python.pycrypto-namespace

`info` python pycrypto, pycryptodome

Imports from the `Crypto` package. PyCrypto, the original owner of that name, has been unmaintained since 2013 and has known vulnerabilities (CVE-2013-7459); PyCryptodome installs under the same name. Confirm which package is installed.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **high**: it finds a lead to confirm, so expect benign hits.

Edge inspected: [depends_on](https://keryn.dev/docs/edges/edge-kinds/#depends-on) something relies on a component it does not verify.

[CWE-1104](https://keryn.dev/rules/?cwe=CWE-1104) [CWE-327](https://keryn.dev/taxonomies/cwe/#cwe-327) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain)

**Fix:** Remove pycrypto from the dependencies; use the cryptography package or pycryptodomex (the `Cryptodome` namespace) so the import cannot resolve to PyCrypto.

**References:** [https://github.com/pycrypto/pycrypto/issues/238](https://github.com/pycrypto/pycrypto/issues/238) · [https://www.pycryptodome.org/src/installation](https://www.pycryptodome.org/src/installation)

## keryn.general.python.pyghmi-ipmi

`info` python pyghmi

Imports pyghmi, an IPMI client. IPMI 2.0 authentication (RAKP) gives the password hash to any client that asks, so BMC credentials used here can be cracked offline, and the protocol is often run without encryption.

Confidence **P2**: a heuristic or a posture check: confirm by reading the code. False-positive risk **medium**: the pattern is legitimate in many programs, so check each hit.

Edge inspected: [sends](https://keryn.dev/docs/edges/edge-kinds/#sends) data leaves for another party; it crosses the [`secret->outside`](https://keryn.dev/docs/edges/trust-boundaries/#secret-to-outside) boundary (a secret leaving the trusted side).

[CWE-319](https://keryn.dev/rules/?cwe=CWE-319) [CWE-327](https://keryn.dev/taxonomies/cwe/#cwe-327) [LLM03](https://keryn.dev/taxonomies/owasp-llm/#llm03-supply-chain)

**Fix:** Keep IPMI on an isolated management network, use a dedicated BMC account per host, and prefer Redfish over HTTPS where the hardware supports it.

**References:** [https://opendev.org/x/pyghmi](https://opendev.org/x/pyghmi) · [https://www.rapid7.com/blog/post/2013/07/02/a-penetration-testers-guide-to-ipmi/](https://www.rapid7.com/blog/post/2013/07/02/a-penetration-testers-guide-to-ipmi/)
