Summary
Tautulli's notification template engine implements a sandboxed eval-like function that attempts to restrict what Python code can run in customized notification texts.
Due to incomplete inspection of nested lambda code objects, an attacker who can control notification templates may be able to execute arbitrary Python code despite the sandbox restrictions.
Affected context
This vulnerability appears in Tautulli's notification handling subsystem, specifically in the str_eval() function used to render dynamic notification text templates.
It becomes relevant when:
- Users or integrated systems can supply or influence template expressions evaluated by
str_eval() - The application relies on
str_eval()'s sandbox to block access to dangerous attributes and callables - Lambda expressions or other nested constructs are permitted in template expressions
The issue affects environments where template authorship is not fully trusted, or where a lower-privileged user can create or modify notification templates.
Exploit preconditions
- Attack surface: Notification text templates evaluated by Tautulli's
str_eval()function. - Required access: Ability to create, edit, or indirectly control notification templates or expressions (e.g., through UI, configuration, or synced settings).
- Trigger point: Submission of a crafted expression that uses lambda or nested code objects so that dangerous attribute accesses reside in
code.co_constsrather thancode.co_names. - Why exploitation is possible: The sandbox only inspects
code.co_namesof the top-level compiled code object to restrict names, but it does not recursively inspect nested code objects (e.g., from lambdas). As a result, restricted attributes and callables can be referenced inside nested code, bypassing the intended name-based restrictions.
Why this happens
The core issue is an overreliance on Python bytecode metadata (code.co_names) to enforce a security policy for dynamic expression evaluation.
The str_eval() function compiles user-controlled expressions and attempts to detect and block dangerous names by examining the top-level code object's co_names. However, lambda expressions and other nested constructs generate separate code objects whose attribute accesses and references may appear in code.co_consts instead.
Because the sandbox does not traverse or analyze these nested code objects, it leaves an unchecked path for invoking restricted attributes or functions. This maps to:
- CWE-94: Improper Control of Generation of Code ('Code Injection') — user-influenced input ultimately controls dynamically evaluated code.
- CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code — filters and checks fail to neutralize dangerous directives in evaluated expressions, especially within nested contexts.
Potential impact
- Execution of arbitrary Python code within the Tautulli process context
- Reading or modification of Tautulli configuration, logs, and in-memory data
- Access to environment variables, including secrets or tokens available to the process
- Local file read/write where the Tautulli service account has permissions
- Use of Tautulli as a pivot to further compromise the underlying host or connected services
General mitigation guidance
Effective mitigation focuses on eliminating or strictly constraining dynamic code evaluation for user-controlled template data:
- Prefer non-evaluating templating mechanisms (e.g., simple variable interpolation and filters) rather than
eval()-style execution of arbitrary expressions. - If expression evaluation is required, use a dedicated, security-focused expression language or sandbox that does not expose Python's full execution environment.
- Treat all template input as untrusted: clearly separate trusted system-defined functions/variables from user-supplied content, and expose only a narrow whitelist of safe operations.
- Avoid implementing ad-hoc eval sandboxes based solely on bytecode inspection or name filtering; instead, use interpreters or libraries designed for restricted execution.
- Run the Tautulli process with least-privilege OS permissions to reduce the blast radius if code execution occurs.
How teams detect issues like this
Organizations can look for and monitor insecure dynamic evaluation patterns and template abuse by:
- Static analysis focused on:
- Use of
eval(),exec(), or custom equivalents that accept non-constant input - Custom sandbox implementations that rely on introspection of
codeobjects or simple name-based filtering - Code review practices that flag:
- Any path where user-supplied text is compiled or evaluated as code
- Complex notification or templating logic implementing partial Python interpreters
- Security testing:
- Fuzzing and targeted tests of template/notification input fields with nested expressions and lambda constructs
- Attempting to reference restricted attributes through multiple levels of indirection or nested scopes
- Policy enforcement:
- Coding guidelines that disallow direct or indirect evaluation of user-controlled strings as Python code
- CI checks that fail builds if disallowed evaluation APIs or patterns are introduced

