/

CVE-2026-45708

Severity:

HIGH RISK

(7.2)

Code Injection in CubeCart Invoice Editor

CVE-2026-45708

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.2)

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

CubeCart versions prior to 6.7.3 allow an administrator with document edit permissions to inject raw PHP code into the Invoice Editor template.

When any admin later prints an order, the malicious template is rendered into a PHP file that can be executed by any unauthenticated visitor, enabling remote code execution under specific administrative misuse conditions.

Affected context

This vulnerability occurs in CubeCart deployments where:

  • The Invoice Editor feature is used to customize invoice templates
  • At least one admin account has "documents edit" (invoice edit) permissions
  • The application writes rendered invoice output into web-accessible PHP files (e.g., files/print.<md5>.php)
  • The files/.htaccess configuration explicitly allows direct web access to print.*.php

The risk materializes when a privileged admin user saves PHP code inside the invoice template, which later becomes part of a generated PHP file served to the public.

Exploit preconditions

  • Attack surface: Web-accessible print.*.php files generated from the invoice template.
  • Required access:
  • Initial step requires an authenticated admin with documents/invoice edit permissions to insert PHP code into the Invoice Editor.
  • Subsequent triggered execution is accessible to any unauthenticated visitor who can reach the generated print.*.php URL.
  • Trigger point: Any admin clicking "Print" on any order causes the invoice template to be rendered and written as files/print.<md5>.php. When that file is requested over HTTP, the PHP code executes on the server.
  • Why exploitation is possible: The templating system allows raw <?php … ?> blocks to be stored without sanitization, then renders them into a server-executable .php file in a directory explicitly configured by .htaccess to allow direct public access.

Why this happens

The core issue is a failure to enforce content and context separation between user-editable templates and executable server-side code.

By allowing raw PHP tags in an admin-editable invoice template, the application effectively treats template content as trusted server code and later persists it as .php under the web root.

This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where dynamically generated code is composed from data that has not been constrained to non-executable forms. The .htaccess carve-out for print.*.php further ensures that these generated files are both reachable and executed by the PHP engine.

Potential impact

  • Remote execution of arbitrary PHP code in the web server context
  • Complete compromise of the CubeCart application, including modification of orders, products, and customer data
  • Theft or manipulation of sensitive information such as customer details, order history, and configuration secrets
  • Establishment of persistent server-side backdoors or web shells
  • Pivoting to underlying operating system resources, depending on server configuration and privileges

General mitigation guidance

Effective mitigation focuses on ensuring that data editable via the UI cannot become executable server-side code:

  • Restrict invoice and document editors to a safe templating language that does not interpret raw PHP, executing only a predefined set of template directives.
  • Strip or reject PHP tags (<?php, <?=, <?) and other executable constructs from all user- or admin-supplied template content.
  • Avoid writing any user-controlled content to files with executable extensions (such as .php); use neutral formats (e.g., .html or .txt) and configure the web server not to execute them.
  • Revisit web server and .htaccess rules to remove broad allowlists for dynamically generated executable files and favor deny-by-default for new file patterns.
  • Apply least-privilege principles so the application can write only where strictly necessary, and not to executable locations when dynamic content is involved.

How teams detect issues like this

Organizations can approach detection both at code and runtime:

  • Static analysis: Flag patterns where template content or other user-controlled strings are written to .php files or passed to dynamic code execution constructs. Look for direct persistence of rich text fields or templates to executable paths.
  • Configuration review: Examine .htaccess and web server configurations for exceptions that allow public access to dynamically created .php files or other executable types.
  • Code review signals: Highlight any template editors that accept raw HTML or mixed content and confirm that PHP tags and script-like constructs are either disabled or rigorously filtered.
  • Runtime monitoring: Log and alert on access to unusual or hash-like print.*.php paths, and correlate with recent template changes by admins.
  • Automated security testing tools (SAST/DAST) can assist in spotting user-controlled content being written to executable files and misconfigured execution carve-outs.

Sources

SourceLink
github.comgithub.com/cubecart/v6/security/advisories/GHSA-747j-4mmc-cj63

Frequently asked

questions

Indirectly. An admin with documents edit permissions must first save PHP code into the Invoice Editor. Once a malicious template has been stored and a print file generated, any unauthenticated visitor who can access the print.*.php URL can trigger execution of that code.

The initial injection requires an authenticated admin account with permission to edit documents/invoices. No direct template editing is available to regular users or visitors under normal configurations.

The robust fix pattern is to ensure that template content is never treated as executable code: disallow PHP in templates, store templates as data-only, render them into non-executable formats, and avoid writing user- or admin-controlled content into .php files or other executable contexts.

Design editing tools around non-executable templating systems, enforce strict input constraints (e.g., stripping executable tags), keep dynamically generated files non-executable by server configuration, and incorporate security review and automated checks for any feature that writes files under the web root.

Find out what's already
exploitable in your codebase.