Skip to content

    Type a page, a command such as keryn scan, or a rule id.

    vulnfix-gaps-v1

    View as Markdown

    33 rules · Keryn Software Licence · rules 0.8.0 · all packs

    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.

    warning python pickle

    pickle.Unpickler(file) builds an unpickler whose load() runs any code the stream encodes. Only unpickle data this process produced and signed; use JSON or safetensors for anything that crosses a trust boundary.

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

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05 LLM03

    Fix: Replace pickle with a data format that cannot carry code, or restrict find_class in an Unpickler subclass to an explicit allow-list.

    References: https://docs.python.org/3/library/pickle.html#pickle.Unpickler

    error python jsonpickle

    jsonpickle.decode rebuilds arbitrary Python objects from JSON, calling constructors and reduce hooks named in the document, so untrusted input runs code. Parse plain JSON and build objects yourself.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05 LLM03

    Fix: Use json.loads and construct the objects explicitly, or pass safe=True and an allow-list of classes.

    References: https://jsonpickle.github.io/api.html

    warning python python

    os.popen runs its argument through the shell. When the command text is built at run time, shell metacharacters in any part of it execute. Use subprocess.run with an argument list and shell=False.

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

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Switch to subprocess.run([…], shell=False) with each argument as its own list element.

    References: https://docs.python.org/3/library/os.html#os.popen

    keryn.vfgap.subprocess-check-shell-true-py

    Section titled “keryn.vfgap.subprocess-check-shell-true-py”

    warning python python

    subprocess.check_output / check_call with shell=True hands the command string to the shell, so any untrusted part of it executes. Pass an argument list and leave shell off. This is a presence check: an allow-list or membership test is seen only in the form if x not in ALLOWED: return right before the call, so it is advisory (P2); the taint rules report the untrusted flows.

    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 one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Use subprocess.check_output([…]) with a list and no shell=True; allow-list the program name.

    References: https://docs.python.org/3/library/subprocess.html#security-considerations

    error python requests, httpx

    TLS certificate verification is switched off (verify=False), so this client accepts any certificate and a network attacker can read or alter the traffic, including API keys and model responses. Trust a CA bundle instead.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: trusts one party believes another without evidence.

    CWE-295 LLM02

    Fix: Remove verify=False; if you use a private CA, point verify at its bundle path.

    References: https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification

    error python ssl

    ssl._create_unverified_context() returns a context that skips certificate and host-name checks, and assigning it as the default context disables verification process-wide. Use ssl.create_default_context().

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-295 LLM02

    Fix: Replace with ssl.create_default_context() and, for a private CA, load its certificate with cafile=.

    References: https://docs.python.org/3/library/ssl.html#ssl.create_default_context

    error python flask

    app.run(debug=True) starts the Werkzeug debugger, which serves an interactive console that executes Python for anyone who can reach the port. Never ship it; use an environment-driven setting that is off in production.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: grants authority is given or left unchecked.

    CWE-489 LLM02

    Fix: Remove debug=True from run() and use FLASK_DEBUG only in local development.

    References: https://flask.palletsprojects.com/en/stable/debugging/

    keryn.vfgap.tarfile-extractall-unfiltered-py

    Section titled “keryn.vfgap.tarfile-extractall-unfiltered-py”

    warning python tarfile

    extractall on a tar archive without a filter writes members to the paths the archive names, including ../ and absolute paths and links that point outside the target. A model or dataset archive from outside can overwrite files. Pass filter=‘data’ (Python 3.12+) or check each member.

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

    Edge inspected: reads one thing reads from another.

    CWE-22 LLM03

    Fix: Call extractall(path, filter=‘data’) or iterate members and refuse absolute paths, ‘..’, and links leaving the target directory.

    References: https://docs.python.org/3/library/tarfile.html#extraction-filters

    warning python jinja2

    Environment.from_string compiles its argument as a template and a normal Environment is not sandboxed, so a template body that includes model or user text can run code. Render with a fixed template and pass the text as data, or use SandboxedEnvironment.

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

    Edge inspected: calls one thing invokes another.

    CWE-1336 LLM05

    Fix: Keep templates in files you control, pass dynamic text as variables, and use jinja2.sandbox.SandboxedEnvironment for any template you did not write.

    References: https://jinja.palletsprojects.com/en/stable/sandbox/

    keryn.vfgap.django-mark-safe-non-literal-py

    Section titled “keryn.vfgap.django-mark-safe-non-literal-py”

    warning python django

    mark_safe tells Django not to escape the value, so model or user text passed through it is rendered as live HTML. Escape with format_html or conditional_escape, or sanitise before marking.

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

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-79 LLM05

    Fix: Build the markup with format_html(), which escapes its arguments, or sanitise with an allow-list sanitiser before calling mark_safe.

    References: https://docs.djangoproject.com/en/stable/ref/utils/#django.utils.safestring.mark_safe

    error javascript, typescript nodejs

    The Node vm module is not a security boundary: code run through vm.runInThisContext, runInNewContext or runInContext (or a new vm.Script) can escape to the host. When the source text is built from model, tool or user input this is code execution. Use a separate process or isolate with no secrets.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-94 LLM05

    Fix: Run untrusted code in an isolated process, container or isolated-vm, and never pass model output to the vm module.

    References: https://nodejs.org/api/vm.html#vm-executing-javascript

    error javascript, typescript node-serialize

    node-serialize’s unserialize evaluates function expressions embedded in the serialized text, so any attacker- controlled string is remote code execution (the library is unmaintained for this reason). Use JSON.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Replace node-serialize with JSON.stringify / JSON.parse and a schema check.

    References: https://github.com/luin/serialize#readme

    keryn.vfgap.tls-reject-unauthorized-false-js

    Section titled “keryn.vfgap.tls-reject-unauthorized-false-js”

    error javascript, typescript nodejs

    rejectUnauthorized: false (or NODE_TLS_REJECT_UNAUTHORIZED=0) makes Node accept any TLS certificate, so a network attacker can read or change the traffic, including API keys. Trust a CA bundle instead.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: trusts one party believes another without evidence.

    CWE-295 LLM02

    Fix: Remove the option; for a private CA pass its certificate in the ca option.

    References: https://nodejs.org/api/tls.html#tlsconnectoptions-callback

    warning javascript, typescript javascript

    Calling Function(…) without new still compiles its string argument into code, exactly like eval. When the text contains model, tool or user data this is code execution. Parse a data format or dispatch to named functions instead.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-94 LLM05

    Fix: Replace the call with a lookup table of allowed functions or a data parser.

    References: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function

    error javascript, typescript nodejs

    execSync and execAsync run their string through a shell, so any untrusted part of the command executes. Use execFileSync / spawn with an argument array and no shell.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Switch to execFileSync(program, [args]) with an allow-listed program and each argument separate.

    References: https://nodejs.org/api/child_process.html#child_processexecsynccommand-options

    error java java

    Runtime.exec with a string that is built at run time splits and runs attacker-influenced text as a command. Pass a fixed program and a separate argument array, and allow-list the program.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Use ProcessBuilder with a fixed executable and one array element per argument, never concatenating input into the command line.

    References: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Runtime.html#exec(java.lang.String)

    keryn.vfgap.process-builder-non-literal-java

    Section titled “keryn.vfgap.process-builder-non-literal-java”

    warning java java

    ProcessBuilder is created from a value that is not a literal. If any part of it comes from a model, tool or user, the program or its arguments are attacker-chosen; with sh -c it is a shell injection. Allow-list the program and keep arguments as separate elements.

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

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Fix the executable path, validate every argument against an allow-list, and never pass a shell with a string built from input.

    References: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html

    keryn.vfgap.xml-factory-without-hardening-java

    Section titled “keryn.vfgap.xml-factory-without-hardening-java”

    warning java java

    This XML factory is created and used with default settings in a method that never calls setFeature, setProperty or setAttribute on it. The defaults of the JDK parsers resolve external entities and DTDs, so a crafted document read from a tool, upload or fetched file can read local files or reach internal URLs (XXE). Disable DOCTYPEs and external access before parsing.

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

    Edge inspected: reaches content or traffic gets to a thing.

    CWE-611 LLM05

    Fix: Call setFeature(“http://apache.org/xml/features/disallow-doctype-decl”, true) (or the factory’s FEATURE_SECURE_PROCESSING and ACCESS_EXTERNAL_* properties) on the factory right after creating it.

    References: https://docs.oracle.com/en/java/javase/21/security/java-api-xml-processing-jaxp-security-guide.html

    error java java

    java.beans.XMLDecoder executes the method calls and constructors a document describes, so reading an XML file or stream from outside is code execution. Use a data-only parser.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Parse the XML with a hardened parser into plain data objects; remove XMLDecoder.

    References: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/beans/XMLDecoder.html

    error java xstream

    XStream.fromXML rebuilds arbitrary Java objects from XML and has a long history of gadget-chain code execution unless a type allow-list is installed. Call allowTypes / addPermission before unmarshalling anything from outside.

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

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Configure XStream with allowTypes(…) for exactly the classes you expect (XStream.setupDefaultSecurity plus an allow-list) or use a data-only format.

    References: https://x-stream.github.io/security.html

    error java snakeyaml

    A SnakeYAML Yaml built with its default constructor can instantiate any class named by a tag in the document, so loading untrusted YAML runs code. Construct it with new Yaml(new SafeConstructor(new LoaderOptions())).

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Create the parser with SafeConstructor (or a TagInspector allow-list in 2.x) before calling load.

    References: https://bitbucket.org/snakeyaml/snakeyaml/wiki/CVE%20&%20Vulnerabilities

    warning java java

    ObjectInputStream.readObject runs the deserialization logic of every class on the classpath that the stream names, which is how most Java deserialization gadget chains execute. Never read one from an untrusted source; install an ObjectInputFilter allow-list.

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

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Use a data format (JSON, protobuf) or set an ObjectInputFilter (setObjectInputFilter) that admits only the classes you expect.

    References: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/ObjectInputStream.html

    error java java

    ScriptEngine.eval runs its argument as script code with access to the JVM. When the text is built from model, tool or user input that is code execution.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-94 LLM05

    Fix: Avoid script engines for dynamic input; if a rules language is needed, use a sandboxed expression evaluator with an allow-list.

    References: https://docs.oracle.com/en/java/javase/21/docs/api/java.scripting/javax/script/ScriptEngine.html

    keryn.vfgap.insecure-formatter-deserialization-cs

    Section titled “keryn.vfgap.insecure-formatter-deserialization-cs”

    error csharp dotnet

    BinaryFormatter, LosFormatter, SoapFormatter, ObjectStateFormatter and NetDataContractSerializer deserialize arbitrary .NET types and cannot be made safe for untrusted data (Microsoft marks them obsolete). Switch to System.Text.Json or another data-only serializer.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Replace with System.Text.Json, DataContractSerializer with known types, or protobuf; do not deserialize with these formatters at all.

    References: https://learn.microsoft.com/en-us/dotnet/standard/serialization/binaryformatter-security-guide

    error csharp dotnet, newtonsoft

    TypeNameHandling set to All, Auto, Objects or Arrays lets the JSON document name the .NET type to create, which is a well-known gadget-chain path to code execution when the JSON is untrusted. Keep it None or use a SerializationBinder allow-list.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: depends_on something relies on a component it does not verify; it crosses the supply-chain boundary (code, models or prompts pulled in from outside).

    CWE-502 LLM05

    Fix: Set TypeNameHandling.None (the default), or restrict types with a custom ISerializationBinder that allow-lists exactly your DTOs.

    References: https://www.newtonsoft.com/json/help/html/SerializationSettings.htm#TypeNameHandling

    warning csharp dotnet

    Process.Start is called with a value that is not a literal. If the file name or arguments come from a model, tool or user, the caller chooses what runs. Allow-list the executable and pass arguments through ArgumentList.

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

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Fix the executable, validate arguments against an allow-list, and use ProcessStartInfo.ArgumentList rather than a concatenated string.

    References: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start

    error go go

    exec.Command is started with sh or bash -c and a command string that is not a literal. Any untrusted part of the string runs as shell. Call the program directly with its arguments as separate values.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Replace sh -c with exec.Command(program, args…) and allow-list the program.

    References: https://pkg.go.dev/os/exec#Command

    error go go

    InsecureSkipVerify: true makes the TLS client accept any certificate and host name, so a network attacker can read or alter the traffic. Verify certificates and supply a RootCAs pool for private CAs.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: trusts one party believes another without evidence.

    CWE-295 LLM02

    Fix: Delete InsecureSkipVerify (default false) and set RootCAs for a private CA.

    References: https://pkg.go.dev/crypto/tls#Config

    warning go go

    DES, 3DES and RC4 are broken or deprecated ciphers (56-bit keys, 64-bit blocks, biased keystream). Use AES-GCM or ChaCha20-Poly1305.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: none a property of one thing, not a relationship between two.

    CWE-327 LLM02

    Fix: Switch to aes.NewCipher with cipher.NewGCM, or chacha20poly1305.

    References: https://pkg.go.dev/crypto/des

    warning go go

    template.HTML(x) tells html/template not to escape x. When x holds model, tool or user text it renders as live markup. Pass plain strings to the template and let it escape, or sanitise first.

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

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-79 LLM05

    Fix: Remove the template.HTML conversion for dynamic values, or run them through an HTML sanitiser (bluemonday) first.

    References: https://pkg.go.dev/html/template#HTML

    error php php

    proc_open and popen start a process from a command string that is not a literal. Any untrusted part of it runs as shell. Pass an argument array (proc_open) and escape what remains with escapeshellarg.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-78 LLM05

    Fix: Use proc_open with an array command, allow-list the program, and wrap every dynamic argument in escapeshellarg.

    References: https://www.php.net/manual/en/function.proc-open.php

    warning php php

    Before PHP 8, assert() evaluated a string argument as PHP code. Passing a variable here executes whatever it holds. Assert on a boolean expression instead.

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

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-95 LLM05

    Fix: Pass a boolean expression, not a string, and remove assert() from production paths.

    References: https://www.php.net/manual/en/function.assert.php

    error php php

    create_function compiles its string arguments with eval semantics (and is removed in PHP 8). Any dynamic text in the body is code injection. Use a closure.

    Confidence P1: dangerous in context. False-positive risk low: an exact API or flag, so hits are almost always real.

    Edge inspected: calls one thing invokes another; it crosses the model->code boundary (model output reaching code, a shell, a query or a page).

    CWE-95 LLM05

    Fix: Replace create_function with an anonymous function (function () use (…) { … }).

    References: https://www.php.net/manual/en/function.create-function.php