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

CVE-2026-114386: Pydantic AI Harness Privilege Escalation

CVE-2026-114386 is a privilege escalation vulnerability in Pydantic AI Harness before 0.59.0 that allows bypassing tool call limits through nested invocations. This article covers technical details, affected versions, 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-114386 Overview

CVE-2026-114386 affects Pydantic AI Harness versions prior to 0.59.0. The library fails to enforce UsageLimits.tool_calls_limit on nested tool calls dispatched from run_code in the CodeMode toolset. Sandboxed programs can invoke tools through run_nested_call() without triggering check_before_tool_call, bypassing operator-defined limits on costly or side-effecting tools. The flaw is categorized under CWE-770 (Allocation of Resources Without Limits or Throttling). Users or prompt-injected content can exploit this gap to exceed intended tool invocation ceilings in agentic AI workflows.

Critical Impact

Prompt-injected or malicious inputs can drive unbounded nested tool invocations, resulting in excess cost and uncontrolled side effects in agent pipelines.

Affected Products

  • Pydantic AI Harness versions prior to 0.59.0
  • CodeMode toolset using run_code with nested tool dispatch
  • Agent pipelines relying on UsageLimits.tool_calls_limit for budget enforcement

Discovery Timeline

  • 2026-10-21 - CVE-2026-114386 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-114386

Vulnerability Analysis

Pydantic AI Harness exposes a CodeMode toolset that lets a model author Python-like code executed inside a sandbox. The sandboxed program can call registered tools indirectly through run_nested_call(). The outer run_code tool is subject to check_before_tool_call, which enforces UsageLimits.tool_calls_limit. Nested invocations dispatched from within the sandbox do not pass through the same gating path. The counter never increments, and operator-defined ceilings never trigger.

Attackers who control model input, or who inject prompts into retrieved context, can instruct the agent to issue many nested tool calls from a single run_code invocation. This escalates spend on paid APIs, exhausts rate-limited services, and amplifies the blast radius of tools with external side effects.

Root Cause

The missing enforcement is a classic resource-throttling gap [CWE-770]. The _eager.py and _monty_exec.py modules in the code_mode package dispatch nested calls without consulting the usage-limit state tracked on the execution context.

Attack Vector

Exploitation requires only that an attacker influences the content a Pydantic AI agent processes. No authentication is needed when the agent itself is network-reachable or ingests untrusted documents. A single run_code dispatch can loop over run_nested_call() to invoke the same costly tool repeatedly, defeating the configured tool_calls_limit.

python
# Security patch from upstream commit eb27b2b
# File: src/pydantic_ai_harness/pydantic_ai_harness/code_mode/_eager.py

        if tool_args.get('restart', False):
            await self.execution.discard(call)
+           if call.execution.usage_limit_exceeded is not None:
+               raise call.execution.usage_limit_exceeded
            async with self.execution.feed_lock:
                return await super().call_tool(name, tool_args, ctx, tool)

Source: GitHub Commit eb27b2b

The fix re-checks usage_limit_exceeded on the execution context before each nested tool call, raising the stored limit exception when the ceiling is reached.

Detection Methods for CVE-2026-114386

Indicators of Compromise

  • Repeated invocations of the same tool within a single run_code execution exceeding configured tool_calls_limit values.
  • Agent runs producing unexpectedly high tool-call counts without corresponding UsageLimitExceeded exceptions.
  • Elevated spend or rate-limit errors on downstream APIs invoked by CodeMode tools.

Detection Strategies

  • Instrument the CodeMode toolset to log every run_nested_call() dispatch with a correlation ID tied to the parent run_code call.
  • Compare per-run nested-call totals against the operator's UsageLimits.tool_calls_limit and alert on divergence.
  • Monitor agent telemetry for prompt-injection patterns that reference run_nested_call or request repeated tool execution.

Monitoring Recommendations

  • Forward Pydantic AI Harness runtime logs to a centralized analytics platform and build dashboards tracking tool-call distributions per session.
  • Alert on downstream API cost or quota anomalies that correlate with agent activity windows.
  • Review retrieved context sources for injected instructions targeting the CodeMode toolset.

How to Mitigate CVE-2026-114386

Immediate Actions Required

  • Upgrade pydantic-ai-harness to version 0.59.0 or later from PyPI.
  • Audit agents that enable CodeMode to confirm UsageLimits are set and enforced after the upgrade.
  • Rotate or revoke credentials for any downstream tool that may have been invoked beyond intended limits.

Patch Information

The fix is tracked in GitHub Pull Request #10362 and shipped in Release v2.59.0. Commit eb27b2b adds usage_limit_exceeded checks before each nested tool dispatch in _eager.py and _monty_exec.py. See the VulnCheck advisory for additional context.

Workarounds

  • Disable the CodeMode toolset in agent configurations until the upgrade is applied.
  • Remove or restrict tools with high cost or external side effects from the registry exposed to CodeMode.
  • Enforce out-of-band quotas at the downstream API or gateway layer to cap tool invocations independent of the agent runtime.
bash
# Upgrade Pydantic AI Harness to the patched release
pip install --upgrade 'pydantic-ai-harness>=0.59.0'

# Verify the installed version
pip show pydantic-ai-harness | grep -i 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.