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/.htaccessconfiguration explicitly allows direct web access toprint.*.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.*.phpfiles 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.*.phpURL. - 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.phpfile in a directory explicitly configured by.htaccessto 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.,.htmlor.txt) and configure the web server not to execute them. - Revisit web server and
.htaccessrules 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
.phpfiles or passed to dynamic code execution constructs. Look for direct persistence of rich text fields or templates to executable paths. - Configuration review: Examine
.htaccessand web server configurations for exceptions that allow public access to dynamically created.phpfiles 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.*.phppaths, 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.

