Skip to main content
Vulnerability Database/CVE-2026-107717

CVE-2026-107717: Banks Prompt Injection Vulnerability

CVE-2026-107717 is a prompt injection vulnerability in Banks that allows attackers to inject malicious JSON and manipulate LLM message roles. This post covers technical details, affected versions, impact, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-107717 Overview

CVE-2026-107717 affects Banks, a Python library that generates Large Language Model (LLM) prompts using a simple template language. The flaw exists in Prompt.chat_messages(), which parses every line of rendered template output as ChatMessage JSON. When an application renders untrusted data into a prompt, attacker-controlled JSON can cross the prompt boundary and be interpreted as a system, assistant, or tool message. The ChatMessage.role field accepts arbitrary strings, enabling role spoofing. The vulnerability is fixed in Banks version 2.5.0.

Critical Impact

Attackers who control any portion of rendered template input can inject fabricated chat messages that override application instructions, alter prompt structure, or confuse downstream tool handling in LLM pipelines.

Affected Products

  • Banks prompt templating library, versions prior to 2.5.0
  • LLM applications that pass ChatMessage objects from Prompt.chat_messages() to an LLM provider
  • Downstream agent and tool-calling pipelines that trust Banks-rendered message roles

Discovery Timeline

  • 2026-10-08 - CVE-2026-107717 published to the National Vulnerability Database (NVD)
  • 2026-10-13 - Last updated in NVD database

Technical Details for CVE-2026-107717

Vulnerability Analysis

Banks renders Jinja-style templates into text intended for LLM consumption. Prompt.chat_messages() splits the rendered output and attempts to parse each line as a JSON ChatMessage structure. The method applies no boundary marker or trust indicator to distinguish template-authored structured output from text produced by variable interpolation.

When an application interpolates user-supplied content (chat history, document excerpts, retrieval results) into a template, that content is subject to the same parsing pass. An attacker who submits a line of valid JSON matching the ChatMessage shape causes Banks to emit an additional message with attacker-chosen role and content. Because ChatMessage.role is typed as an arbitrary string, roles such as system or tool are accepted without validation [CWE-20].

Root Cause

The root cause is improper input validation of rendered template output. chat_messages() treats every line as potentially structured data and does not require a sentinel or marker to indicate that a line was intentionally emitted as a chat message by the template author. User-controlled text and template-authored text share the same parsing path.

Attack Vector

Exploitation requires only that the application render untrusted content through a Banks template and forward the resulting ChatMessage list to an LLM. No authentication is required when the untrusted content enters through a public interface such as a chatbot, document upload, or web retrieval. A successful injection can:

  • Insert a forged system message that supersedes the application's own instructions
  • Insert an assistant message to seed false conversational context
  • Insert a tool message to spoof tool-call results and alter downstream agent decisions
python
# Patch excerpt from src/banks/env.py
from .config import config
from .filters import audio, cache_control, document, image, lemmatize, tool, video, xml
from .utils import ensure_environment_sentinel


def _add_extensions(_env):
    ...
# Source: https://github.com/masci/banks/commit/02172b816fb84f6a824cc09a8aca7416f53c12cb

The fix introduces an ensure_environment_sentinel utility so that only output explicitly marked by the template environment is parsed as a chat message, closing the trust-boundary gap.

Detection Methods for CVE-2026-107717

Indicators of Compromise

  • Rendered Banks output containing JSON lines with role values of system, assistant, or tool that did not originate from the template source
  • LLM responses that follow instructions not present in the application's authored system prompt
  • Agent tool-call traces showing synthetic tool message results with no matching upstream tool invocation

Detection Strategies

  • Log the full ChatMessage list produced by Prompt.chat_messages() and diff it against the template's declared message count and roles
  • Scan untrusted inputs reaching Banks templates for strings matching the ChatMessage JSON schema before rendering
  • Add integration tests that render templates with adversarial fixtures containing JSON role payloads and assert the output message count

Monitoring Recommendations

  • Instrument LLM request pipelines to record per-request message role counts and alert on unexpected system or tool messages
  • Monitor for Banks package versions below 2.5.0 across Python dependency inventories and software bills of materials
  • Review agent tool-execution logs for calls that reference tools or results absent from the authoritative tool registry

How to Mitigate CVE-2026-107717

Immediate Actions Required

  • Upgrade Banks to version 2.5.0 or later in all environments that render untrusted content
  • Audit existing templates to confirm that user-controlled variables are not interpolated into regions parsed as chat messages
  • Review LLM application logs for prior requests whose message role distributions suggest injection attempts

Patch Information

The fix is tracked in GitHub Pull Request #78 and committed as 02172b8. The patched release is available at Banks v2.5.0. Full advisory details are published as GHSA-hmq2-7hp6-7crh. After the fix, Banks parses only output explicitly marked with an environment sentinel as ChatMessage JSON.

Workarounds

  • Sanitize untrusted inputs by stripping or escaping newline characters and leading { tokens before passing them to Banks templates
  • Validate the output of Prompt.chat_messages() against an allowlist of expected roles before forwarding to an LLM provider
  • Isolate untrusted content inside clearly delimited, non-JSON template regions that are not forwarded through chat_messages()
bash
# Upgrade Banks to the patched release
pip install --upgrade 'banks>=2.5.0'

# Verify installed version
python -c "import banks; print(banks.__version__)"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.