Severity:

HIGH RISK

(7.3)

Code Injection / Dynamic Evaluation Vulnerability

CVE-2026-4965

Analyzed

Vulnerability type

Category:

Code Injection / Dynamic Evaluation Vulnerability

CWE:

CWE-94, CWE-95

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A code injection vulnerability in the resolve_type function within letta/functions/ast_parsers.py leads to improper neutralization of directives in dynamically evaluated code.

An attacker who can influence the inputs processed by this function may be able to execute arbitrary code remotely, especially in deployments that evaluate user-controllable expressions or directives.

Affected context

The vulnerability occurs in installations of letta-ai letta 0.16.4 that rely on the resolve_type logic from letta/functions/ast_parsers.py to interpret or transform dynamic expressions or type declarations.

It is relevant where untrusted or partially trusted input can reach this code path and where the library is configured to evaluate or interpret such input at runtime.

The issue is associated with an incomplete fix for CVE-2025-6101, indicating that the earlier remediation did not fully neutralize dangerous directives or constructs before evaluation.

Exploit preconditions

  • Attack surface: Remote, via any interface (API, SDK, plugin, or integration) that accepts user-controlled or externally sourced content passed into resolve_type or its call chain.
  • Required access: Ability to supply crafted data that is parsed and interpreted by the vulnerable function; this may involve authenticated or unauthenticated access depending on how the host application exposes letta.
  • Trigger point: Invocation of resolve_type on attacker-controlled input, typically during parsing, type resolution, or dynamic expression handling.
  • Why exploitation is possible: The function performs dynamic evaluation (for example, using constructs like eval, exec, or equivalent dynamic execution primitives) without fully neutralizing or constraining directives and operators that can alter control flow, import modules, or execute arbitrary code.

Why this happens

The underlying bug is an instance of CWE-94: Improper Control of Generation of Code ('Code Injection') and is closely related to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code.

The resolve_type function appears to construct or feed programmatic fragments derived from external input into a dynamic evaluation mechanism that can interpret them as executable code.

Because the neutralization or sanitization logic—originally introduced as a fix for CVE-2025-6101—is incomplete, certain metacharacters, operators, or directives remain allowed.

These residual constructs enable an attacker to escape any intended type or expression constraints and inject additional logic that the interpreter executes with the privileges of the running process.

Conceptually, the pattern is: "User-influenced string → treated as code → evaluated without strict whitelisting or sandboxing".

Potential impact

  • Execution of arbitrary code within the context of the application process.
  • Complete compromise of the host application using letta, including data theft, data modification, or impersonation of application logic.
  • Lateral movement inside the hosting environment (e.g., reading environment variables, accessing other services, or interacting with the filesystem or network).
  • Bypass of application-level authorization or business logic by injecting directives that change control flow.
  • Potential use of the vulnerable environment as a pivot for further attacks, such as supply-chain manipulation of generated artifacts or configurations.

General mitigation guidance

Effective mitigation focuses on eliminating dynamic evaluation of untrusted data and enforcing strict interpretation boundaries:

  • Replace generic dynamic evaluation mechanisms (e.g., direct eval/exec or similar constructs) with explicit, declarative parsing that maps input tokens to a closed set of allowed operations or types.
  • Apply robust whitelisting rather than blacklisting: define a finite grammar or schema for acceptable directives and reject anything outside that specification before interpretation.
  • Treat all user-influenced expressions as data, not code: prefer table-driven lookups, mapping identifiers to pre-defined handlers, instead of constructing executable fragments.
  • Introduce a hardened validation layer around parsing and type resolution that normalizes input, strips unsupported features, and enforces maximum complexity and length.
  • Run components that must interpret dynamic content under least privilege, with constrained OS-level capabilities and separated from sensitive resources to limit blast radius if a flaw persists.
  • Incorporate defense-in-depth controls such as application isolation, read-only runtime environments where possible, and strict network egress policies for components using dynamic evaluation.

How teams detect issues like this

Detection can combine static analysis, code review, and runtime monitoring:

  • Static analysis: Configure rules to flag use of dynamic execution functions (eval, exec, or similar APIs) and track taint flows from external inputs into these sinks; verify that any sanitization steps implement strict whitelisting.
  • Code review: During manual review, pay special attention to parser components, AST handlers, and type-resolution logic that construct or transform strings before evaluation; look for incomplete or ad-hoc filtering patterns, regular-expression based "sanitizers," or attempts to block only specific tokens.
  • Policy enforcement: Establish organizational guidelines that prohibit direct evaluation of user-controllable input and require security sign-off for any dynamic evaluation mechanisms, including those added as "temporary" solutions.
  • Runtime monitoring: Instrument logging around parsing and evaluation paths to detect anomalous or unusually complex expressions; consider behavioral analytics or WAF-style controls at upstream layers to flag suspicious payloads.
  • Automated tooling: Integrate SAST and dependency-scanning tools in CI pipelines to highlight risky patterns and known vulnerable components, and set policies that prevent merging code introducing new dynamic execution sinks without review.

Sources

SourceLink
gist.github.comgist.github.com/YLChen-007/fc09bc447a73bba526c1642d9ce73ca5
vuldb.comvuldb.com/?ctiid.353842
vuldb.comvuldb.com/?id.353842
vuldb.comvuldb.com/?submit.777654

Frequently asked

questions

Exploitability depends on how the host application exposes resolve_type or the surrounding parsing functionality.

If untrusted users can influence the expressions or directives passed into this logic, exploitation can be remote and impactful; in tightly controlled deployments where only trusted administrators provide such input, the risk is lower but still present.

Not necessarily. The key requirement is the ability to supply data that ultimately reaches the vulnerable function.

In some integrations this may require authenticated API access, while in others a public endpoint, plugin, or workflow may forward anonymous user input into the parser.

The safest pattern is to remove or strictly limit dynamic evaluation: replace code-evaluating APIs with deterministic parsing that resolves only a predefined set of tokens or types, backed by a whitelist.

Inputs should be validated against a clear grammar or schema, and anything outside that definition should be rejected rather than "cleaned."

Avoid designs where external input is treated as code or is transformed into executable fragments.

When dynamic behavior is needed, use configuration-driven or table-driven approaches that map identifiers to pre-registered behaviors, enforce least privilege for components that perform interpretation, and incorporate static analysis and security reviews specifically targeting parser and evaluation logic.

Find out what's already
exploitable in your codebase.