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_typeor 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_typeon 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/execor 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.

