/

CVE-2026-45136

Severity:

HIGH RISK

(7.8)

Command/Code Injection via Unsanitized String Interpolation (CWE-78/CWE-94) in claude-code-cache-fix quota-statusline hook

CVE-2026-45136

Analyzed

Vulnerability type

Category:

Command / Code Injection

CWE:

CWE-78, CWE-94

Impact:

Arbitrary Code Execution in User Process

Severity:

HIGH RISK

(7.8)

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

From versions 3.5.0 to before 3.5.2, claude-code-cache-fix's tools/quota-statusline.sh script interpolates Claude Code's hook stdin payload directly into a Python triple-quoted string without escaping.

If any user-controlled field in the payload contains a ''' sequence, the Python string literal is prematurely closed and subsequent bytes are executed as Python code in the user's Claude Code process, enabling local code execution in that context.

Affected context

This issue arises in environments where:

  • claude-code-cache-fix versions 3.5.0 to before 3.5.2 are installed.
  • The tools/quota-statusline.sh helper is used as part of the Claude Code hook workflow.
  • The hook consumes stdin payloads that include fields influenced by user or external input (for example, project metadata, filenames, or status messages).

The vulnerable behavior occurs when the shell script constructs a Python snippet that embeds the raw payload inside a triple-quoted string, relying on the payload being well-formed and non-malicious.

Exploit preconditions

  • Attack surface: The stdin payload consumed by the Claude Code hook and passed through tools/quota-statusline.sh into an embedded Python fragment.
  • Required access: Ability to influence or control any field in the hook payload (e.g., via project configuration, file names, generated content, or other processed user input).
  • Trigger point: Processing of a payload containing a ''' byte sequence (three single quotes) in a user-controlled field while the vulnerable script is executed.
  • Why exploitation is possible: The script directly embeds the unescaped payload into a Python triple-quoted string literal. A crafted ''' sequence closes the string early, and the remaining bytes are parsed and executed as Python code within the user's Claude Code process.

Why this happens

The root cause is unsafe construction of executable code by concatenating untrusted data into a Python source fragment, then invoking the Python interpreter on that fragment.

Specifically, the shell script uses a triple-quoted Python string to wrap the hook payload but performs no escaping or validation on the payload content. This enables an attacker-controlled ''' sequence to terminate the string and inject arbitrary Python syntax. This maps to:

  • CWE-94: Improper Control of Generation of Code ('Code Injection'), because user-controlled data influences dynamically generated code.
  • CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), by extension when injected Python code spawns system commands or interacts with the OS.

The insecure pattern is trusting that structured, human-readable data will not contain language delimiters, instead of treating it as untrusted input requiring strict encoding or non-code handling.

Potential impact

  • Execution of arbitrary Python code within the user's Claude Code process.
  • Reading or modifying local project files accessible to that process.
  • Exfiltration of sensitive data (API keys, tokens, configuration files) from the user environment.
  • Launching OS-level commands via Python standard library calls (e.g., spawning shells or other processes).
  • Persistence within the development environment, such as writing malicious hooks or modifying configuration in the project workspace.

General mitigation guidance

Effective mitigation focuses on breaking the direct link between untrusted payload data and executable code:

  • Avoid generating Python (or any language) source code by string concatenation with untrusted input; instead, pass data as data (e.g., via stdin, JSON, environment variables, or arguments).
  • If a Python string literal must contain user-controlled content, apply strict escaping/encoding to all string delimiters and special characters before interpolation.
  • Prefer structured serialization (JSON, YAML with safe loaders, or other typed formats) and parse the payload as data rather than embedding it in executable code.
  • Enforce a clear separation of concerns: keep scripting logic (code) separate from dynamic content (data), and avoid designing scripts that "print code" for another interpreter.
  • Run auxiliary tooling with least-privilege and minimal filesystem/system access, so that even if similar issues arise, the blast radius is reduced.

How teams detect issues like this

To detect similar vulnerabilities:

  • Static analysis: Define rules to flag:
  • Shell scripts or programs that construct interpreter invocations (e.g., python -c, node -e) with embedded variables derived from stdin or other untrusted sources.
  • Use of multi-line string literals or heredocs in combination with unescaped variable substitution that can affect language delimiters.
  • Code review signals: Look for patterns where:
  • Scripts embed user or environment data directly into code snippets for another interpreter.
  • Triple-quoted strings, heredocs, or other string delimiters contain interpolated variables without explicit escaping.
  • Policy enforcement: Establish guidelines that:
  • Disallow passing arbitrary user input into python -c, sh -c, or similar command-evaluating interfaces.
  • Require encoding or structured serialization when cross-language boundaries are involved (e.g., shell → Python).
  • Automated review tools (SAST or linters) can be configured to highlight code generation paths, command construction with interpolated variables, and unescaped use of delimiters.

Sources

SourceLink
github.comgithub.com/cnighswonger/claude-code-cache-fix/issues/108
github.comgithub.com/cnighswonger/claude-code-cache-fix/pull/110
github.comgithub.com/cnighswonger/claude-code-cache-fix/security/advisories/GHSA-g3xq-3gmv-qq8g

Frequently asked

questions

It can be, depending on how the hook payload is populated. If remote sources (such as remote repositories, services, or collaborators) can influence fields in the hook stdin payload, then an attacker could trigger code execution remotely via those inputs.

An attacker needs the ability to control or influence at least one user-controlled field in the payload processed by tools/quota-statusline.sh. This might come from editing project files, configuration, or any upstream data that flows into the hook input.

The safest pattern is to stop embedding untrusted data directly into code. Pass payload content as data (e.g., via JSON or stdin) into a Python script that reads and processes it without using python -c with string interpolation. If embedding is unavoidable, rigorously escape delimiters and special characters.

Avoid dynamic code generation with untrusted input, enforce secure coding guidelines around command and code construction, and use automated checks to flag patterns like python -c or shell heredocs that interpolate variables. During design and review, ensure that data is kept separate from executable code and is always treated as untrusted by default.

Find out what's already
exploitable in your codebase.